Code assembly tổng 2 số
kiểu word
(kỹ thuật vi xử lý)
.model tiny
.stack 100h
.data
tb1 db 'Nhap so thu nhat : $'
tb2 db 13,10,'Nhap so thu hai : $'
tb3 db 13,10,'Tong 2 so la : $'
so1 dw 0
so2 dw 0
.code
main proc
mov ax,@data
mov ds,ax
lea dx,tb1
mov ah,9
int 21h
;nhap so
thu nhat
nhapso1:
mov ah,1
int 21h
cmp al,13
je hientb2
mov cl,al
mov ch,0
sub cl,30h
mov ax,so1
mov bx,10
mul bx
add ax,cx
mov so1,ax
jmp nhapso1
hientb2:
lea dx,tb2
mov ah,9
int 21h
;nhap so
thu 2
nhapso2:
mov ah,1
int 21h
cmp al,13
je hientb3
mov cl,al
mov ch,0
sub cl,30h
mov ax,so2
mov bx,10
mul bx
add ax,cx
mov so2,ax
jmp nhapso2
;==TONG 2
SO ==
hientb3:
lea dx,tb3
mov ah,9
int 21h
;gan so
thu nhat vao ax
mov ax,so1
;cong ax
voi so thu 2
add ax,so2
;khoi tao
de thuc hien chia
mov cx,0
mov bx,10
mov dx,0
;chia de
hien thi ket qua
chiatong:
div bx
push dx
inc cx
cmp ax,0
je hientong
mov dx,0
jmp chiatong
;hien ket
qua ra man hinh
hientong:
pop dx
add dl,30h
mov ah,2
int 21h
loop hientong
thoat:
mov ah,76
int 21h
main endp
end main
tag: tong hai so kieu word, tổng hai số kiểu word, assembly, kỹ thuật vi
xử lý
HÃY QUÁ B À
ReplyDelete