Question: . 4 8 6 . model flat, stdcall option casemap: none include masm 3 2 include windows . inc ; For Windows
model flat, stdcall
option casemap: none
include masmincludewindowsinc ; For Windows API types and definitions
include masmincludeuserinc ; For using MessageBox
include masmincludekernelinc ; For using ExitProcess
include masmincludemasminc ; For using FloatToStr
includelib masmlibuserlib ; Library for MessageBox
includelib masmlibkernellib ; Library for ExitProcess
include Extmacros.inc
NUM macro Q M N O
MOV AL M ; Copy number M to register AL
CBW ; Signextend AL to AX
MOV BL ; Copy constant to register BL
IDIV BL ; Division register AX by constant quotient in AL
ADD AL N ; Add N to AL
SUB AL ; Subtract from AL
CBW ; Signextend AL to AX
MOV Q AX ; Store the result in the memory location specified by Q
endm
DEN macro Q M N O
MOV AL M ; Copy number M to register AL
MOV BL N ; Copy number N to register BL
IMUL BL ; Multiply AL by BL ab
DEC AL ; Decrement AL by
MOV Q AL ; Store the result in the memory location specified by Q
endm
data
msgtitle db "Lab
buffer db dup
format db A dB dC dC BACB d
msgtitle db "WARNING!", ; text variable for title of window
msgmessage db "Value in denominator equal ; text variable for text in window
A DB
B DB
C DB
D dd
E dd
F dd
code
start:
MOV EDI, ; Pointer to set
WHILE EDI
NUM BX BEDI CEDI
DEN AL AEDI BEDI CEDI
CMP AL ; Compare value in AL with
jz ZERO
TEST AL ; Test if AL is odd
JNZ ODDRESULT ; Jump to ODDRESULT if AL is odd
EVENRESULT:
SAR AL ; Rightshift AL by divide by
JMP CONT ; Jump to CONT
ODDRESULT:
; Handle odd result here multiply by for example
MOV BH ; Set BH to
IMUL BH ; Multiply AL by
; Continue with further processing as needed
CONT:
CWDE
movsx ESI, AEDI
mov D ESI
movsx ESI, BEDI
mov E ESI
movsx ESI, CEDI
mov F ESI
invoke wsprintf, addr buffer, addr format, D E F eax
invoke MessageBox, addr buffer, addr msgtitle, MBOK
jmp PRCONT
ZERO:
invoke MessageBox, addr msgmessage, addr msgtitle MBOK
PRCONT:
INC EDI
ENDW
invoke ExitProcess,
end start
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
