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

I need help finish writting the rest of the assmbly langauge code, please help,

ID: 3790960 • Letter: I

Question

I need help finish writting the rest of the assmbly langauge code, please help, i posted this question 3 times alread and no one helped

The program shown converts a binary number totwo decimal digits. The binary number is loaded from memory at the location N, and the two decimal digits that are extracted from N are stored into memory in two bytes starting at the location Digits. For the value NE76 (0x4c shown in the figure, the code sets Digits to 00000706 Make sure that you understand how the code works. Then, extend the code so that it converts the binary numberto four decimal digits, supporting decimal values up to 9999. You should modify the DIVIDE subroutine so that it can use any divisor, rather than only a divisor of 10. Pass the divisor to the subroutine in register r5. If you run your code with the value NE9876 (0x2694), then Digits should be set to 09080706 Program that converts a bin number to decimal .text .global start star: movie r4, N //r8 points to storage location addi r8, r4, ldw r4, (r4) //r4 loads N call DIVIDE //parameter for DIVIDE is in r4 stb r3, 1(r8) stb r2, (r8) END: br END Subroutine to perform the integer division r4 10 Retums: quotient in r3, and remainder in r2 DIVIDE r2, r4 will be the remainder movi r5, 100 divisor //r3 will be the quotient Movi r3, 0 CONT blt r2, r5, DIV END sub r2, 2,5 addi r3, r3, 1 br CONT DIV END ret word 76 //the decimal number to be converted //space for storage location Digits: space 4 .end

Explanation / Answer

prnstr macro msg mov ah, 09h lea dx, msg int 21h endm data segment buf1 db "Enter a decimal number : $" buf2 db 0ah, "Invalid Decimal Number...$" buf3 db 0ah, "Equivalent Binary number is : $" buf4 db 6 db 0 db 6 dup(0) multiplier db 0ah data ends code segment assume cs:code, ds:data start : mov ax, data mov ds, ax mov es, ax prnstr buf1 mov ah, 0ah lea dx, buf4 int 21h mov si, offset buf4 + 2 mov cl, byte ptr [si-1] mov ch, 00h subtract : mov al, byte ptr [si] cmp al, 30h jnb cont1 prnstr buf2 jmp stop cont1 : cmp al, 3ah jb cont2 prnstr buf2 jmp stop cont2 : sub al, 30h mov byte ptr [si], al inc si loop subtract mov si, offset buf4 + 2 mov cl, byte ptr [si-1] mov ch, 00h mov ax, 0000h calc : mul multiplier mov bl, byte ptr [si] mov bh, 00h add ax, bx inc si loop calc mov si, offset buf4 + 2 mov bx, ax mov dx, 0000h mov ax, 8000h convert : mov cx, 0000h conv : cmp bx, ax jb cont3 sub bx, ax inc cx jmp conv cont3 : add cl, 30h mov byte ptr [si], cl inc si mov cx, 0002h div cx cmp ax, 0000h jnz convert mov byte ptr [si], '$' prnstr buf3 prnstr buf4+2 stop : mov ax, 4c00h int 21h code ends end start

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote