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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:14:41+00:00 2026-05-30T13:14:41+00:00

I am trying to print out the offset values. (Is the term print correct?

  • 0

I am trying to print out the offset values.
(Is the term “print” correct? Is there another term for it?

Is the code correct? I am rather confused with documentation for assembly.

print_offsets:  mov  SI,0
                mov  CX,30
                mov  AH,2
                int  21h
                jmp  offsloop

offsloop:       cmp  0,Array[SI]
                ja   print_offset ;if the array element is nonzero
                inc  SI
                dec  CX
                jnz  offsloop

print_offset:   mov DL,SI
                mov  AH,2
                int  21h
  • 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-05-30T13:14:43+00:00Added an answer on May 30, 2026 at 1:14 pm

    If you’re trying to print numbers, your code is incorrect.

    INT 21h, AH=2 outputs an ASCII character. What your code is doing is putting the offset value into DL. DOS will treat that offset value as an ASCII character and output that instead.

    For example, suppose the first non-zero element is at an offset of 7. Your code will call INT 21h, AH=2 with DL=07. DOS will output the ASCII character 07h which is BEL (basically a system beep). Instead, you would probably want DL=37h in order to output the ASCII character 37h which represents the number 7 digit.

    There are a couple of ways of solving this.

    The first way is easy – if your Array never has more than 10 elements, you can simply add 30h to the offset to convert the offset value to the correct ASCII character value:

    print_offsets:  mov  SI,0          ; SI=offset
                    mov  CX,10         ; CX = count (must be <= 10!!!!)
    
    offsloop:       cmp  0,Array[SI]
                    ja   print_offset ;if the array element is nonzero
    next_element:   inc  SI
                    dec  CX
                    jnz  offsloop
                    jmp finished
    
    print_offset:   mov DL,SI
                    add DL, 30h      ; convert offset to ASCII digit 0..9
                    mov  AH,2
                    ; save the registers in case INT 21h modifies them!
                    push cx          ; save current count
                    push si          ; save current offset
                    int  21h
                    pop si           ; restore current offset
                    pop cx           ; restore current count
                    jmp next_element
    finished:
                    ; do something else!
    

    The second way is more complex because you need to implement a full integer-to-ascii conversion routine. But there are plenty of code samples out there that can do that.

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

Sidebar

Related Questions

In the code below, I am trying to print out a 1-column, 25-row table,
I'm trying to print out debug statements when some third party code changes a
I am trying to print out a table of values in Prolog. Currently I
I'm trying to print out the date in a certain format: NSDate *today =
In Ruby, trying to print out the individual elements of a String is giving
I'm using Django templating with Google App Engine. I'm trying unsuccessfully to print out
I'm trying to come up with an algorithm that will print out all possible
I'm trying to write a very simple program, I want to print out the
I'm trying to print to Dot Matrix printers (various models) out of C#, currently
I'm trying to iterate through all nodes, so I can print them out for

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.