vixuli1
1-Hoa thường
org 100h
.model small
.stack 100h
.data
msg1 db 'Nhap vao mot ki tu inhoa : $'
msg2 db 10,13,'Khong la ki tu in hoa! Hay nhap lai! :$ '
msg3 db 10,13,'Ki tu thuong : '
kytu db ?,'$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg1
int 21h
nhap:
mov ah,01h
int 21h
cmp al,'A'
jb next
cmp al,'Z'
ja next
add al,20h
mov kytu,al
mov ah,09h
lea dx,msg3
int 21h
jmp exit
next:
mov ah,09h
lea dx,msg2
int 21h
jmp nhap
exit:
mov ah,4ch
int 21h
main endp
end
ret
2ki tu truoc sau
org 100h
.model small
.stack 100h
.data
msg1 db 'Nhap vao ki tu :$'
msg2 db 10,13, 'Ki tu lien truoc ki tu vua nhap :$'
msg3 db 10,13, 'Ki tu lien sau ki tu vua nhap :$'
kytu db ?
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg1
int 21h
mov ah,01h
int 21h
;chuyen ky tu vao bien
mov kytu,al
;ky tu dung truoc
mov ah,09h
lea dx,msg2
int 21h
;lay ra ky tu
mov dl,kytu
;tang gia tri trong bien 1dv
add dl,1
;xuat gia tri moi ra man hinh
mov ah,02h
int 21h
;ky tu dung sau
mov ah,09h
lea dx,msg3
int 21h
mov dl,kytu
add dl,-1
mov ah,02h
int 21h
mov ah,4ch
int 21h
main endp
end
ret
----------------------------------------------------------
3 nhap xuat chuỗi
org 100h
.model small
.stack 100h
.data
msg1 db 'Nhap vao 1 chuoi ky tu :$'
msg2 db 10,13,'Chuoi ky tu vua nhap la :$'
len db ? ;bien
chuoi db 101 ;chuoi co nhieu nhat 100 ki tu
buff db 102 dup(?) ;vung nho luu tru ky tu
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg1
int 21h
mov ah,0ah ;ham nhap chuoi
lea dx,chuoi ; dx chua dia chi chuoi
int 21h
mov ah,09h
lea dx,msg2
int 21h
mov si,2 ;vi tri luu ky tu nhap
lap:
mov dl,chuoi[si]
cmp dl,13 ;enter -> ket thuc
je exit
mov ah,02h
int 21h
inc si
jmp lap
exit:
mov ah,4ch
int 21h
main endp
end
ret
============================
4. nhập xuất kí tự
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
.model small
.stack 100h
.data
msg1 db 'Nhap 1 ki tu bat ki tu ban phim :$'
msg2 db 10,13,'Ki tu hien thi tren man hinh :$'
.code
main proc
start:
mov ax,@data
mov ds,ax
;in chuoi thong bao
mov ah,09h
lea dx,msg1
int 21h
;nhap 1 ki tu tu ban phim
mov ah,01h
int 21h
;luu ki tu vua nhap
push ax
mov ah,09h
lea dx,msg2
int 21h
;lay ki tu vua nhap
pop ax
;xuat ki tu
mov dl,al
;in ki tu ra man hinh
mov ah,02h
int 21h
exit:
mov ah,21h
int 21h
main endp
end
ret
5. thuong – hoa
org 100h
.model small
.stack 100h
.data
msg1 db 'Nhap vao mot ki tu thuong : $'
msg2 db 10,13,'Khong la ki tu thuong! Hay nhap lai! : $'
msg3 db 10,13,'Ki tu hoa : '
kytu db ?,'$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg1
int 21h
nhap:
mov ah,01h
int 21h
;kiem tra chu thuong
cmp al,'a' ;so sanh voi a
jb next ;nhay neu <a
cmp al,'z'
ja next ;nhay neu >z
sub al,20h
mov kytu,al
mov ah,09h
lea dx,msg3
int 21h
jmp exit
next:
mov ah,09h
lea dx,msg2
int 21h
jmp nhap
exit:
mov ah,4ch
int 21h
main endp
end
ret
======================================
7. x1 x2=
org 100h
.model small
.stack 100h
.data
msg1 db 'Nhap so nguyen duong x1 : $'
msg2 db 10,13,'Nhap so nguyen duong x2 : $'
msg3 db 10,13,'Khong phai so nguyen duong! Hay nhap lai : $'
msg4 db 10,13,'ket qua phep tinh x1 - 1 :'
msg5 db 10,13,'ket qua phep tinh x1 + 2 :'
;msg6 db 10,13,'ket qua phep tinh x1 - x2 :'
;msg7 db 10,13,'ket qua phep tinh x1 + x2 :'
x1 db ?,'$'
x2 db ?,'$'
x3 db ?,'$'
x4 db ?,'$'
x5 db ?,'$'
x6 db ?,'$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg1
int 21h
jmp nhapx1
nhapx1:
mov ah,01h
int 21h
cmp al,'0'
jb next1
cmp al,'9'
ja next1
mov x1,al
jmp tinhtoan
; mov ah,09h
;lea dx,msg2
;int 21h
;nhapx2:
;mov ah,01h
;int 21h
;cmp al,'0'
;jb next2
;cmp al,'9'
;ja next2
;mov x2,al
next1:
mov ah,09h
lea dx,msg3
int 21h
jmp nhapx1
;next2:
; mov ah,09h
;lea dx,msg3
;int 21h
;jmp nhapx2
tinhtoan:
mov ah,09h
lea dx,msg4
int 21h
mov dl,x1
add x1,2
mov ah,02h
int 21h
mov ah,09h
lea dx,msg5
int 21h
mov dl,x1
sub x1,1
mov ah,02h
int 21h
mov ah,4ch
int 21h
main endp
end
ret
8. xuat ra chuoi kit u
org 100h
.model small
.stack 100h
.data
msg db 'Wellcom to Assembly!$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov ah,4ch
int 21h
main endp
end
ret
Bạn đang đọc truyện trên: AzTruyen.Top