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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:24:09+00:00 2026-06-03T01:24:09+00:00

I am writing the code for the following program, Objective: Count the number of

  • 0

I am writing the code for the following program,

Objective:

Count the number of spaces pressed by the user. Break if enter is pressed.

Code:

.MODEL SMALL
.STACK 100H
.DATA
    TEXT DB "Enter Character"
.CODE
    MOV AX,9
    MOV DX,TEXT
    INT 21H
    BACK:
        INT21H
        CMP AL, " "
        JE INCREMENT
        CMP AL, "\n"
        JE OUT
        JMP BACK
INCREMENT:
        INC ; which register do I use here? I feel that I am out of registers
        LOOP BACK
OUT:
;display the count

In the above code, I have marked the area where I am feeling that I don’t have anymore registers left to use. I have to use AX,AL,DX,DL registers in the code. Which other register can I use to store the count? Please help, thanks.

  • 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-03T01:24:10+00:00Added an answer on June 3, 2026 at 1:24 am

    You have the following general-purpose registers that you can use:

    AX (AH is 8 most significant bits of AX, AL is 8 least significant bits of AX)
    BX (BH is 8 MSBs of BX, BLis 8 LSBs of BX)
    CX (CH is 8 MSBs of CX, CL is 8 LSBs of CX)
    DX (DH is 8 MSBs of DX, DL is 8 LSBs of DX)
    BP (individual halves aren’t accessible directly)
    SI (individual halves aren’t accessible directly)
    DI (individual halves aren’t accessible directly)

    Btw, you have to set AH to 1 before int 21H that reads a character into AL from the keyboard.

    And your text string must end with a dollar sign if you want to print it using int 21H function 9.

    Also, Enter’s code is 13 (‘\r’), not 10 (‘\n’).

    A few more issues:

    • Your stack is too small for interrupts. Bump it up to 4 KB. If you don’t, they’ll overwrite some code or data in your program or in some other place. You don’t want that.
    • Since this is an .EXE program (and not .COM) you must set DS to point to the data segment. See your book or notes or assembler documentation on how to do that. ES should probably be set to the same value.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got tired of writing the following code: /* Commenting out irrelevant parts public
I am writing code to performance test a web site. I have the following
I'm writing an XML file with the following code: Source source = new DOMSource(rootElement);
Mono won't fire the following code: I get internal server error 500, error writing
How I'm stuck with writing a test for the following code. I want to
does any one know if, for example, I'm writing in c++ the following code:
I have the following section of code in an app that I am writing:
I've been writing Java swing GUI code for several years but the following syntax
I am writing the following code on boost's program_options (version 1.42). This seems straight-forward
How can I break long lines when writing c++ code in vim? For example,

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.