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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:40:57+00:00 2026-05-27T18:40:57+00:00

I have this piece of assembly code to accept a string and display the

  • 0

I have this piece of assembly code to accept a string and display the string back.

My problem is I’m not able to figure out how exactly the name is getting stored in name1 as we are using buff to store the input from the user.

I know that

buff label byte
maxchar db 50
readchar db 0
name1 db 48 dup(0)

is got something to do with this. But I’m not able to understand the working.

.model small
.stack
.data
    buff label byte
    maxchar db 50
    readchar db 0
    name1 db 48 dup(0)
    m1 db 10,13,"enter name: $"
    m2 db 10,13,"your name is: $"
.code
    mov ax, @data
    mov ds, ax
    lea dx, m1
    mov ah, 09
    int 21h
    lea dx, buff
    mov ah, 10
    int 21h


    mov ah,0
    mov al, readchar
    add ax, 2
    mov si, al
    mov buff[si],24H ;ascii code for $ to terminate string
    lea dx, m2
    mov ah, 9
    int 21h
    lea dx, name1
    mov ah, 09
    int 21h

    mov ah, 4ch
    int 21h
end

please help!

thank you.

  • 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-27T18:40:57+00:00Added an answer on May 27, 2026 at 6:40 pm

    The input is read using DOS function 0x0a (or decimal 10 in your code) which performs buffered input. The DS:DX parameter points to a buffer that has the following format, which is at the location labeled buff (or equivalently maxchar) in your program:

     offset    meaning
     ------  -------------
        0      Number of bytes available for the input data (starting at offset 2)
        1      A location for DOS to put the number of characters read into the buffer
        2      A buffer of bytes that can hold the number of characters specified in 
               offset 0
    

    So in your code, DS:DX points to buff which indicates that up to 50 characters can be put into the buffer at name1. It looks like the code has a potential problem since there are only 48 bytes in the buffer, but the data structure indicates that there are 50 bytes. So it’s possible that the input will overwrite the first two bytes of m1. Now, assembly programs – especially old ones – are known for performing all sorts of tricks to save space. m1 isn’t used after the call to DOS function 0x0a, so this might have been intentional (but if so, I’m not sure why more of m1 wasn’t made available). I’d guess that it’s unintentional, and the bug just never manifested into anything noticeable.

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

Sidebar

Related Questions

I have this piece of code #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h>
I have this piece of code I'm trying to get to display but no
I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
I have this piece of code (summarized)... AnsiString working(AnsiString format,...) { va_list argptr; AnsiString
I have this piece of code: $(#faq).click(function () { var url = $.get(faq, {
I have this piece of code: var myObj = function () { this.complex =
I have this piece of code that works fine in subsonic 2.2, I migrated
I have this piece of code in C++: ihi = y[0]>y[1] ? (inhi=1,0) :
I have this piece of code: <li class=selected><a href=/AmIACandidate.html>Am I a Candidate?</a></li> I need
I have this piece of code to test a shellcode but I don't understand

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.