Cant understand why this code output in a result:ERROR

52 Views Asked by At

I think I'm using the right commands to do this task, but for some reason the result is wrong.

I have already tried to change this string _res1 db 14 DUP(0),10,13. I also tried to change dword on REAL4, but its was pointless

.486 ;sets the CPU to 80486 instruction set mode

.model flat, stdcall ;sets the memory model to flat and the calling convention to stdcall

option casemap :none ;sets the case sensitivity option for symbols to none     
include \masm32\include\windows.inc ; connecting the windows.inc program file    
include \masm32\macros\macros.asm ; MASM support macros
include \masm32\include\masm32.inc ; connecting the program file masm.inc
include \masm32\include\gdi32.inc ; connecting the program file gdi32.inc
include \masm32\include\fpu.inc ; connecting the program file fpu.inc
include \masm32\include\user32.inc ; connecting the user32.inc program file
include \masm32\include\kernel32.inc ; connecting the program file kernel32.inc
include \masm32\include\msvcrt.inc ; connecting the msvcrt.inc program file 
includelib \masm32\lib\msvcrt.lib ; connecting the msvcrt.lib library
includelib \masm32\lib\fpu.lib ; connecting the fpu.lib library
includelib \masm32\lib\masm32.lib ; connecting the masm32.lib library
includelib \masm32\lib\gdi32.lib ; connecting the gdi32.lib library
includelib \masm32\lib\user32.lib ; connecting the user32.lib library
includelib \masm32\lib\kernel32.lib ; connecting the kernel32.lib library

uselib masm32, comctl32, ws2_32 

.data ; data definition directive
_const_A DWORD 1.5 ;declaration of the constant
_const_B DWORD 0.7 ;declaration of the constant
_result DWORD 0.0 ;declaration the result
_title db "Laboratorna robota 5",0 ; set the title for the message box
strbuf dw ?,0 ; define a buffer for the message box output
_text db " Student of KNEU IITE",10,
    "Output result by MessageBox:",10, 
    "A+B",10,
    "Result: " ; set the message box output text

_res1 db 14 DUP(0),10,13 ; Define a string with a length of 14 characters filled with 0s, and line feed and carriage return at the end
    
.code ; Command segment start directive
start: ; Program start mark with the name _start
    finit ;initialization of coprocessor
    fld _const_A ;
    fadd _const_B ;  
    fstp _result ; save value in variable _result
    invoke FpuFLtoA, 0, 10, ADDR _res1, SRC1_FPU or SRC2_DIMM
    invoke MessageBox, 0, offset _text, offset _title, MB_ICONINFORMATION
    invoke ExitProcess, 0 ; exit the program
end start ; End of the program

Screenshot of program: enter image description here

OllyDBg screenshot: enter image description here

0

There are 0 best solutions below