Hello! I am a newbie in assembler language programming area. Help me please to solve my "great problem"
I attempted to write a program which is calculating the sum of the two floating point numbers. It was compiled successfully, but the result of the run was unexpected for me. For example, if the one number is 1.3 and another is 1.8, the sum should be equal to 3.1 But my program returns extremely big number as the sum. This is the text of the program:
include'include\win32a.inc' start: cinvokeprintf, req, 41h; Âûâîä íà ýêðàí
cinvokescanf, tpt, A; ââîä A
cinvokeprintf, req, 42h; Âûâîä íà ýêðàí
cinvokescanf, tpt, B; ââîä B
fld [A] fld [B] faddst0, st1
fstdword [C] cinvokeprintf, tpo, C
invokesleep, 50000; 50 sec. delay
gtfo: invokeexit, 0
tpodb'A + B = ' tptdb'%f',0
; import data in the same section
librarymsvcrt,'MSVCRT.DLL',\ kernel32,'KERNEL32.DLL' importkernel32,\ sleep,'Sleep' importmsvcrt,\ puts,'puts',\ scanf,'scanf',\ printf,'printf',\ exit,'exit' enddata
What was my mistake? My CPUs are AMD E2 and Intel Core i3.
Using 32-bit floats may complicate things further (promotion, multiple pushes etc). Try using all doubles for variables and see how it goes. Btw, printf's arguments like variables are passed by values, not by reference. If you are new, my suggestion is to test short codes first especially when dealing with Win API and high-level constructs. They are known to hide things and children.
Ok, here's a wild guess of what you are trying to achieve here
cinvokegetchar;for that classic "I can't see the output" cry.
fldqword[A] ;the thing
fstpqword[C] ;Split the double into two unit. printf dont like floats.
cinvokeprintf,f,dword[C],dword[C+4] cinvokegetchar;don't fall asleep!
xdb'%lf',0;double needs a %lf specifier for scanf
I'm not interested in solving it for you but judging by the blasphemy of Win API that you are messing up with, I decided to throw in some clues.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum