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

  • Home
  • SEARCH
  • 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 7726923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:19:55+00:00 2026-06-01T05:19:55+00:00

I want to do something simple in assembly language. addition two numbers, and print

  • 0

I want to do something simple in assembly language.
addition two numbers, and print the result on the screen.

I did that code:

.Model SMALL
.Stack 100h

.Code
start:
   MOV ax, 10
   ADD ax, 5
   MOV ah, 02h
   INT 21h 

   MOV ah, 01h
   INT 21h

   MOV ah, 4ch
   INT 21h

end start

After compile the code without any error, tells me a strange character .


Modified:

MOV dl, 10
ADD al,5
MOV dl, al

MOV ah,02h
INT 21h 

but still print a strange character
I don’t know what can I do to print number on the screen

  • 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-01T05:19:56+00:00Added an answer on June 1, 2026 at 5:19 am

    Yes, you will most likely get a strange character because int 21/ah=02 requires the character to print to be in the dlregister, and you haven’t populated dl with anything.

    You may want to transfer the value with something like:

    mov  ax, 10
    add  ax, 5
    
    push ax             ; these are the two new lines.
    pop  dx
    
    mov  ah, 02h
    

    However, keep in mind that, even if you do transfer the value from al to dl, character number 15 may not be what you expect. 15 is one of the ASCII control characters and I’m not sure what the DOS interrupts will output for them.

    If you want to print out the digits15, you will need two calls, one with dl = 31h and the second with dl = 35h (the two ASCII codes for the 1 and 5 characters).

    If you want to know how to take a number in a register and output the digits for that number in readable form, there’s some pseudo-code in an earlier answer of mine.

    From that answer, you have the pseudo-code:

        val = 247
    
        units = val
        tens = 0
        hundreds = 0
    loop1:
        if units < 100 goto loop2
        units = units - 100
        hundreds = hundreds + 1
        goto loop1
    loop2:
        if units < 10 goto done
        units = units - 10
        tens = tens + 1
        goto loop2
    done:
        if hundreds > 0:                 # Don't print leading zeroes.
            output hundreds
        if hundreds > 0 or tens > 0:
            output tens
        output units
        ;; hundreds = 2, tens = 4, units = 7.
    

    Now you need to translate that into x86 assembly. Let’s start with the desired value in ax:

        mov  ax, 247                 ; or whatever (must be < 1000)
        push ax                      ; save it
        push dx                      ; save dx since we use it
    
        mov  dx, 0                   ; count of hundreds
    loop1:
        cmp  ax, 100                 ; loop until no more hundreds
        jl   fin1a
        inc  dx
        sub  ax, 100
        jmp  loop1
    fin1a:
        add  dx, 30h                 ; convert to character in dl
        push ax                      ; save
        mov  ah, 2
        int  21h                     ; print character
        pop  ax                      ; restore value
    
        ; now do tens and units the same way.
    
        pop dx                       ; restore registers
        pop ax
    

    Now that code segment (notwithstanding any errors due to the fact it’s been a while since I did assembly) should print out the hundreds digit and leave ax with only the tens and units digit.

    It should be a simple matter to duplicate the functionality twice more to get the tens and units places.

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

Sidebar

Related Questions

I want to implement something simple like /System/Workflows/Sample Workflow with the small addition of
I want to load this simple something into my Editor: Write:-repeat,write(hi),nl,fail. So that it
I know it's simple to implement, but I want to reuse something that already
I want to code a simple form layout in flex. Something like the following:
I want something simple in order to experiment/hack. I've created a lot interpreters/compilers for
I want to something as simple as turning this is a test into new
I want to be able to download a URL in C++. Something as simple
I want to implement something with jquery, simple javascript and java but I don't
I've built a simple cms with an admin section. I want to create something
I'm writing a simple Perl script that translates assembly instruction strings to 32-bit binary

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.