Answer to Question #295683 in Assembler for Answer lelo.

Question #295683

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.


1
Expert's answer
2022-02-09T18:58:16-0500
;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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS