Code assembly hiệu 2 số kiểu word (kỹ thuật vi xử lý)

Code assembly Hiệu 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,'Hieu 2 so la : $'
    so1 dw 0
    so2 dw 0
.code
    main proc
        mov ax,@data
        mov ds,ax
       
        ;hien thong bao va nhap so thu 1
        lea dx,tb1
        mov ah,9
        int 21h
       
        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 
        ;hien thong bao va nhap so thu 2
        hientb2:
            lea dx,tb2
            mov ah,9
            int 21h
        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
         hientb3:
         ;==HIEU 2 SO ==
         lea dx,tb3
         mov ah,9
         int 21h
         ;gan so 1 vao ax
         mov ax,so1
         ;tru so1 - so2
         sub ax,so2
         ;khoi tao de chia =>hien thi ket qua
         mov dx,0
         mov cx,0
         mov bx,10
         chiatru:
            div bx
            push dx
            inc cx
            cmp ax,0
            je hientru
            mov dx,0
            jmp chiatru
         hientru:
            pop dx
            add dl,30h
            mov ah,2
            int 21h
            loop hientru
        
         ;thoat khoi chuong trinh      
         thoat:
            mov ah,76
            int 21h
         main endp
    end main


tag: hieu hai so kieu wordhieu hai số kiểu word, assembly, kỹ thuật vi xử lý 
Share on Google Plus

About dungnv

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment