35baiASM-26...35
;phamtuan_hp89
;bai 26: nhap 1 ky tu ch, in ra man hinh 10 dong, moi dong 10 ky tu ch
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'nhap 1 ky tu ch, in ra man hinh 10 dong, moi dong 10 ky tu ch$'
xdong db 10,13,'$'
tb1 db 10,13,'nhap 1 ky tu:$'
kt db 0
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
;nhap 1 ky tu
printst tb1
mov ah,1
int 21h
mov kt,al
printst xdong
;in 10x10 ky tu ch
mov cx,10
indong:
push cx
mov cx,10
inch:
mov dl,kt
mov ah,2
int 21h
mov dl,' '
mov ah,2
int 21h
loop inch
printst xdong
pop cx
loop indong
;press any key
lea dx,pkey
mov ah,9
int 21h
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
;phamtuan_hp89
;bai 27: tao s1 tu s loai bo cac dau cach
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'tao s1 tu s loai bo cac dau cach$'
xdong db 10,13,'$'
tb1 db 10,13,'nhap xau s:$'
s db 70 dup(0)
tb2 db 10,13,'s1:$'
s1 db 70 dup(0)
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
;nhap s
printst tb1
lea si,s
mov dx,si
add dx,70
nhaps:
mov ah,1
int 21h
cmp al,13
je endnhaps
mov [si],al
inc si
cmp si,dx
je endnhaps
jmp nhaps
endnhaps:
mov [si],'$'
printst xdong
;xu ly sc
lea si,s
lea di,s1
gans1:
cmp [si],'$'
je endgans1
cmp [si],' '
je gantiep
mov al,[si]
mov [di],al
inc di
gantiep:
inc si
jmp gans1
endgans1:
inc di
mov [di],'$'
printst xdong
printst tb2
printst s1
printst xdong
;press any key
lea dx,pkey
mov ah,9
int 21h
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
;phamtuan_hp89
;bai 28: kiem tra 1 ky tu ch trong xau s hay ko
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'kiem tra 1 ky tu ch trong xau s hay ko$'
xdong db 10,13,'$'
tb1 db 10,13,'nhap xau s : $'
s db 70 dup(0)
tb2 db 10,13,'nhap 1 ky tu ch : $'
ch db 70 dup(0)
cch db 10,13,'Co ch trong s $'
kch db 10,13,'Khong co ch trong s $'
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
;nhap s
printst tb1
lea si,s
mov ah,1
nhap:
int 21h
cmp al,13
je endnhap
mov [si],al
inc si
jmp nhap
endnhap:
mov [si],'$'
printst xdong
printst xdong
printst tb2
mov ah,1
int 21h
mov ch,al
printst xdong
;kiem tra ch trong s
lea si,s
kiemtra:
cmp [si],'$'
je koch
cmp [si],ch
je coch
inc si
jmp kiemtra
koch:
printst kch
jmp endkiemtra
coch:
printst cch
endkiemtra:
printst xdong
;press any key
lea dx,pkey
mov ah,9
int 21h
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
;phamtuan_hp89
;bai 29:dem so luong ky tu 'A' trong xau s
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'kiem tra 1 ky tu ch trong xau s hay ko$'
xdong db 10,13,'$'
tb1 db 10,13,'nhap xau s : $'
s db 70 dup(0)
tb2 db 10,13,'So luong ky tu A trong s : $'
d dw 0
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
;nhap s
printst tb1
lea si,s
mov ah,1
nhap:
int 21h
cmp al,13
je endnhap
cmp al,65
jne tiep
inc d
tiep:
mov [si],al
inc si
jmp nhap
endnhap:
mov [si],'$'
printst xdong
printst xdong
printst tb2
mov ax,d
call printnum
;press any key
lea dx,pkey
mov ah,9
int 21h
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
printnum proc
mov cx,0
pushstack:
xor dx,dx
mov bx,10
div bx ;thuong luu vao ax,du luu vao dx
push dx
inc cx
cmp ax,0
jne pushstack
mov ah,2
popstack:
pop dx
add dl,'0'
int 21h
loop popstack
printnum endp
;phamtuan_hp89
;bai 30: tinh tong cac ky tu so trong sau s
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'kiem tra 1 ky tu ch trong xau s hay ko$'
xdong db 10,13,'$'
tb1 db 10,13,'nhap xau s : $'
s db 70 dup(0)
tb2 db 10,13,'So luong ky tu so trong s : $'
d dw 0
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
;nhap s
printst tb1
lea si,s
mov ah,1
nhap:
int 21h
cmp al,13
je endnhap
cmp al,'0'
jb tiep
cmp al,'9'
ja tiep
inc d
tiep:
mov [si],al
inc si
jmp nhap
endnhap:
mov [si],'$'
printst xdong
printst xdong
printst tb2
mov ax,d
call printnum
;press any key
lea dx,pkey
mov ah,9
int 21h
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
printnum proc
mov cx,0
pushstack:
xor dx,dx
mov bx,10
div bx ;thuong luu vao ax,du luu vao dx
push dx
inc cx
cmp ax,0
jne pushstack
mov ah,2
popstack:
pop dx
add dl,'0'
int 21h
loop popstack
printnum endp
;phamtuan_hp89
;bai 31: nhap 1 so n, tinh tong n den 10
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
n db 0
t dw 0
tenct db 10,13,'nhap vao 1 so tu nhien n < 10, tinh tong cac so tu nhien tu n den 10$'
pkey db 10,13,'press any key to exit ... $'
xdong db 10,13,'$'
tb1 db 10,13,'Nhap so nguyen n = $'
tb2 db 10,13,'Tong= $'
cong db ' + $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
;hien ten chuong trinh
printst tenct
;nhap
nhap:
printst tb1
mov ah,1
int 21h
cmp al,'0'
jb nhap
cmp al,'9'
ja nhap
mov n,al
printst xdong
printst tb2
mov cx,0
mov cl,'9'
sub cl,n
inc cl
mov dl,n
inso:
mov ah,2
int 21h
and dx,00ffh
push dx
printst cong
pop dx
sub dx,'0'
mov ax,t
add ax,dx
mov t,ax
inc dx
add dx,'0'
loop inso
mov ah,2
mov dl,'1'
int 21h
mov dl,'0'
int 21h
mov ax,t
add ax,10
mov t,ax
mov dl,' '
mov ah,2
int 21h
mov dl,'='
mov ah,2
int 21h
mov dl,' '
mov ah,2
int 21h
mov ax,t
mov cx,0
mov bx,10
lap:
mov dx,0
div bx
push dx
inc cx
cmp ax,0
jne lap
mov ah,2
vietso:
pop dx
add dl,'0'
int 21h
loop vietso
;press any key
printst pkey
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
;phamtuan_hp89
;bai 32:nhap n so tu nhien trong doan [0..9], tinh tong cac so nay
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'nhap n so tu nhien trong doan [0..9], tinh tong cac so nay$'
xdong db 10,13,'$'
tb1 db 10,13,'nhap cac so can tinh tong, ket thuc bang enter:$'
so dw 20 dup(0)
t dw 0
cong db ' + $'
bang db ' = $'
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
printst tb1
lea si,so
mov cx,0
nhap:
mov ah,1
int 21h
cmp al,13
je endnhap
cmp al,'0'
jb endnhap
cmp al,'9'
ja endnhap
mov [si],al
sub al,'0'
and ax,00ffh
add t,ax
inc cx
cmp cx,20
je endnhap
inc si
jmp nhap
endnhap:
printst xdong
printst xdong
lea si,so
intong:
mov ah,2
mov dl,[si]
int 21h
inc si
cmp cx,1
je koincong
printst cong
koincong:
loop intong
printst bang
mov ax,t
call printnum
printst xdong
;press any key
printst pkey
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
printnum proc
mov cx,0
pushstack:
xor dx,dx
mov bx,10
div bx ;thuong luu vao ax,du luu vao dx
push dx
inc cx
cmp ax,0
jne pushstack
mov ah,2
popstack:
pop dx
add dl,'0'
int 21h
loop popstack
printnum endp
;phamtuan_hp89
;bai 33: tinh tong cac so chan trong doan [0..100]
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'tinh tong cac so chan trong doan [0..100]$'
xdong db 10,13,'$'
tb1 db 10,13,'Tong = $'
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
printst xdong
printst tb1
mov ax,0
mov bx,0
tinh:
add bx,2
add ax,bx
cmp bx,100
je endtinh
jmp tinh
endtinh:
call printnum
printst xdong
printst xdong
;press any key
printst pkey
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
printnum proc
mov cx,0
pushstack:
xor dx,dx
mov bx,10
div bx ;thuong luu vao ax,du luu vao dx
push dx
inc cx
cmp ax,0
jne pushstack
mov ah,2
popstack:
pop dx
add dl,'0'
int 21h
loop popstack
printnum endp
;phamtuan_hp89
;bai 34:tinh tong cac so le trong doan [0,100]
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'tinh tong cac so le trong doan [0..100]$'
xdong db 10,13,'$'
tb1 db 10,13,'Tong = $'
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
printst xdong
printst tb1
mov ax,0
mov bx,1
tinh:
add bx,2
add ax,bx
cmp bx,99
je endtinh
jmp tinh
endtinh:
add ax,1
call printnum
printst xdong
printst xdong
;press any key
printst pkey
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
printnum proc
mov cx,0
pushstack:
xor dx,dx
mov bx,10
div bx ;thuong luu vao ax,du luu vao dx
push dx
inc cx
cmp ax,0
jne pushstack
mov ah,2
popstack:
pop dx
add dl,'0'
int 21h
loop popstack
printnum endp
;phamtuan_hp89
;bai 35:kiem tra n la so chan hay so le
.model small
.stack 100h
printst macro tb
lea dx,tb
mov ah,9
int 21h
endm
.data
tenct db 10,13,'kiem tra n la so chan hay so le$'
xdong db 10,13,'$'
tb1 db 10,13,'Nhap n = $'
n dw 0
sochan db ' la so chan$'
sole db ' la so le$'
pkey db 10,13,'Press any key to exit ... $'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
printst tenct
printst xdong
printst tb1
call scannum
mov n,ax
printst xdong
mov ax,n
call printnum
mov ax,n
mov bx,2
xor dx,dx
div bx
cmp dx,0
je nchan
printst sole
jmp thoat
nchan:
printst sochan
thoat:
printst xdong
;press any key
printst pkey
mov ah,1
int 21h
mov ah,4ch
int 21h
main endp
printnum proc
mov cx,0
pushstack:
xor dx,dx
mov bx,10
div bx ;thuong luu vao ax,du luu vao dx
push dx
inc cx
cmp ax,0
jne pushstack
mov ah,2
popstack:
pop dx
add dl,'0'
int 21h
loop popstack
printnum endp
scannum proc
xor bx,bx
xor cx,cx
xor dx,dx
nhap:
mov ah,1
int 21h
cmp al,13
je endnhap
cmp al,'0'
jb endnhap
cmp al,'9'
ja endnhap
sub al,'0'
mov bl,al
mov ax,cx
mov dx,10
mul dx
add ax,bx
mov cx,ax
jmp nhap
endnhap:
mov ax,cx
scannum endp
Bạn đang đọc truyện trên: AzTruyen.Top