㈠ 匯編語言怎麼從鍵盤輸入一個十進制的兩位數,並把它存到數組裡面
以下是輸入岩襲數組的子程序(注意其數據定義與代碼段同段)
;===================================================
; 鍵盤輸入數值數組子程序(數粗族兄組名為@array,元素個數存放在@num中)
; 可以是負數
INPUTNUM PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSHF
; 對數組@array清零
MOV CX,100
MOV AX,0
LEA DI,@ARRAY
REP STOSW
MOV WORD PTR @NUM,0
; 輸入的數據以穗團一個空格分隔,以回車符結束輸入
LEA DX,@STRA
MOV AH,10
INT 21H
MOV CL,@STRN
MOV CH,0
MOV WORD PTR @STRM,CX
LEA SI,@STR
CLD
LEA DI,@ARRAY
MOV WORD PTR @NUM,0
@STIN:
MOV AX,0
PUSH AX
MOV BYTE PTR @SIGNN,0
@AGAIN1:
CMP WORD PTR @STRM,0
JE @LINE0
LODSB
DEC WORD PTR @STRM
CMP AL,' '
JE @LINE0
CMP AL,'-'
JNE @INPUT1
MOV BYTE PTR @SIGNN,1
JMP @AGAIN1
@INPUT1:
SUB AL,30H
MOV AH,0
MOV BX,AX
POP AX
MOV CL,10
MOV CH,0
MUL CX
ADD AX,BX
PUSH AX
JMP @AGAIN1
@LINE0:
POP AX
CMP BYTE PTR @SIGNN,1
JNE @INPUT2
NEG AX
@INPUT2:
MOV WORD PTR[DI],AX
INC WORD PTR @NUM
CMP WORD PTR @STRM,0
JE @STINEND
INC DI
INC DI
JMP @STIN
@STINEND:
POPF
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
RET
@STRA DB 255
@STRN DB ?
@STR DB 255 DUP(?)
@STRM DW 0
@ARRAY DW 100 DUP(0)
@NUM DW 0
@CHAR DB ?
@SIGNN DB 0
INPUTNUM ENDP
;=========================================
㈡ 匯編語言怎麼編寫把鍵盤輸入數據存到存儲器或寄存器里
目的數據存儲器單元,備清如果是在單片機內部,
這仿舉前樣就可以:答團MOV
@R0,
A
或送到片外:MOVX
@R0,
A