Answer the question
In order to leave comments, you need to log in
My program does not display numbers in the console, how can I fix it?
My program doesn't make sense, it should get 2 numbers and print them out, but it outputs the address in place of the first number and the letter in place of the second number. The program is written using FASM
format PE console
entry start
include 'win32a.inc'
section '.data' data readable writable
formatNum db '%d', 0
formatNum2 db '%t', 0
razmer rb 1
razmer2 rb 1
wn db 'RY? ', 0
ho db 'SY? ', 0
tg db ' %d, %t', 0
NULL = 0
section '.code' code readable executable
start:
push wn
call [printf]
push razmer
push formatNum
call [scanf]
push ho
call [printf]
push razmer2
push formatNum2
call [scanf]
push razmer2
push razmer
push tg
call [printf]
call [getch]
push NULL
call [ExitProcess]
section '.idata' import data readable
library kernel , 'kernel32.dll',\
msvcrt, 'msvcrt.dll'
import kernel,\
ExitProcess, 'ExitProcess'
import msvcrt,\
printf, 'printf',\
getch, '_getch',\
scanf, 'scanf'
Answer the question
In order to leave comments, you need to log in
My program ... displays the address in place of the first number and the letter in place of the second number.
how to fix?
"%d %d"
. push razmer
to pass the address of the razmer variable to scanf, but in printf you need to pass not the address of the variable, but its value. For example like this:mov eax, [razmer]
push eax
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question