-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdinp.asm
More file actions
48 lines (43 loc) · 1.07 KB
/
stdinp.asm
File metadata and controls
48 lines (43 loc) · 1.07 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
.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
extern printf:NEAR
extern scanf:NEAR
; PROTO sets up a function that will be called w/ argument INVOKE
.data
; variables go here
input DWORD 8 DUP(0)
;input DWORD 0
format BYTE "%x",0
reversed DWORD 8 DUP(0)
;reversed DWORD 0
format_hex BYTE "Final result: %x",0
.code
main PROC c
push offset input
push offset format
call scanf
add esp,8
;originally used DWORD PTR
mov eax, [input]
mov ebx, [input+1]
mov ecx, [input+2]
mov edx, [input+3]
;mov DWORD PTR[reversed], eax
;mov DWORD PTR[reversed+1], ebx
;mov DWORD PTR[reversed+2], ecx
;mov DWORD PTR[reversed], edx
mov [reversed], edx
mov [reversed+1], ecx
mov [reversed+2], ebx
mov [reversed+3], eax
push reversed
push offset format_hex
call printf
add esp, 8
INVOKE ExitProcess,0 ;
main endp ;
end