Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone, can you help me in getting the remainder and the quotient and display it together? I really don't know how to code it in assembly language as I'm a beginner.

In the code below, I created a program that will add two numbers and display it's sum in decimal form. The sum will be divided to 7 as we need to display the sum in Base 7 form. So for example, I added 7 and 6, the sum should be 16 instead of 13.

To get 16, the sum 13 (base 10/decimal) should be divided to 7 (which is the base) 13/7=1 remainder 6. 1 and 6 should be displayed together (16).

Hope someone can help me to get an idea on how to code this one.

What I have tried:

.MODEL SMALL
.STACK 1000h
.DATA       
    abase7 db 0dh,0ah,'Base 07 Addition$'
    ad db 0dh,0ah, 'Addend(00-99): $'
    au db 0dh,0ah, 'Augend(00-99): $'
    sum db 0dh,0ah,'The sum is   : $'  
    sev db 7
     
.CODE
start:
    mov ax,@data
    mov ds,ax
    mov dx,offset abase7
    mov ah,09
    int 21h

mn:
    mov dx,offset ad
    mov ah,09
    int 21h
    mov ah,01
    int 21h
    
    mov cl,al
    sub cl,30h
    
    mov dx,offset au
    mov ah,09
    int 21h
    mov ah,01
    int 21h
    
    sub al,30h
    
        xor ah,ah
        add al,cl
        aaa
        
        mov cx,ax
        add cx,3030h

        mov dx, offset sum
        mov ah,09
        int 21h

        mov ah,2
        mov dl,ch
        int 21h

        mov dl,cl
        int 21h
 
    mov ah,4ch
     int 21h

end start
Posted
Updated 11-May-21 6:19am

Quote:
... can you help me in getting the remainder and the quotient and display it together? I really don't know how to code it in assembly language as I'm a beginner.

And that's the point: that you learn how to do it, by applying what you have been taught so far.

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

Just dumping irrelevant code on us and hoping we will "fill in the blanks" doesn't help you in the long term, even if we did give you a solution ...
 
Share this answer
 
Comments
Vee Jay Recana 11-May-21 11:39am    
Hi @OriginalGriff, currently I'm stuck at getting the remainder and quotient. I tried dividing cx(sum) to sev(7) and wasn't able to display the quotient and remainder.

xor ah,ah
add al,cl
aaa

mov cx,ax
add cx,3030h
div sev

mov dx, offset sum
Richard MacCutchan 11-May-21 12:19pm    
Please do not repost.
Why have you reposted this question? I already gave you some suggestions at Program to calculate base 7 to base 9 in assembly language[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900