bai tap
Bai 1
.model small
.stack 100
.data
tb1 db 10,13,10,10,'Hay go vao mot chu cai thuong:$'
tb2 db 10,13,'chu cai hoa tuong ung la:$'
.code
chu proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,tb1
int 21h
mov ah,1
int 21h
mov bl,al
mov ah,9
lea dx,tb2
int 21h
mov ah,2
mov dl,bl
and dl,0dfh
int 21h
mov ah,4ch
int 21h
chu endp
end chu
bai 2
.model small
.stack 100
.data
tb1 db 10,13,' CHUONG TRINH TINH A=B+C'
tb2 db 10,13,' B=$'
tb3 db 10,13,' C=$'
tb4 db 10,13,' A=B+C=$'
a dw ?
b dw ?
c dw ?
.code
vaonp proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,tb1
int 21h
xor bx,bx ; bx chua so vao
mov ah,1
int 21h
lapw1:
cmp al,13 ; kt khac enter?
je ra1
and al,0fh
shl bx,1
or bl,al
int 21h
jmp lapw1
ra1: mov b,bx ; vao xong b
mov ah,9
lea dx,tb3
int 21h
xor bx,bx ; bx chua so vao
mov ah,1
int 21h
lapw2:
cmp al,13 ; kt khac enter?
je ra2
and al,0fh
shl bx,1
or bl,al
int 21h
jmp lapw2
ra2: mov c,bx ; vao xong c
mov bx,b
add bx,c ;bx=b+c
mov a,bx
mov ah,9
lea dx,tb4
int 21h
mov cx,16
mov ah,2
lapf:
xor dl,dl
rol bx,1
adc dl,30h
int 21h
loop lapf
mov ah,4ch
int 21h
vaonp endp
end vaonp
bai 3 .model small
.stack 100h
.data
tb1 db 10,13,' CHUONG TRINH TINH A=B-2A',10,13
db 'Ban hay vao gia tri cho A:$'
tb3 db 10,13,'B:$'
tb2 db 10,13,'A=B-2A=$'
A DB ?
B DB ?
.code
HV proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,tb1
int 21h
mov ah,1
int 21h ; al chua ki tu vao
and al,0Fh
mov A,al ; vao xong cho A
mov ah,9
lea dx,tb3
int 21h
mov ah,1
int 21h
and al,0Fh
mov B,al ; vao xong cho B
mov al,a
add al,al ; al=2A
neg al
add al,B
mov a,al ; A=B-2A
mov ah,9
lea dx,tb2
int 21h
mov ah,2
mov dl,a
or dl,30h
int 21h
mov ah,4Ch
int 21h
HV endp
end HV
bai 4
.model small
.stack 100h
.data
tb db 10,13,10,13,' DAY LA CHUONG TRINH DAU TIEN$'
chao db 10,13,10,10,' CHAO CAC BAN$'
.code
cao proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,tb
int 21h
lea dx,chao
int 21h
mov ah,4ch
int 21h
cao endp
end cao
bai 5
.model small
.stack 100h
.data
tb1 db 10,13,' CHUONG TRINH IN DAY KI TU DAO NGUOC'
db 10,13,' Ban hay danh vao mot day ki tu:',10,13,'$'
.code
dn proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,tb1
int 21h
xor cx,cx ; cx dem so ki tu
mov ah,1
int 21h
lapw:
cmp al,13 ; ki tu khac enter ?
je thoi
push ax
inc cx
int 21h
jmp lapw
thoi:
mov ah,2
mov dl,10
int 21h
mov dl,13
int 21h
jcxz ketthuc
lapf:
pop dx
mov ah,2
int 21h
loop lapf
ketthuc:
mov ah,4ch
int 21h
dn endp
end dn
bai 6 Hienten
.model small
.stack 100
.data
ten db 80 dup(?)
.code
name1 proc
mov ax,@data
mov ds,ax
xor bx,bx ; dem=0
xor di,di ; chi so phan tu dau =0
mov ah,1
int 21h ; vao 1 ki tu
lapr:
mov ten[di],al
inc di
inc bx
int 21h
cmp al,13 ; ki tu=enter?
jne lapr
mov ah,2
mov dl,10
int 21h
mov dl,13
int 21h
mov cx,bx
xor di,di
lapf1:
mov dl,ten[di]
cmp dl,61h ; pt.=61h
jb ht
sub dl,20h
ht: int 21h
inc di
loop lapf1
mov ah,4ch
int 21h
name1 endp
end name1
bai 7 IN 1 so hexa
.model small
.stack 100
.data
tieude db 10,13,10,13,' IN RA MOT SO HEX',10,13,10,13,'$'
tb1 db ' hay vao mot so hex:$'
tb2 db 10,13,' gia tri so do la:$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,tieude
int 21h
lea dx,tb1
int 21h
mov ah,1
int 21h
cmp al,39h
ja chuyen
sub al,30h
jmp thoi
chuyen: cmp al,5ah
ja chuthuong
sub al,37h
jmp thoi
chuthuong: sub al,57h
thoi:
mov bl,al
mov ah,9
lea dx,tb2
int 21h
mov dl,bl
cmp dl,9
ja doichu
add dl,30h
jmp ht
doichu: add dl,37h
ht: mov ah,2
int 21h
mov ah,4ch
int 21h
main endp
end main
Bạn đang đọc truyện trên: AzTruyen.Top