用汇编语言输出一个矩阵(随便一个矩阵)

如题 请给出编译通过的完整程序 谢谢
2024-12-21 18:57:50
推荐回答(2个)
回答1:

好地,我来。假设要输出一个3*3的矩阵,用一个二重循环,内层循环打印出字符、空格,修改指针SI;外重循环打印出回车,初始化内重循环。代码如下(已编译)
data segment
data1 db 1,2,3,4,5,6,7,8,9
data ends

code segment
assume ds:data,cs:code
start: mov ax,data
mov ds,ax
mov ax,0
lea si,data1
mov ch,3
loop1: mov cl,3
loop2: mov dl,[si]

add dl,30h
mov ah,2
int 21h

mov dl,20h
mov ah,2
int 21h

inc si
dec cl
jnz loop2

mov dl,0dh
mov ah,2
int 21h

dec ch
jnz loop1

mov ah,4ch
int 21h

code ends
end start

回答2:

CSEG SEGMENT
ASSUME CS:CSEG
START: MOV CX,10
CALL NEWLINE
NEXT2: PUSH CX
MOV CX,10
NEXT1: CALL SHOW
LOOP NEXT1
CALL NEWLINE
POP CX
LOOP NEXT2
MOV AH,4CH
INT 21H
SHOW PROC
PUSH AX
PUSH DX
MOV DL,'*'
MOV AH,2H
INT 21H
MOV DL,' '
MOV AH,2H
INT 21H
POP DX
POP AX
RET
SHOW ENDP
NEWLINE PROC
PUSH AX
PUSH DX
MOV DL,0DH
MOV AH,2H
INT 21H
MOV DL,0AH
MOV AH,2H
INT 21H
POP DX
POP AX
RET
NEWLINE ENDP
CSEG ENDS
END START