-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq1.asm
More file actions
69 lines (63 loc) · 1.41 KB
/
q1.asm
File metadata and controls
69 lines (63 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
.586 ;indicates what assembly is being used
.model flat, stdcall ; specifies memory model
.stack 4096 ; size of stacks in bytes
includelib libcmt.lib ;include these 2 libraries
includelib legacy_stdio_definitions.lib
ExitProcess PROTO, dwExitCode:DWORD ; ExitProcess(DWORD,PROTO)?
extern printf:NEAR
extern scanf:NEAR
; PROTO sets up a function that will be called w/ argument INVOKE
.data
; variables go here
format1 byte "%s",0
format2 byte "%c",13,10,0
charray byte 20 dup(?)
i dd 20
charac db 0
charlen dd 0
len equ $ - charray
.code
main PROC c
push ebp
mov ebp, esp
sub esp, 20 ;char x[20];
push ebp
push offset format1
call scanf
add esp,8
;debug
jmp after
after:
;must start calling the individual characters by memory in regards to ebp
xor ecx,ecx
xor eax,eax
mov i,0
jmp upd2
upd2:
mov ecx,i
cmp ecx,len
jb loop_body2
jmp rtn
loop_body2:
;consider using pop to get from the reverse
;or going from 80 to 0
;add i,4
;movzx charac, i
cmp byte ptr [ebp],65
jb rtn
cmp byte ptr [ebp],122
ja rtn
push [ebp]
push offset format2
call printf
add esp,8
inc ebp
inc i
;add esp,4
jmp upd2
rtn:
;add esp,80
pop ebp
INVOKE ExitProcess,0 ; using () does not work, the equivalent of (0) is , 0
main endp ; there are no blocks, must explicity end main procedure
end