0% found this document useful (0 votes)
5 views2 pages

Cong 2 So

The document is an assembly language program that prompts the user to input two single-digit numbers (A and B) and calculates their sum. It converts the ASCII input to numerical values, adds them, and displays the result. The program uses DOS interrupts for input and output operations.

Uploaded by

22a1701d0120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Cong 2 So

The document is an assembly language program that prompts the user to input two single-digit numbers (A and B) and calculates their sum. It converts the ASCII input to numerical values, adds them, and displays the result. The program uses DOS interrupts for input and output operations.

Uploaded by

22a1701d0120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

.

model small
.stack 100
.data
; khai bao bien, chuoi
nhap_a_msg db 13, 10, 'Nhap 0<= A <=9 :$'
nhap_b_msg db 13, 10, 'Nhap 0<= B <=9 :$'
ket_qua_msg db 13, 10, 'A+B = $'
.code
main proc
; khoi tao cho DS
mov ax, @data
mov ds, ax

; in ra thong bao nhap A


lea dx, nhap_a_msg
mov ah, 9
int 21h

; doc 1 ky tu tu ban phim


mov ah, 1
int 21h
; chuyen so dang ASCII sang so
sub al, '0'
mov bl, al ; cat A vao BL

; in ra thong bao nhap B


lea dx, nhap_b_msg
mov ah, 9
int 21h

; doc 1 ky tu tu ban phim


mov ah, 1
int 21h
; chuyen so dang ASCII sang so
sub al, '0'

xu_ly:
add al, bl
mov ah, 0
jmp in_kq

in_kq:
; in ket qua AX ra man hinh
mov bl, 10
mov cx, 0
tiep_tuc_chia:
div bl ; lay ax / bl -> ket qua: al = thuong, ah = du
push ax
inc cx ; <=> add cx, 1
mov ah, 0
cmp al, 0
je xuat
jmp tiep_tuc_chia
xuat:
lea dx, ket_qua_msg
mov ah, 9
int 21h

in_tung_ky_tu:
pop ax
mov dl, ah
add dl, '0'
mov ah, 2
int 21h
;loop in_tung_ky_tu
dec cx
jne in_tung_ky_tu

; tro ve DOS
mov ah, 4ch
int 21h
main endp
end main

You might also like