ne0n82
November 2nd, 2008, 05:21 PM
Hello, im trying to read a line of text using the DOS interupt 21h, function code 0Ah and im having tons of problems, my level of assembly knowledge is limited im taking a beginner course on it in college at the moment.
i would be very grateful if someone could post a full example (including) creating the inital buffer and then filling the buffer, ill post the code im having trouble with now
BTW: this code is old because the book we are using is an old book so we are using MASM 615.
;***********************************
;* File: readline.asm
;* Author: James Martinez
;***********************************
include c:\masm615\programs\pcmac.inc
.model small
.386
.stack 500h
.data
;; Defines
cr equ 13
lf equ 10
;; Global Data
string DB 256 DUP(?) ;; This is my buffer to read into (i dont know if this is the right way to declare a buffer)
requestText DB 'Enter a line of text: ', '$'
newline DB cr, lf, '$'
.code
_start proc
_Begin
_PutStr requestText
;; from what i read about the dos call the first element in the buffer has to be the size of the string to read in
mov [string], 250
;; my attempt at using the dos call but it doesnt work
mov ax, @data
mov ds, ax
mov dx, OFFSET string
mov ah, 0Ah
int 21h
;; Try to just echo back what the user inputs
_PutStr string
_Exit 0
_start endp
end _start
again if you could please show me how to get this working it would be a lifesaver, THANKS! =)
i would be very grateful if someone could post a full example (including) creating the inital buffer and then filling the buffer, ill post the code im having trouble with now
BTW: this code is old because the book we are using is an old book so we are using MASM 615.
;***********************************
;* File: readline.asm
;* Author: James Martinez
;***********************************
include c:\masm615\programs\pcmac.inc
.model small
.386
.stack 500h
.data
;; Defines
cr equ 13
lf equ 10
;; Global Data
string DB 256 DUP(?) ;; This is my buffer to read into (i dont know if this is the right way to declare a buffer)
requestText DB 'Enter a line of text: ', '$'
newline DB cr, lf, '$'
.code
_start proc
_Begin
_PutStr requestText
;; from what i read about the dos call the first element in the buffer has to be the size of the string to read in
mov [string], 250
;; my attempt at using the dos call but it doesnt work
mov ax, @data
mov ds, ax
mov dx, OFFSET string
mov ah, 0Ah
int 21h
;; Try to just echo back what the user inputs
_PutStr string
_Exit 0
_start endp
end _start
again if you could please show me how to get this working it would be a lifesaver, THANKS! =)