Question: . 4 8 6 . model flat, stdcall option casemap: none include masm 3 2 include windows . inc ; For Windows

.486
.model flat, stdcall
option casemap: none
include \masm32\include\windows.inc ; For Windows API types and definitions
include \masm32\include\user32.inc ; For using MessageBox
include \masm32\include\kernel32.inc ; For using ExitProcess
include \masm32\include\masm32.inc ; For using FloatToStr
includelib \masm32\lib\user32.lib ; Library for MessageBox
includelib \masm32\lib\kernel32.lib ; Library for ExitProcess
include Ext_macros.inc
NUM macro Q, M, N, O
MOV AL, M ; Copy number M to register AL
CBW ; Sign-extend AL to AX
MOV BL,4 ; Copy constant "4" to register BL
IDIV BL ; Division register AX by constant "4", quotient in AL
ADD AL, N ; Add N to AL
SUB AL,33 ; Subtract 33 from AL
CBW ; Sign-extend 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 (a*b)
DEC AL ; Decrement AL by 1
MOV Q, AL ; Store the result in the memory location specified by Q
endm
.data
msg_title db "Lab 5",0
buffer db 256 dup(?)
format db "A =%d",10,"B =%d",10,"C =%d",10,"(C -33+ B/4)/(A*C/B -1)=%d",0
msg_title0 db "WARNING!", 0 ; text variable for title of window
msg_message db "Value in denominator equal 0",0 ; text variable for text in window
A DB -2,-6,2,48,-6,2
B DB 8,12,8,48,4,-4
C0 DB 16,14,40,-3,-2,-2
D dd 0
E dd 0
F dd 0
.code
start:
MOV EDI, 0 ; Pointer to set
.WHILE EDI<6
NUM BX, B[EDI], C0[EDI]
DEN AL, A[EDI], B[EDI], C0[EDI]
CMP AL,0 ; Compare value in AL with 0
jz ZERO
TEST AL,1 ; Test if AL is odd
JNZ ODD_RESULT ; Jump to ODD_RESULT if AL is odd
EVEN_RESULT:
SAR AL,1 ; Right-shift AL by 1(divide by 2)
JMP CONT ; Jump to CONT
ODD_RESULT:
; Handle odd result here (multiply by 5, for example)
MOV BH,5 ; Set BH to 5
IMUL BH ; Multiply AL by 5
; Continue with further processing as needed
CONT:
CWDE
movsx ESI, A[EDI]
mov D, ESI
movsx ESI, B[EDI]
mov E, ESI
movsx ESI, C0[EDI]
mov F, ESI
invoke wsprintf, addr buffer, addr format, D, E, F, eax
invoke MessageBox, 0, addr buffer, addr msg_title, MB_OK
jmp PR_CONT
ZERO:
invoke MessageBox, 0, addr msg_message, addr msg_title0, MB_OK
PR_CONT:
INC EDI
.ENDW
invoke ExitProcess, 0
end start

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!