ورود

View Full Version : خبر: ضرب جز به جز



mehdi_khepel2004
یک شنبه 15 آذر 1388, 21:21 عصر
با سلام
برنامه ضرب جز به جز رو با برداشتی که داشتم نوشتم نمیدونم درست هست یا نه
لطفا اشکالات این برنامه رو به من بگین تا درستش کنم چون میخوام تحویل استاد بدم

;seyed mohammad mehdi mousave zadeh
.model small
.data
str1 db '0000','$'
str2 db '0000','$'

a1 dw 1234h
a2 dw 4321h

str db ?
db ?
db ?
db ?

t1 dw ?
total1 dw ?
dw ?
total2 dw ?
dw ?
total3 dw ?
dw ?
total4 dw ?
dw ?
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax

lea si,a2
lea di,a1
mov dx,[si]
mov bx,[di]

mov al,dl
mul bl
;mov total,ax
mov t1,ax

mov al,dl
mul bh

mov cx,100h
mul cx
mov total2,ax
mov [total2+2],dx
mov cx,t1
add total2,cx

mov cx,100h
mov dx,[si]
mov al,dh
mul cx
mov t1,ax
xor bh,bh
mul bx
mov total3,ax
mov [total3+2],dx

mov cx,100h
mov dx,[si]
mov al,dh
mul cx
;----------------5600
mov total1,ax

mov bx,[di]
mov al,bh
mul cx
;----------------1200
mov [total1+2],ax

;tota1=12005600
;1200*5600
mov ax,total1
mov bx,[total1+2]
mul bx
mov total1,ax
mov [total1+2],dx

;-------------sum total1,total3 in total4
mov ax,total1
mov bx,total3
clc
add ax,bx
mov total4,ax
mov ax,[total1+2]
mov bx,[total3+2]
adc ax,bx
mov [total4+2],ax
;--------------sum total4,total2
clc

mov ax,total2
mov bx,total4
add ax,bx
mov total3,ax
mov ax,[total2+2]
mov bx,[total4+2]
adc ax,bx
mov [total3+2],ax
;------------------ end sum with ok test
mov ax,total3
mov bx,[total3+2]

mov a1,ax
mov a2,bx

; convert number to char for print

;convert low bit 0..15
mov ax,a1
xor ah,ah
mov dx,ax
mov bl,10h
div bl
;convert ah to str
add ah,48
;check for grat than 9 if >9 then replace with A..F
mov bh,ah
xor bh,00110000b
cmp bh,9
jG p0
jmp ex0
p0:
mov ah,bh
sub ah,10
add ah,65
ex0:
;----------------
mov str,ah
;convert al to str
add al,48
;check for grat than 9 if >9 then replace with A..F
mov bh,AL
xor bh,00110000b
cmp bh,9
jG p1
jmp ex1
p1:
mov aL,bh
sub aL,10
add aL,65
ex1:
;----------------
mov [str+1],al
mov ax,a1
xor al,al
xchg ah,al
div bl
add ah,48
;check for grat than 9 if >9 then replace with A..F
mov bh,ah
xor bh,00110000b
cmp bh,9
jG p2
jmp ex2
p2:
mov ah,bh
sub ah,10
add ah,65
ex2:
;----------------
mov [str+2],ah
;convert al to str
add al,48
;check for grat than 9 if >9 then replace with A..F
mov bh,aL
xor bh,00110000b
cmp bh,9
jG p3
jmp ex3
p3:
mov aL,bh
sub aL,10
add aL,65
ex3:
;----------------
mov [str+3],al
lea di,str2+3
mov dh,str
mov [di],dh
dec di
mov dh,[str+1]
mov [di],dh
dec di
mov dh,[str+2]
mov [di],dh
dec di
mov dh,[str+3]
mov [di],dh

;convert high bit 16..31
mov ax,a2
xor ah,ah
mov dx,ax
mov bl,10h
div bl
;convert ah to str
add ah,48
;check for grat than 9 if >9 then replace with A..F
mov bh,ah
xor bh,00110000b
cmp bh,9
jG p4
jmp ex4
p4:
mov ah,bh
sub ah,10
add ah,65
ex4:
;----------------
mov str,ah
;convert al to str
add al,48
;check for grat than 9 if >9 then replace with A..F
mov bh,aL
xor bh,00110000b
cmp bh,9
jG p5
jmp ex5
p5:
mov aL,bh
sub aL,10
add aL,65
ex5:
;----------------
mov [str+1],al
mov ax,a2
xor al,al
xchg ah,al
div bl
add ah,48
;check for grat than 9 if >9 then replace with A..F
mov bh,ah
xor bh,00110000b
cmp bh,9
jG p6
jmp ex6
p6:
mov ah,bh
sub ah,10
add ah,65
ex6:
;----------------
mov [str+2],ah
;convert al to str
add al,48
;check for grat than 9 if >9 then replace with A..F
mov bh,aL
xor bh,00110000b
cmp bh,9
jG p7
jmp ex7
p7:
mov aL,bh
sub aL,10
add aL,65
ex7:
;----------------
mov [str+3],al
lea di,str1+3
mov dh,str
mov [di],dh
dec di
mov dh,[str+1]
mov [di],dh
dec di
mov dh,[str+2]
mov [di],dh
dec di
mov dh,[str+3]
mov [di],dh

lea dx,str1
mov ah,09h
int 21h

lea dx,str2
mov ah,09h
int 21h

mov ah,4ch
int 21h
ret
main endp

ret