1
所以我有這個計劃:爲什麼nasm告訴我我無法將AL移動到INPUT?
[BITS 16]
[ORG 7C00h]
JMP 0:start
start:
MOV AX, 0
MOV DS, AX
MOV ES, AX
MOV SS, AX
MOV SP, 7C00h
MOV SI, Hello
CALL _puts16
MOV AL, LogLvl1
INT 21h
CALL .getinput
.getinput:
MOV AH, 2h
MOV AL, Success ;Echo was successful
INT 21h
MOV AH, 1h ;Set AH to 1h, which means character input
INT 21h
MOV INPUT, AL ;Store the character in INPUT
MOV AH, 2h ;Change AH back to 2h, which means character output
MOV DL, Message ;Move Message to DL, which will be echoed
INT 21h
MOV DL, INPUT ;Move the inputed key to DL to be echoed
INT 21h
RET
;input= es:si -> string
_puts16:
PUSHA
.BEGIN:
LODSB ;Load a single byte
CMP AL, 0 ;Calculate if that byte is 0, or null
JE .END ;Jump to end if it is not 0
MOV AH, 0Eh ;Otherwise, set 24 bit graphics modes
INT 10h
JMP .BEGIN
.END:
POPA
RET
.define:
Hello DB "Enter a string: ",0
Message DB " Grats! You said",0
INPUT DB " ",0
LogLvl1 DB "Calling .getinput...\n",0
Success DB "Successful.\n",0
times 510 - ($ - $$) db 0
DW 0xAA55
我很新的裝配,而我需要移動被輸入到作爲定義.DEFINE字符串varriable「INPUT」鍵,但網際彙編給我錯誤:
1.asm:24: error: invalid comination of opcode and operands
我想這意味着由於某種原因我不能移動到輸入,但我不知道爲什麼。正如我所說,我是裝配新手,所以這可能是一個明顯的錯誤。我怎樣才能解決這個問題?我需要將鍵入的字符或鍵存儲在內存中,以便稍後在程序中回顯。
哇,謝謝!它非常完美! –