嘿,我已经开始学习assembly language
了。
我写了以下代码:
.MODEL SMALL
.STACK 1000H
.DATA
MSG db "Hey$"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AH,0AH ; setting the sub function
MOV DX, offset msg ; moving address of msg to dx
INT 21h ; calling interrupt
MOV AH, 09
MOV DX, OFFSET MSG
INT 21h ; for printing
MOV AH, 04Ch ; Select exit function
MOV AL, 00 ; Return 0
INT 21h ; Call Interupt to Terminate program
MAIN ENDP
END MAIN
我正在尝试接受输入,它有点工作但是当我尝试打印它时,我没有得到正确的字符串。我用这个list来选择中断函数。
我附上截图,我输入了以下字符串:
Hey this is me taking input
但是我得到了意想不到的结果。
截图:
感谢。
答案 0 :(得分:0)
你没有为你的输入字符串留出足够的空间;当你宣布" MSG
,您只为4个字符("Hey$"
)提供了空间。
答案 1 :(得分:0)
http://www.skynet.ie/~darkstar/assembler/intlist.html
注意:使用" db Size dup(0)"我们可以占用Size size of bytes的值。
.MODEL SMALL
.STACK 10H
Size = 3
.DATA
M1 db Size ; First character=max length
M2 db ? ; Second char of buffer=length of input
MSG db Size dup (20H) ; Rest of buffer=input string
db 0DH ; followed by carriage return (0Dh)
;---
db "$" ; (allways needed for printing function)
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AH,0AH ; setting the sub function
MOV DX, offset M1 ; moving address of input buffer
INT 21h ; calling interrupt
MOV AH, 09
MOV DX, OFFSET MSG
INT 21h ; for printing
MOV AH, 04CH ; Select exit function
MOV AL, 00 ; Return 0
INT 21h ; Call Interupt to Terminate program
MAIN ENDP
END MAIN