我的任务是从终端(又名atoi)读取一个数字,然后将其写回终端(又名itoa)。
要读取我使用的字符串int 21h, ah 0ah
。当我在调试器中检查它时看起来不错。然后我的atoi和itoa看起来也不错,只是在itoa中我int 21h, ah 02h
用来显示一个字符,但由于某种原因它没有显示。所以我回到开头,注意到在(read string)int 21h, ah 02h
之后写 (print char)没有结果。int 21h, ah 0ah
; STACK SEGMENT
STSEG SEGMENT PARA STACK "STACK"
DB 64 DUP (0)
STSEG ENDS
; DATA SEGMENT
DSEG SEGMENT PARA PUBLIC "DATA"
startStr db "Enter a number : $"
inputError db "Number has incorrect chars.", 10, "$"
buffError db "Number is too big", 10, "$"
bufferSize DB 16 ; 15 chars + RETURN
inputLength DB 0 ; number of read chars
buffer DB 16 DUP('?') ; actual buffer
DSEG ENDS
; CODE SEGMENT
CSEG SEGMENT PARA PUBLIC "CODE"
MAIN PROC FAR
ASSUME cs: CSEG, ds: DSEG, ss:STSEG
mov ax, DSEG
mov ds, ax
;lea dx, startStr
;call WRITING
;call READING
xor ax, ax
xor dx, dx
mov ah, 2
mov dl, 56
int 21h
;test display char before reading string - works fine
xor dx, dx
xor ax, ax
lea dx, bufferSize
mov ah, 10
int 21h
; reading string - works fine
xor ax, ax
xor dx, dx
mov ah, 2
mov dl, 56
int 21h
; trying to display char again - nothing
; call ATOI
; add ax, 15
; call ITOA
ret
MAIN ENDP
CSEG ENDS
END MAIN
Screenshot
'8' 是我在开始时显示的字符。'123' 是我输入的字符串,然后按回车键。