Q1: Consider the last 2 digits of your registration number as a hexadecimal number.
i) Write the code to multiply this number by 6 without using the MUL command.
ii) Write the code to divide this number by 2 without using the DIV command.
;MS Visual Studio 2017
INCLUDE irvine32.inc
.data
num dword ?
EnterN BYTE "Enter hex: ",0
Answer BYTE "Answer Decimal:",10,13,0
.code
main PROC
mov edx, OFFSET EnterN ; "Enter hex: "
call writeString ; writes a string
call ReadHex
mov num,eax
mov edx, OFFSET Answer ; Answer Decimal"
call writeString ; writes a string
; to multiply number by 6 without using the MUL command
xor edx,edx
mov ecx,6
mult_6:
add edx,eax
loop mult_6
mov eax, edx
call writeDec
call crlf
; to divide number by 2 without using the DIV command
div2:
mov eax, num
shr eax,1
call writeDec
call crlf
call crlf
call waitMsg
exit
main ENDP
END main
Comments
Leave a comment