0
如果有人知道彙編語言,我真的需要一些幫助來調試我的程序。我有一個3x3矩陣和一個3元素矢量,我從控制檯讀取,我需要將它們相乘並顯示結果數組。(emu8086)將3x3矩陣與陣列相乘
這是我到目前爲止的代碼:
name "2x2_matrix"
include "emu8086.inc"
org 100h ; directive make tiny com file.
.model small
.stack 100h
.data
size dw 3
A db ?,?,?,?,?,?,?,?,?
B db ?,?,?
C db ?,?,?
message_a db 10,13,"type the elements of matrix A:$"
message_b db 10,13,"type the elements of array B:$"
rez db 10,13,"the result is:$"
.code
start:
mov ax,@data
mov ds,ax
mov bx, 0 ;
read_a:
;compare with sizexsize
mov ax, size
mul size
cmp bx, ax
je reset_counter
;display message
mov dx, offset message_a
mov ah, 09h
int 21h
;read element
mov ah, 01h
int 21h
sub al, 30h
mov A[bx], al
inc bx
jmp read_a
reset_counter:
mov bx, 0
jmp read_b
read_b:
;compare with size
mov ax, size
cmp bx, ax
je calcul
;display message
mov dx, offset message_b
mov ah, 09h
int 21h
;read element
mov ah, 01h
int 21h
sub al, 30h
mov B[bx], al
inc bx
jmp read_b
calcul:
mov bx,0
mov cx,0
for_i:
mov ax, size
cmp bx, ax
je print
mov al,b.size
mul bx
mov al, A[bx+1]
mov bh, B[bx+1]
mul bh
add C[bx], ah
mov al, b.A[bx+2]
mov bl, b.B[bx+2]
mul al
add C[bx], ah
mov al, b.A[bx+3]
mov bl, b.B[bx+3]
mul al
add C[bx], ah
inc bx
jmp for_i
print:
mov dx, offset rez
mov ah,09h
int 21h
mov ax,size
mul size
mov cx,ax
mov ax,0
mov bx,0
print_c:
cmp bx,cx
je finish
mov al, C[bx]
CALL PRINT_NUM
inc bx
jmp print_c
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS
finish:
ret
end start
end
這似乎循環之後我插入的元素不會顯示任何內容,我不知道如何調試它。如果有人熟悉彙編類型的編碼,並可以幫助我修復我的代碼,我將不勝感激!