Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

X86 Assembly Write an assembly program to test if the MSB in the register al is

ID: 3820624 • Letter: X

Question

X86 Assembly Write an assembly program to test if the MSB in the register al is set: If it is set, then divide the content of al by 4 using the appropriate shift instruction and exit. Else, if it is not set, then multiply the content of al by 8 using the appropriate shift instruction and exit. When checking al MSB, do not change al content. Assume that al is equal to the signed integer 18h. You need to come up with the appropriate mask to check the MSB. Run your program using the debugger to verify your answers.

can you show how to write the answer in visual studio? like .data and .code. thanks!

Explanation / Answer

section .text

global _start

_start:

;load 18h in al

mov al,18h

;copy the al into bl

mov bl,al

;check MSB is set

and bl,80h

;if MSB is not set, go to multInst

jz multInst

;divide the al by 2

shr al,2

;jump to exitCode

jmp exitCode

;multiply al by 8

multInst:

shl al,3

;exitCode

exitCode:

mov eax,1

int 0x80