用汇编语言编写程序,建立一数据表,表中存放1-9的平方,查表求某数字的平方。
答案:1 悬赏:70 手机版
解决时间 2021-04-07 18:42
- 提问者网友:临风不自傲
- 2021-04-07 05:48
用汇编语言编写程序,建立一数据表,表中存放1-9的平方,查表求某数字的平方。
最佳答案
- 五星知识达人网友:梦中风几里
- 2021-04-07 06:20
程序如下:
;--------------------------------------------------------------------
DATA SEGMENT
; 数据表格.
TABLE DW 0, 1, 4, 9, 16, 25, 36, 49, 64, 81
DATA ENDS
;--------------------------
STACK SEGMENT
DW 128 DUP(0)
STACK ENDS
;--------------------------
CODE SEGMENT
ASSUME CS: CODE, DS: DATA, SS: STACK
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX
M_LOOP:
MOV AH, 1
INT 21H
CMP AL, 1BH
JZ EXIT
CMP AL, 30H
JL M_LOOP
CMP AL, 39H
JG M_LOOP
SUB AL, 30H
;------------------------------
MOV BX, TABLE
PUSH CX
SHL AL, 1
MOV AH, AL
INC AH
XLAT
MOV CL, AL
MOV AL, AH
XLAT
MOV CH, AL
MOV AX, CX
POP CX
;------------------------------
CALL CR_LF
CALL OUT_AX
CALL CR_LF
JMP M_LOOP
;------------------------------
EXIT:
MOV AX, 4C00H ;EXIT TO OPERATING SYSTEM.
INT 21H
;--------------------------------------------
OUT_AX PROC NEAR
PUSH BX
MOV DL, 0
CALL OUT_ASC
MOV BL, 100
DIV BL
MOV DL, AL
CALL OUT_ASC
MOV AL, AH
XOR AH, AH
MOV BL, 10
DIV BL
MOV DL, AL
CALL OUT_ASC
MOV DL, AH
CALL OUT_ASC
POP BX
RET
OUT_AX ENDP
;--------------------------------------------
OUT_ASC PROC NEAR
ADD DL, 30H
CALL OUT_DL
RET
OUT_ASC ENDP
;--------------------------------------------
CR_LF PROC NEAR
MOV DL, 10
CALL OUT_DL
MOV DL, 13
CALL OUT_DL
RET
CR_LF ENDP
;--------------------------------------------
OUT_DL PROC NEAR
PUSH AX
MOV AH, 02H
INT 21H
POP AX
RET
OUT_DL ENDP
;--------------------------------------------
CODE ENDS
END START
------------------------------------------------------------------
;--------------------------------------------------------------------
DATA SEGMENT
; 数据表格.
TABLE DW 0, 1, 4, 9, 16, 25, 36, 49, 64, 81
DATA ENDS
;--------------------------
STACK SEGMENT
DW 128 DUP(0)
STACK ENDS
;--------------------------
CODE SEGMENT
ASSUME CS: CODE, DS: DATA, SS: STACK
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX
M_LOOP:
MOV AH, 1
INT 21H
CMP AL, 1BH
JZ EXIT
CMP AL, 30H
JL M_LOOP
CMP AL, 39H
JG M_LOOP
SUB AL, 30H
;------------------------------
MOV BX, TABLE
PUSH CX
SHL AL, 1
MOV AH, AL
INC AH
XLAT
MOV CL, AL
MOV AL, AH
XLAT
MOV CH, AL
MOV AX, CX
POP CX
;------------------------------
CALL CR_LF
CALL OUT_AX
CALL CR_LF
JMP M_LOOP
;------------------------------
EXIT:
MOV AX, 4C00H ;EXIT TO OPERATING SYSTEM.
INT 21H
;--------------------------------------------
OUT_AX PROC NEAR
PUSH BX
MOV DL, 0
CALL OUT_ASC
MOV BL, 100
DIV BL
MOV DL, AL
CALL OUT_ASC
MOV AL, AH
XOR AH, AH
MOV BL, 10
DIV BL
MOV DL, AL
CALL OUT_ASC
MOV DL, AH
CALL OUT_ASC
POP BX
RET
OUT_AX ENDP
;--------------------------------------------
OUT_ASC PROC NEAR
ADD DL, 30H
CALL OUT_DL
RET
OUT_ASC ENDP
;--------------------------------------------
CR_LF PROC NEAR
MOV DL, 10
CALL OUT_DL
MOV DL, 13
CALL OUT_DL
RET
CR_LF ENDP
;--------------------------------------------
OUT_DL PROC NEAR
PUSH AX
MOV AH, 02H
INT 21H
POP AX
RET
OUT_DL ENDP
;--------------------------------------------
CODE ENDS
END START
------------------------------------------------------------------
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯