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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:11:18+00:00 2026-05-23T21:11:18+00:00

Please, does anybody know how to code string input in assembly language? I’m using

  • 0

Please, does anybody know how to code string input in assembly language? I’m using int 21 to display and input characters.

  • 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-23T21:11:18+00:00Added an answer on May 23, 2026 at 9:11 pm

    You can use function 0Ah to read buffered input. Given a string buffer in ds:dx it reads a string of up to length 255. The buffer layout is:

    Byte 0 String length (0-255)
    Byte 1 Bytes read (0-255, filled by DOS on return)
    Bytes 2-..Length+2 (The character string including newline as read by DOS).
    

    An example of a small COM file that reads a string and then echos it back to the user:

        org 0x100
    
    start:
        push cs
        pop ds ; COM file, ds = cs
    
        mov ah, 0x0A ; Function 0Ah Buffered input
        mov dx, string_buf ; ds:dx points to string buffer
        int 0x21
    
        movzx si, byte [string_buf+1] ; get number of chars read
    
        mov dx, string_buf + 2 ; start of actual string
    
        add si, dx ; si points to string + number of chars read
        mov byte [si], '$' ; Terminate string
    
        mov ah, 0x09 ; Function 09h Print character string
        int 0x21 ; ds:dx points to string
    
        ; Exit
        mov ax, 0x4c00
        int 0x21
    
    string_buf: 
        db 255 ; size of buffer in characters
        db 0 ; filled by DOS with actual size
        times 255 db 0 ; actual string
    

    Note that it will overwrite the input line (and it thus might not look the program is doing anything!)

    Alternatively you can use function 01h and read the characters yourself in a loop. Something like this (note it will overflow later buffers if more than 255 characters are entered):

        org 0x100
    
    start:
        push cs
        pop ax
        mov ds, ax
        mov es, ax; make sure ds = es = cs
    
        mov di, string ; es:di points to string
        cld ; clear direction flag (so stosb incremements rather than decrements)
    read_loop:
        mov ah, 0x01 ; Function 01h Read character from stdin with echo
        int 0x21
        cmp al, 0x0D ; character is carriage return?
        je read_done ; yes? exit the loop
        stosb ; store the character at es:di and increment di
        jmp read_loop ; loop again
    read_done:
        mov al, '$'
        stosb ; 'Make sure the string is '$' terminated
    
        mov dx, string ; ds:dx points to string
        mov ah, 0x09 ; Function 09h Print character string
        int 0x21
    
        ; Exit
        mov ax, 0x4c00
        int 0x21
    
    string: 
        times 255 db 0 ; reserve room for 255 characters
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does GWT has LazyPanel .I can not see it .Please let me know .If
What does it mean by logical grouping of modules in assembly? Can anyone please
Does anybody know how to setup the starting form of a winforms project in
Can someone please explain what the & does in the following: class TEST {
On IIS 6, what does an IIS reset do? Please compare to recycling an
Pretty simple task, but the source code doesn't do required job... Please advise. There
please help me solve this issue. I have a client using WCF. I don't
I want to draw a square in Assembly language. I have ridden something about
Please suggest some good resources to start writing Java Web services.
Please read the whole question. I'm not looking for an approach to managing multi-lingual

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.