Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:59:24+00:00 2026-06-08T07:59:24+00:00

I managed to make the addition of two-digit numbers based on the solutions provided

  • 0

I managed to make the addition of two-digit numbers based on the solutions provided by helpful people from the thread I created last time:

How do I use ADC in assembly?

So now, there seems to be a problem when I add 2 numbers and their result will be a 3-digit number. The jump named IS_3DIGIT handles that possibility, but addition of some numbers like 80 + 80, 99 + 99, 89 + 82 all give wrong results. 56 + 77 works well. So my hypothesis is that adding two numbers higher than 79 will give wrong results. How can I resolve this problem? BTW, additions like 99 + 23 or 89 + 43 give correct results.

.MODEL SMALL
.STACK 1000
.DATA

MSGA DB 13,10,"Input first number: ","$"
MSGB DB 13,10,"Input second number:","$"
MSGC DB 13,10,"The sum is: ","$"

NUM1 db ?
NUM2 db ?
NUM3 db ?

.CODE

MAIN PROC NEAR

MOV AX, @DATA
MOV DS, AX

; get first number
LEA DX, MSGA
MOV AH, 09h
INT 21h

MOV AH, 01
INT 21H
SUB AL, '0'

MOV BL, AL

MOV AH, 01
INT 21H
SUB AL, '0'

MOV CL, AL

; get second number
LEA DX, MSGB
MOV AH, 09h
INT 21h

MOV AH, 01
INT 21H
SUB AL, '0'

MOV DL, AL

MOV AH, 01
INT 21H
SUB AL, '0'

MOV DH, AL

; add
MOV AL, CL
MOV AH, BL
ADD AL, DH
AAA 
ADD AH, DL

MOV NUM1, AL
ADD NUM1, '0'

; if tens digit is less than or equal to 9
CMP AH, 9
JLE NOT_3DIGIT 

IS_3DIGIT:
MOV AL, AH   ; move value of ah to al
SUB AH, AH   ; clear ah
ADD AL, 0    ; al + 0 = al (tens digit)
AAA          ; move for addition
ADD AH, 0    ; ah + 0 + 1 = ah + 1 (hundreds digit)
MOV NUM2, AL
MOV NUM3, AH
ADD NUM2, '0'
ADD NUM3, '0'
; output sum
LEA DX, MSGC
MOV AH, 09h
INT 21h
MOV DL, NUM3
MOV AH, 02H
INT 21h
MOV DL, NUM2
MOV AH, 02H
INT 21h
JMP PRINT_LASTDIGIT


NOT_3DIGIT:    
MOV NUM2, AH
ADD NUM2, '0'
; output sum
LEA DX, MSGC
MOV AH, 09h
INT 21h
MOV DL, NUM2
MOV AH, 02H
INT 21h

PRINT_LASTDIGIT:
MOV DL, NUM1
MOV AH, 02H
INT 21h

EXIT:
MOV AH, 4Ch
INT 21h

MAIN ENDP
END MAIN
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:59:25+00:00Added an answer on June 8, 2026 at 7:59 am

    Well you did it the “hard way”, really. Again, aaa can do all the hard work, as long as the right things are in ah and al, so different cases for overflow and no overflow aren’t really necessary.

    Something like this (untested):

    ; ah:al = tens:ones
    add al,dh
    aaa
    ; now make ah:al hundres:tens
    mov bl,al
    mov al,ah
    xor ah,ah   ; this will be the hundreds digit
    add al,dl
    aaa
    ; result in ah:al:bl
    

    I took the use of dh and dl from your source, and bl is just some extra place. They’re not important, but the things in ah and al really have to be there, just as last time.

    I’ve read the descriptions of aaa and add very closely, and I think that should work even though the second add can be adding 10 to something, but I’m only about 90% sure about that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created some documents and managed to make some simple queries but I
I have managed to make the last TD in each row unselectable in JQuery
Somehow I managed to make the date work, <td width=67><font size=3><b>*Date</b></td> <td width=3>:</td> <td
I have an assembly which I have managed to make visible to VB6 and
I am using a timer in xcode i have managed to make it count
I'm a newbie to jquery, but have managed to make a show-function and hover
with the help of resources of stackoverflow, i have managed to make autocomplete on
How to make use of jndi in a stand-alone (non-managed) application? App and Tomcat6
I'm trying to make sure that my Managed to Unmanaged calls are optimized. Is
I'm trying to make a network system using UDP. I've managed to get it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.