Click here to Skip to main content
15,886,031 members

Assembly program to get string from user

AshakiranBhatter asked:

Open original thread
Hi,
I am trying to learn ASM programming on MS-DOS to get a string from User.
But during the run-time it reboots the OS automatically or hangs or misbehaves while the same program is executed on Windows-XP it does not give any run-time errors.

Could you please help me in this regards as to where am I going wrong.

Below is the environment:
Assembler: Tasm
OS: MS-DOS71, XP

ASM
.Model Small
.Stack 100H .Data
    CR Equ 0DH
    LF Equ 0AH
    NL Equ 00H
    MsgX db 32H Dup (NL)
.Code
Run:
    MOV AX, @Data
    MOV DS, AX
    MOV AX, Offset MsgX
    CALL GetStr
    CALL Exit

    GetChr:
        PUSH BX
        PUSH CX
        PUSH DX
        MOV AH, 01H
        INT 21H
        POP  DX
        POP  CX
        POP  BX
    RET

    GetStr:
        PUSH AX
        PUSH BX
        PUSH CX
        PUSH DX
        MOV BX, AX
        GetStrLoop:
            CALL GetChr
            MOV Byte Ptr [BX], AL
            CMP Byte Ptr [BX], CR
            JE GetStrFree
            INC BX
            JMP GetStrLoop
        GetStrFree:
            MOV Byte Ptr [BX], NL
            POP DX
            POP CX
            POP BX
            POP AX
    RET

    Exit:
        MOV AH, 4CH
        INT 21H
End Run
Tags: ASM

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900