News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Magic with printf and scanf.

Started by ko2, October 28, 2017, 04:03:16 AM

Previous topic - Next topic

ko2

Hello everybody.

I start learning masm, but I done't actully know what problem is.
The first example is not correct. The second work truly. Explain me please  :(

include /masm32/include/masm32rt.inc

.data

ConsoleTitle db 'Input', 0
mess_1 db 'Write arg1: ', 0
mess_2 db 'Write arg2: ', 0
mess_3 db ' + | - | * | / : ', 0

arg1 DWORD 0
arg2 DWORD 0
arg3 DWORD ?
res DWORD 0

formats db '%d', 0
formats2 db "%d %c %d = %d", 10, 0
formats3 db "%c", 0

.code

main PROC

invoke SetConsoleTitle, offset ConsoleTitle

invoke crt_printf, addr mess_1
invoke crt_scanf, addr formats, addr arg1

invoke crt_printf, addr mess_2
invoke crt_scanf, addr formats, addr arg2

invoke crt_printf, addr mess_3
invoke crt_scanf, addr formats3, addr arg3

invoke crt_printf, addr formats2, arg1, arg3, arg2, res
inkey

invoke ExitProcess, 0
main ENDP
END main

"Image1"




include /masm32/include/masm32rt.inc

.data

ConsoleTitle db 'Input', 0
mess_1 db 'Write arg1: ', 0
mess_2 db 'Write arg2: ', 0
mess_3 db ' + | - | * | / : ', 0

arg1 DWORD 0
arg2 DWORD 0
arg3 DWORD ?
res DWORD 0

formats db '%d', 0
formats2 db "%d %c %d = %d", 10, 0
formats3 db "%c", 0

.code

main PROC

invoke SetConsoleTitle, offset ConsoleTitle

invoke crt_printf, addr mess_3
invoke crt_scanf, addr formats3, addr arg3

invoke crt_printf, addr mess_1
invoke crt_scanf, addr formats, addr arg1

invoke crt_printf, addr mess_2
invoke crt_scanf, addr formats, addr arg2

invoke crt_printf, addr formats2, arg1, arg3, arg2, res
inkey

invoke ExitProcess, 0
main ENDP
END main

"Image2"