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 8269931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:23:42+00:00 2026-06-08T06:23:42+00:00

.MODEL SMALL .STACK 1000 .DATA MSGA DB 13,10,Input first number: ,$ MSGB DB 13,10,Input

  • 0
.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
ADD CL, DH 
ADC BL, DL
MOV NUM1, CL
ADD NUM1, '0'
MOV NUM2, BL
ADD NUM2, '0'

; output sum
LEA DX, MSGC
MOV AH, 09h
INT 21h

MOV DL, NUM2
MOV AH, 02H
INT 21h

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

MOV AH, 4Ch
INT 21h

MAIN ENDP
END MAIN

Above is my code for adding 2 two-digit numbers in assembly. I wonder why the ADC doesn’t work. If the ones digits don’t obtain a carry when added, my code works. But not otherwise. Did I misunderstand what the ADC really does? What should I do with my code?

  • 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-08T06:23:44+00:00Added an answer on June 8, 2026 at 6:23 am

    You appear to be working with decimal math, but you’re not using AAA. ADC does what you’d expect, but with that code there is never an actual carry from the first addition (9+9 is not bigger than 255, after all).

    So the solution, of course, is to use AAA, like this (not tested):

    add al,dl
    aaa        ; takes no arguments and works on al
    add ah,dh  ; adc not necessary, aaa already incremented ah if there was a carry
    

    AAA (ASCII Adjust for Addition) tests if al is bigger than 9, and if so:

    • adjusts al,
    • sets the carry flag, and
    • increments ah
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

.MODEL SMALL .STACK 64 .DATA MSGA DB 13,10,Input first number: ,$ MSGB DB 13,10,Input
.model small .stack 100 .data .code mov ah,00h mov al,0e3h mov dx,00h int 14h
I need to create an executable from the next assembly code: .MODEL SMALL .DATA
I'm working with a small model in Entity Framework 4.0. I'd like to have
I'm writing a small program to record reading progress, the data models are simple:
model.py: class Tribes(Group): members = models.ManyToManyField(User, related_name='tribes', verbose_name=_('members')) i want to store a number
We're developing a data heavy modular web application stack with java but have little
I am using the Model-View pattern on a small application I'm writing. Here's the
I need to show all numbers from matrix(3x3) where number has two first bits
Im currently working on a small project in which I need to model the

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.