用汇编怎么写下面这个题目
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/16 23:26:02
用汇编怎么写下面这个题目
要求:检查9*9 乘法表内数据是否正确,将不正确位置确定下来并显示在屏幕上;
如数据部分:
data segment
table db 7,2,3,4,5,6,7,8,9 ;9*9表数据
db 2,4,7,8,10,12,14,16,18
db 3,6,9,12,15,18,21,24,27
db 4,8,12,16,7,24,28,32,36
db 5,10,15,20,25,30,35,40,45
db 6,12,18,24,30,7,42,48,54
db 7,14,21,28,35,42,49,56,63
db 8,16,24,32,40,48,56,7,72
db 9,18,27,36,45,54,63,72,81
……
data ends
要求:检查9*9 乘法表内数据是否正确,将不正确位置确定下来并显示在屏幕上;
如数据部分:
data segment
table db 7,2,3,4,5,6,7,8,9 ;9*9表数据
db 2,4,7,8,10,12,14,16,18
db 3,6,9,12,15,18,21,24,27
db 4,8,12,16,7,24,28,32,36
db 5,10,15,20,25,30,35,40,45
db 6,12,18,24,30,7,42,48,54
db 7,14,21,28,35,42,49,56,63
db 8,16,24,32,40,48,56,7,72
db 9,18,27,36,45,54,63,72,81
……
data ends
;运行正确.
Tips macro m ;显示一字符串
mov dx,offset m
mov ah,9
int 21h
endm
data segment
table db 7,2,3,4,5,6,7,8,9 ;9*9表数据
db 2,4,7,8,10,12,14,16,18
db 3,6,9,12,15,18,21,24,27
db 4,8,12,16,7,24,28,32,36
db 5,10,15,20,25,30,35,40,45
db 6,12,18,24,30,7,42,48,54
db 7,14,21,28,35,42,49,56,63
db 8,16,24,32,40,48,56,7,72
db 9,18,27,36,45,54,63,72,81
message db 'x y',13,10,'$'
buffer db 0,' ',0,' error',0dh,0ah,'$'
string db 'Press any key to quit ...$'
data ends
CODE SEGMENT ;代码段
ASSUME CS:CODE,DS:data
START: MOV AX,DATA ;初始化
MOV DS,AX
;请在这里添加您的代码
Tips message
mov di,offset table
mov dx,101h
mov bp,9
again:
mov cx,9
next:
mov al,dl
mul dh
cmp al,[di]
jz yes
call show
yes:inc di
inc dl
loop next
inc dh
mov dl,1
dec bp
jnz again
Tips string
mov ah,7
int 21h
MOV AH,4CH ;退出程序
INT 21H
show:push dx
mov si,offset buffer
mov ax,dx
or ax,3030h
mov [si],ah
mov [si+2],al
Tips buffer
pop dx
ret
CODE ENDS
END START
Tips macro m ;显示一字符串
mov dx,offset m
mov ah,9
int 21h
endm
data segment
table db 7,2,3,4,5,6,7,8,9 ;9*9表数据
db 2,4,7,8,10,12,14,16,18
db 3,6,9,12,15,18,21,24,27
db 4,8,12,16,7,24,28,32,36
db 5,10,15,20,25,30,35,40,45
db 6,12,18,24,30,7,42,48,54
db 7,14,21,28,35,42,49,56,63
db 8,16,24,32,40,48,56,7,72
db 9,18,27,36,45,54,63,72,81
message db 'x y',13,10,'$'
buffer db 0,' ',0,' error',0dh,0ah,'$'
string db 'Press any key to quit ...$'
data ends
CODE SEGMENT ;代码段
ASSUME CS:CODE,DS:data
START: MOV AX,DATA ;初始化
MOV DS,AX
;请在这里添加您的代码
Tips message
mov di,offset table
mov dx,101h
mov bp,9
again:
mov cx,9
next:
mov al,dl
mul dh
cmp al,[di]
jz yes
call show
yes:inc di
inc dl
loop next
inc dh
mov dl,1
dec bp
jnz again
Tips string
mov ah,7
int 21h
MOV AH,4CH ;退出程序
INT 21H
show:push dx
mov si,offset buffer
mov ax,dx
or ax,3030h
mov [si],ah
mov [si+2],al
Tips buffer
pop dx
ret
CODE ENDS
END START