I am trying to create a program that greets the user with their name. The user enters their name after a prompt and the they are greeted along with their name. I have already tried using this code but it fails and throws error on line 21.
The error message states: (21) wrong parameters: LEA Dx,name (21) probably no zero prefix for hex; or no 'h' suffix; or wrong addressing; or undefined var: name
Here's the code
.MODEL SMALL
.STACK 100
.DATA
msg db "Hello! Please enter your name:$"
newline db 13,10,'$'
greeting db "Wellcome!$"
name db 80, 0, 78 DUP('$')
.CODE
main PROC
; Prompt
MOV Ax,@DATA
MOV Ds,Ax
LEA Dx,msg
MOV Ah,09h
INT 21h
; Input
LEA Dx,name (throws error)
MOV AH,0AH
INT 21h
; Check if ENTER is pressed
CMP Al,13
JE Display
; Newline
LEA Dx,newline
MOV Ah,09h
INT 21h
; Print Greeting
Display: MOV AH,09h
LEA Dx,name+2
;MOV Dl,Al
INT 21H
Exit:
MOV Ah,4Ch
INT 21h
main ENDP
END main
it fails is not a useful description. When you want to use Int 21/AH=0Ah buffered input , the first buffer byte has to be initialized with its size, for instance name db 80, 0, 78 DUP('$')
Also remove the instruction MOV Dl,Al
which damages DX in ; Print Greeting
; Print Greeting
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.