├── Addbintobin.asm ├── BTTL1.asm ├── BTTL2.asm ├── BTmail ├── Baitapbuoc1.asm ├── Baitapbuoc2.asm ├── Ghivadoc.asm └── Nguyentofromfile.asm ├── BaiTap ├── Baitap1.asm ├── Baitap10.asm ├── Baitap11.asm ├── Baitap12.asm ├── Baitap13.asm ├── Baitap14.asm ├── Baitap16.asm ├── Baitap17.asm ├── Baitap18.asm ├── Baitap19.asm ├── Baitap2.asm ├── Baitap20.asm ├── Baitap3.asm ├── Baitap4.asm ├── Baitap5.asm ├── Baitap6.asm ├── Baitap7.asm ├── Baitap8.asm ├── Baitap9.asm └── baitap15.asm ├── Dectobinsimple.asm ├── Hienthibin.asm ├── Mang.asm ├── Nhapstring.asm ├── README.md ├── VD1file.asm ├── bai1-11.asm ├── btmovsb.asm ├── dectobin.asm ├── diem.asm ├── howtogit.txt ├── laytungchuso.asm ├── mycode1.asm ├── mycode2.asm ├── nhapst.asm ├── printday.asm ├── stringtonumbe.asm ├── vd2file.asm ├── vd3file.asm └── xulifile.asm /Addbintobin.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | bien1 dw ? 5 | thongbao1 db 10,13,'So thu nhat : $' 6 | thongbao2 db 10,13,'So thu hai : $' 7 | thongbao db 10,13,'Tong la : $' 8 | main proc 9 | mov ax,@data 10 | mov ds,ax 11 | mov bx,0 12 | mov cx,16 13 | mov ah,09h 14 | lea dx,thongbao1 15 | int 21h 16 | Lap1: 17 | mov ah,01h 18 | int 21h 19 | sub al,30h 20 | shl bx,1 21 | add bl,al 22 | loop Lap1 23 | 24 | mov bien1,bx 25 | mov bx,0 26 | mov cx,16 27 | 28 | mov ah,09h 29 | lea dx,thongbao2 30 | int 21h 31 | 32 | Lap2: 33 | mov ah,01h 34 | int 21h 35 | sub al,30h 36 | shl bx,1 37 | add bl,al 38 | loop Lap2 39 | 40 | add bx,bien1 41 | mov cx,16 42 | 43 | mov ah,09h 44 | lea dx,thongbao 45 | int 21h 46 | 47 | mov dx,30h 48 | adc dx,0 49 | mov ah,02h 50 | int 21h 51 | Lap3: 52 | mov dl,30h 53 | shl bx,1 54 | adc dl,0 55 | mov ah,02h 56 | int 21h 57 | loop Lap3 58 | mov ah,4ch 59 | int 21h 60 | main endp 61 | end main 62 | -------------------------------------------------------------------------------- /BTTL1.asm: -------------------------------------------------------------------------------- 1 | .model small ;hien thi tu ?-z 2 | .stack 50 3 | .data 4 | str DB 10,13,'Nhap ky tu thuong:$' 5 | str1 DB 10,13, ' $' 6 | ktu DB ? 7 | 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds,ax 12 | 13 | mov ah,09h 14 | mov dx,offset str 15 | int 21h 16 | 17 | 18 | mov ah,01h 19 | int 21h 20 | mov ktu,al 21 | Lap: 22 | lea dx, str1 23 | int 21h 24 | 25 | inc ktu 26 | cmp ktu, 'z' 27 | jg Thoat 28 | lea dx,str1 29 | mov ah,9 30 | mov dl,ktu 31 | mov ah,2 32 | int 21h 33 | jmp Lap 34 | Thoat: 35 | 36 | mov ah,4CH 37 | int 21h 38 | 39 | main endp 40 | end main -------------------------------------------------------------------------------- /BTTL2.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | str1 DB 10,13, 'Nhap vao chu cai:$' 5 | str2 DB 10,13, 'Ky tu da doi:$' 6 | ktu DB ? 7 | .code 8 | main proc 9 | mov ax, @data 10 | mov ds,ax 11 | 12 | Lap: 13 | mov ah,09 14 | lea dx,str1 15 | int 21h 16 | 17 | mov ah,01h 18 | int 21h 19 | 20 | cmp al,'A' 21 | JL Lap 22 | cmp al,'z' 23 | Ja Lap 24 | 25 | cmp al,'Z' 26 | Jl Low 27 | cmp al,'a' 28 | JL Lap 29 | cmp al,'z' 30 | JL Up 31 | 32 | Up: 33 | sub al,32 34 | mov ktu,al 35 | jmp Exit1 36 | 37 | Low: 38 | 39 | add al,32 40 | mov ktu,al 41 | 42 | Exit1: 43 | lea dx,str2 44 | mov ah,9 45 | int 21h 46 | mov dl,ktu 47 | mov ah,02 48 | int 21h 49 | 50 | mov ah,4CH 51 | int 21h 52 | 53 | main endp 54 | end main -------------------------------------------------------------------------------- /BTmail/Baitapbuoc1.asm: -------------------------------------------------------------------------------- 1 | ;viet chuong trinh doc tep text 2 | .model small 3 | .stack 50 4 | .data 5 | controf dw ? 6 | tenf db 'bt.txt',0 7 | buff db ? 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | lea dx,tenf 14 | mov al,0 15 | mov ah,3Dh 16 | int 21h 17 | mov controf, ax 18 | 19 | Lapdoc: 20 | lea dx,buff 21 | mov bx,controf 22 | mov cx,1 23 | mov ah,3Fh 24 | int 21h 25 | cmp ax,0 26 | je thoat 27 | mov dl, buff 28 | mov ah,2 29 | int 21h 30 | jmp Lapdoc 31 | 32 | thoat: 33 | mov ah,3Eh 34 | mov bx,controf 35 | int 21h 36 | 37 | mov ah,4Ch 38 | int 21h 39 | main endp 40 | end main -------------------------------------------------------------------------------- /BTmail/Baitapbuoc2.asm: -------------------------------------------------------------------------------- 1 | ;viet chuong trinh doc tep text 2 | .model small 3 | .stack 50 4 | .data 5 | controf dw ? 6 | tenf db 'ab.txt',0 7 | buff db 50 dup('$') 8 | tam db 5 dup(?) 9 | count db 0 10 | .code 11 | main proc 12 | mov ax, @data 13 | mov ds, ax 14 | 15 | lea dx,tenf 16 | mov al,0 17 | mov ah,3Dh 18 | int 21h 19 | mov controf, ax 20 | Lapdoc: 21 | lea dx, buff 22 | mov ax,5 23 | mul count 24 | add dx, ax 25 | mov bx,controf 26 | mov cx,5 27 | mov ah,3Fh 28 | int 21h 29 | cmp ax,0 30 | je thoat 31 | inc count 32 | jmp Lapdoc 33 | 34 | thoat: 35 | lea dx,buff 36 | mov ah,9 37 | int 21h 38 | mov ah,3Eh 39 | mov bx,controf 40 | int 21h 41 | 42 | mov ah,4Ch 43 | int 21h 44 | main endp 45 | end main -------------------------------------------------------------------------------- /BTmail/Ghivadoc.asm: -------------------------------------------------------------------------------- 1 | .MODEL SMALL 2 | .STACK 50 3 | .DATA 4 | tb1 db 'Nhap chuoi ki tu vao: $' 5 | tb2 db 10,13,'Chuoi da nhap: $' 6 | tenf db 'bt.txt',0 7 | controf dw ? 8 | buff db ? 9 | .CODE 10 | 11 | main proc 12 | mov ax,@data 13 | mov ds,ax 14 | ;tao tap tin moi 15 | mov ah,3Ch 16 | lea dx,tenf ;gan ten moi cho file 17 | mov cx,0 ;che do file binh thuong 18 | int 21h 19 | mov controf, ax ;luu con tro file vao bien controf 20 | ;thong bao nhap vao 21 | lea dx, tb1 22 | mov ah,9 23 | int 21h 24 | ;doc ki tu tu ban phim va ghi vao file 25 | Lapghi: 26 | mov ah,1 27 | int 21h 28 | cmp al,13 ;so sanh voi ENTER de thoat 29 | je thoat 30 | mov buff , al ;neu ghi vao file 31 | lea dx, buff ;ky tu can ghi vao duoc chua trong dx 32 | mov bx,controf ; bien con tro 33 | mov cx,1 ; ghi 1 ky tu vao file //so ky tu duoc ghi vao 34 | mov ah,40h 35 | int 21h 36 | jmp Lapghi 37 | 38 | thoat: 39 | mov ah,3Eh ;dong file 40 | mov bx,controf 41 | int 21h 42 | ;mo lai file 43 | mov ah, 3Dh 44 | lea dx, tenf ;ten file 45 | mov al,0 ;mo lai chi doc 46 | int 21h 47 | mov controf,ax ;luu con tro file 48 | ;thong bao xuat 49 | lea dx,tb2 50 | mov ah,9 51 | int 21h 52 | ;doc va xuat file 53 | Lapdoc: 54 | lea dx,buff 55 | mov bx,controf 56 | mov cx,1 ;so ky tu doc tu file 57 | mov ah,3Fh 58 | int 21h 59 | 60 | cmp ax,0 ;neu o cuoi file ax se bang 0,la so ky tu doc duoc 61 | je Thoat2 ;neu bang 0 thi ket thuc 62 | mov dl, buff 63 | mov ah,2 64 | int 21h 65 | jmp Lapdoc 66 | ;dong file 67 | thoat2: 68 | mov ah,3Eh 69 | mov bx,controf 70 | int 21h 71 | 72 | mov ah,4Ch 73 | int 21h 74 | main endp 75 | end main -------------------------------------------------------------------------------- /BTmail/Nguyentofromfile.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | inp db 'inp.txt',0 5 | ctrof dw ? 6 | buf db 100,0,100 dup('$') 7 | count db 0 8 | b1 db 0 9 | b2 db 1 dup('$') 10 | muoi db 10 11 | outp db 'out.txt',0 12 | conf dw ? 13 | .code 14 | 15 | MAIN PROC 16 | mov ax,@data 17 | mov ds,ax 18 | 19 | mov ah, 3Dh 20 | lea dx,inp 21 | mov al,0 22 | int 21h 23 | mov ctrof,ax 24 | 25 | loopREAD: 26 | xor ax,ax 27 | lea dx,buf 28 | mov al,count 29 | add dx,ax 30 | mov bx,ctrof 31 | mov cx,1 32 | mov ah,3fh 33 | int 21h 34 | 35 | cmp ax,0 36 | je exitread 37 | inc count 38 | JMP loopREAD 39 | 40 | exitRead: 41 | mov ah,3eh 42 | mov bx,ctrof 43 | int 21h 44 | 45 | mov ah,3ch 46 | lea dx,outp 47 | mov cx,0 48 | int 21h 49 | mov conf, ax 50 | 51 | lea si,buf 52 | 53 | xulichuoi: 54 | cmp [si],'$' 55 | je exitXLC 56 | cmp [si], ' ' 57 | jne tiep 58 | call xau 59 | call kiemtra 60 | mov b1,0 61 | inc si 62 | 63 | tiep: 64 | mov al,b1 65 | xor bx,bx 66 | mov bl,[si] 67 | sub bl,30h 68 | mul muoi 69 | add ax,bx 70 | mov b1,al 71 | inc si 72 | jmp XULICHUOI 73 | exitXLC: 74 | call kiemtra 75 | 76 | MOV AH, 4Ch 77 | INT 21H 78 | MAIN ENDP 79 | 80 | KIEMTRA PROC 81 | mov cx,2 82 | nt: 83 | mov al,b1 84 | div cl 85 | cmp ah,0 86 | ja exit 87 | cmp cl,b1 88 | inc cx 89 | jl nt 90 | 91 | lea dx,b2 92 | mov cx,3 93 | mov bx,conf 94 | mov ah, 40h 95 | int 21h 96 | exit: 97 | ret 98 | KIEMTRA ENDP 99 | XAU PROC 100 | 101 | ret 102 | XAU ENDP 103 | END MAIN -------------------------------------------------------------------------------- /BaiTap/Baitap1.asm: -------------------------------------------------------------------------------- 1 | ;su dung ham 7 ngat 21h de nhan ky tu ban phim, roi hien thi lai 2 | .model small 3 | .stack 50 4 | .data 5 | tem DB ? 6 | str1 DB 10,13,'Nhap 1 ky tu:$' 7 | str2 DB 10,13,'Ky tu nhan duoc la:$' 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds,ax 12 | ;hien thi thong bao 13 | mov ah,09h 14 | lea dx,str1 15 | int 21h 16 | ;nhap ky tu vao 17 | mov ah,07h 18 | int 21h 19 | ;gan ky tu cho bien tam 20 | mov tem,al 21 | ;thong bao ky tu nhan duoc 22 | mov ah,09 23 | lea dx,str2 24 | int 21h 25 | ;hien thi ky tu duoc nhap vao 26 | mov ah,02h 27 | mov dl,tem 28 | int 21h 29 | 30 | mov ah,4CH 31 | int 21h 32 | 33 | 34 | 35 | main endp 36 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap10.asm: -------------------------------------------------------------------------------- 1 | ;nhap 2 so tu ban phim 2 | ; tinh a/b a*b khong su dung DIV va MUL 3 | 4 | .model small 5 | .stack 50 6 | .data 7 | so db 10,0,10 dup($) 8 | muoi db 10 9 | tb1 db 10,13,'A: $' 10 | tb2 db 10,13,'B: $' 11 | tb3 db 10,13,'A/B: $' 12 | tb4 db 10,13,'A*B: $' 13 | b1 dw 0 14 | b2 dw 0 15 | .code 16 | main proc 17 | mov ax,@data 18 | mov ds,ax 19 | 20 | mov ah,9 21 | lea dx,tb1 22 | int 21h 23 | 24 | mov ah,0Ah 25 | lea dx,so 26 | int 21h 27 | 28 | mov ah,9 29 | lea dx,tb2 30 | int 21h 31 | 32 | call xulichuoi 33 | mov b1,dx 34 | 35 | mov ah,0Ah 36 | lea dx,so 37 | int 21h 38 | 39 | call xulichuoi 40 | mov b2, dx 41 | 42 | mov ah,9 43 | lea dx,tb3 44 | int 21h 45 | 46 | mov dx,b1 47 | mov ax,b2 48 | 49 | xor cx,cx 50 | chia: 51 | sub dx,ax 52 | inc cx 53 | cmp dx,ax 54 | jae chia 55 | 56 | mov ax,cx 57 | Call Inchuoi 58 | 59 | lea dx,tb4 60 | mov ah,9 61 | int 21h 62 | 63 | xor cx,cx 64 | xor dx,dx 65 | mov cx,b2 66 | Nhan: 67 | add dx,b1 68 | Loop Nhan 69 | 70 | mov ax,dx 71 | Call inchuoi 72 | 73 | mov ah,4Ch 74 | int 21h 75 | main endp 76 | 77 | inchuoi PROC 78 | xor cx,cx 79 | Lapchia: 80 | xor dx,dx 81 | div muoi 82 | 83 | add ah,30h 84 | mov dl,ah 85 | push dx 86 | inc cx 87 | xor ah,ah 88 | cmp ax,0 89 | jne Lapchia 90 | Hienthi: 91 | pop dx 92 | mov ah,2 93 | int 21h 94 | loop Hienthi 95 | ret 96 | inchuoi ENDP 97 | 98 | xulichuoi PROC 99 | xor dx,dx 100 | xor cx,cx 101 | lea si,so + 2 102 | mov cl,[so+1] 103 | Lap: 104 | mov ax,dx 105 | xor bx,bx 106 | mov bl,[si] 107 | sub bl,30h 108 | mul muoi 109 | add ax,bx 110 | mov dx,ax 111 | inc si 112 | loop Lap 113 | ret 114 | xulichuoi ENDP 115 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap11.asm: -------------------------------------------------------------------------------- 1 | ;Nhap 2 so nhi phan 16 bit 2 | ;tinh A+B,A-B,A and B,A OR B 3 | .model small 4 | .stack 100 5 | .data 6 | b1 dw ? 7 | b2 dw ? 8 | tb1 db 'So A 16bit: $' 9 | tb2 db 10, 13, 'So B 16bit: $' 10 | tb3 db 10, 13, 'A + B = $' 11 | tb4 db 10, 13, 'A - B = $' 12 | tb5 db 10, 13, 'A OR B = $' 13 | tb6 db 10, 13, 'A AND B = $' 14 | MAIN PROC 15 | mov ax, @data 16 | mov ds,ax 17 | 18 | mov bx, 0 19 | mov cx, 16 20 | mov ah,9 21 | lea dx,tb1 22 | int 21h 23 | 24 | Lap1: 25 | mov ah,1 26 | int 21h 27 | sub al,30h 28 | shl bx,1 29 | add bl,al 30 | loop Lap1 31 | mov b1, bx 32 | 33 | mov bx,0 34 | mov cx, 16 35 | lea dx, tb2 36 | mov ah,9 37 | int 21h 38 | 39 | Lap2: 40 | mov ah,1 41 | int 21h 42 | sub al,30h 43 | shl bx,1 44 | add bl, al 45 | Loop Lap2 46 | mov b2,bx 47 | 48 | mov ah, 09 49 | lea dx, tb3 50 | int 21h 51 | 52 | mov bx,b2 53 | add bx,b1 54 | 55 | mov cx,16 56 | mov dx, 30h 57 | adc dx,0 58 | mov ah,2 59 | int 21h 60 | 61 | Lap3: 62 | mov dl,30h 63 | shl bx,1 64 | adc dl,0 65 | mov ah,2 66 | int 21h 67 | loop Lap3 68 | 69 | mov ah,9 70 | lea dx,tb4 71 | int 21h 72 | 73 | mov bx,b1 74 | sub bx,b2 75 | mov cx,16 76 | Lap4: 77 | mov dl,30h 78 | shl bx,1 79 | adc dl,0 80 | mov ah,2 81 | int 21h 82 | loop Lap4 83 | 84 | mov ah,9 85 | lea dx,tb5 86 | int 21h 87 | 88 | mov bx,b1 89 | or bx,b2 90 | mov cx,16 91 | Lap5: 92 | mov dl,30h 93 | shl bx,1 94 | adc dl,0 95 | mov ah,2 96 | int 21h 97 | loop Lap5 98 | 99 | mov ah,9 100 | lea dx,tb6 101 | int 21h 102 | mov bx,b1 103 | and bx,b2 104 | mov cx,16 105 | Lap6: 106 | mov dl,30h 107 | shl bx,1 108 | adc dl,0 109 | mov ah,2 110 | int 21h 111 | loop Lap6 112 | mov ah,4ch 113 | int 21h 114 | main endp 115 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap12.asm: -------------------------------------------------------------------------------- 1 | ;Nhap vao ban phim 1 ky tu 2 | ;hien thi ma ascii cua no o dang Hex, Dec, Bin 3 | .model small 4 | .stack 100 5 | .data 6 | muoi db 10 7 | xuong db 10,13,'$' 8 | b1 db ? 9 | chia16 db 16 10 | .code 11 | main proc 12 | mov ax,@data 13 | mov ds,ax 14 | 15 | mov ah,1 16 | int 21h 17 | mov b1,al 18 | lea dx, xuong 19 | mov ah,9 20 | int 21h 21 | 22 | mov ax,0 23 | mov al,b1 24 | xor cx,cx 25 | Lap1: 26 | xor dx,dx 27 | div chia16 28 | cmp ah,9 29 | ja chucai 30 | add ah,30h 31 | jmp so 32 | chucai: 33 | add ah,55 34 | so: 35 | mov dl, ah 36 | push dx 37 | inc cx 38 | xor ah,ah 39 | cmp ax,0 40 | jne Lap1 41 | Hienthi: 42 | pop dx 43 | mov ah,2 44 | int 21h 45 | loop hienthi 46 | mov dx,'h' 47 | mov ah,2 48 | int 21h 49 | 50 | lea dx,xuong 51 | mov ah,9 52 | int 21h 53 | 54 | xor ah,ah 55 | mov al,b1 56 | xor cx,cx ;gan cx = 0 de dem so ky tu so 57 | Lapchia: 58 | xor dx,dx ;dua dx =0 59 | div muoi ;chia cho ax cho 10 o dang 8 bit ah chua so du al chua thuong 60 | 61 | add ah,30h ;bien so trong ah thanh ky tu so 62 | mov dl,ah ; dua ah vao dx 63 | push dx ;dua dx vao ngang xep 64 | inc cx ;them mot chu so la cong them 65 | xor ah,ah ;xoa ah 66 | cmp ax,0 ;neu thuong bang 0 thi dung lai 67 | jne Lapchia 68 | 69 | Dochienthi: ;luc nay cx co gia tri la so ky tu 70 | pop dx ;lay tung ky tu so in ra 71 | mov ah,2 72 | int 21h 73 | loop Dochienthi 74 | 75 | lea dx,xuong 76 | mov ah,9 77 | int 21h 78 | xor bx,bx 79 | mov bl,b1 80 | mov cx,8 81 | Lap4: 82 | mov dl,30h 83 | shl bl,1 84 | adc dl,0 85 | mov ah,2 86 | int 21h 87 | loop Lap4 88 | mov dl,'b' 89 | mov ah,2 90 | int 21h 91 | 92 | mov ah,4Ch 93 | int 21h 94 | main endp 95 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap13.asm: -------------------------------------------------------------------------------- 1 | ;Nhap vao 2 so he 16 tinh tong hieu or xor 2 | .model small 3 | .stack 100 4 | .data 5 | tb1 db 'Nhap so A: $' 6 | tb2 db 10,13, 'Nhap so B: $' 7 | b1 dw ? 8 | b2 dw ? 9 | tb3 db 10, 13, 'A + B = $' 10 | tb4 db 10, 13, 'A - B = $' 11 | tb5 db 10, 13, 'A OR B = $' 12 | tb6 db 10, 13, 'A XOR B = $' 13 | tbloi db 10, 13 , 'Nhap sai$' 14 | so db 5,0,5 dup(?) ,'$' 15 | muoi dw 16 16 | .code 17 | main proc 18 | mov ax,@data 19 | mov ds,ax 20 | 21 | lea dx,tb1 22 | mov ah,9 23 | int 21h 24 | call Nhap 25 | mov ax,b2 26 | mov b1,ax 27 | ;xuong hang 28 | mov ah,9 29 | lea dx,tb2 30 | int 21h 31 | mov b2, 0 32 | call Nhap 33 | 34 | mov ah, 09 35 | lea dx, tb3 36 | int 21h 37 | 38 | mov bx,b2 39 | add bx,b1 40 | 41 | mov cx,16 42 | mov dx, 30h 43 | adc dx,0 44 | mov ah,2 45 | int 21h 46 | 47 | Lap3: 48 | mov dl,30h 49 | shl bx,1 50 | adc dl,0 51 | mov ah,2 52 | int 21h 53 | loop Lap3 54 | 55 | mov ah,9 56 | lea dx,tb4 57 | int 21h 58 | 59 | mov bx,b1 60 | sub bx,b2 61 | mov cx,16 62 | Lap4: 63 | mov dl,30h 64 | shl bx,1 65 | adc dl,0 66 | mov ah,2 67 | int 21h 68 | loop Lap4 69 | 70 | mov ah,9 71 | lea dx,tb5 72 | int 21h 73 | 74 | mov bx,b1 75 | or bx,b2 76 | mov cx,16 77 | Lap5: 78 | mov dl,30h 79 | shl bx,1 80 | adc dl,0 81 | mov ah,2 82 | int 21h 83 | loop Lap5 84 | 85 | mov ah,9 86 | lea dx,tb6 87 | int 21h 88 | mov bx,b1 89 | xor bx,b2 90 | mov cx,16 91 | Lap6: 92 | mov dl,30h 93 | shl bx,1 94 | adc dl,0 95 | mov ah,2 96 | int 21h 97 | loop Lap6 98 | mov ah,4Ch 99 | int 21h 100 | main endp 101 | 102 | nhap proc 103 | xor cx,cx 104 | lea dx,so 105 | mov ah,0Ah 106 | int 21h 107 | ;dua ve ky tu dau tien nhap vao 108 | lea si,so + 2 109 | ;dua so ky tu vao 110 | mov cl, [so + 1] 111 | ;dua so vao b1 112 | Lap1: 113 | mov Ax,b2 114 | xor bx,bx 115 | mov bl,[si] 116 | 117 | cmp bl, 48 118 | jl thoat 119 | cmp bl,57 120 | jae tiep 121 | sub bl,48 122 | jmp nhan1 123 | tiep: 124 | cmp bl,65 125 | jl thoat 126 | cmp bl,70 127 | ja thoat 128 | sub bl,55 129 | nhan1: 130 | mul muoi 131 | add ax,bx 132 | mov b2,ax 133 | inc si 134 | jmp conti 135 | 136 | thoat: 137 | mov cx,0 138 | mov ah, 9 139 | lea dx, tbloi 140 | int 21h 141 | ret 142 | conti: 143 | Loop Lap1 144 | ret 145 | nhap endp 146 | 147 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap14.asm: -------------------------------------------------------------------------------- 1 | ;nhap vao hai chuoi so roi tinh tong 2 | .model small 3 | .stack 50 4 | .data 5 | so db 10,0, 10 dup($) 6 | muoi db 10 7 | xuong db 10,13,'A + B: $' 8 | kq db 10,13, 'A - B: $' 9 | B1 Dw 0 10 | b2 dw 0 11 | tb1 db 10,13, 'Nhap vao so dau: $' 12 | tb2 db 10,13, 'Nhap vao so thu 2: $' 13 | .code 14 | main proc 15 | mov ax,@data 16 | mov ds,ax 17 | ;nhap xau 18 | lea dx,tb1 19 | mov ah,9 20 | int 21h 21 | xor cx,cx 22 | lea dx,so 23 | mov ah,0Ah 24 | int 21h 25 | ;xuong hang 26 | mov ah,9 27 | lea dx,tb2 28 | int 21h 29 | ;dua ve ky tu dau tien nhap vao 30 | lea si,so + 2 31 | ;dua so ky tu vao 32 | mov cl,[so + 1] 33 | ;dua so vao b1 34 | Lap: 35 | mov Ax,b1 36 | xor bx,bx 37 | mov bl,[si] 38 | sub bl,48 39 | mul muoi 40 | add ax,bx 41 | mov b1,ax 42 | inc si 43 | Loop Lap 44 | 45 | mov ah,0Ah 46 | lea dx,so 47 | int 21h 48 | 49 | mov ah,9 50 | lea dx,xuong 51 | int 21h 52 | 53 | lea si,so + 2 54 | mov cl,[so + 1] 55 | Lap2: 56 | mov Ax,b2 57 | xor bx,bx 58 | mov bl,[si] 59 | sub bl,48 60 | mul muoi 61 | add ax,bx 62 | mov b2,ax 63 | inc si 64 | Loop Lap2 65 | ;cong b1 va b2 vao dx 66 | mov dx,b2 67 | add dx,b1 68 | 69 | mov ax,dx 70 | xor cx,cx 71 | Lapchia: 72 | xor dx,dx 73 | div muoi 74 | 75 | add ah,30h 76 | mov dl,ah 77 | push dx 78 | inc cx 79 | xor ah,ah 80 | cmp ax,0 81 | jne Lapchia 82 | Hienthi: 83 | pop dx 84 | mov ah,2 85 | int 21h 86 | loop Hienthi 87 | 88 | lea dx,kq 89 | mov ah,9 90 | int 21h 91 | 92 | mov dx,b1 93 | sub dx,b2 94 | 95 | mov ax,dx 96 | xor cx,cx 97 | 98 | Lapxuat: 99 | xor dx,dx 100 | div muoi 101 | 102 | add ah,30h 103 | mov dl,ah 104 | push dx 105 | inc cx 106 | xor ah,ah 107 | cmp ax,0 108 | jne Lapxuat 109 | Hienthi2: 110 | pop dx 111 | mov ah,2 112 | int 21h 113 | loop Hienthi2 114 | 115 | mov ah,4Ch 116 | int 21h 117 | 118 | main endp 119 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap16.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | so db 10,0, 10 dup($) 5 | muoi db 10 6 | xuong db 10,13,'Ket Qua: $' 7 | B1 Dw 0 8 | b2 dw 0 9 | tb1 db 10,13, 'Nhap vao so dau: $' 10 | tb2 db 10,13, 'Nhap vao so thu 2: $' 11 | .code 12 | main proc 13 | mov ax,@data 14 | mov ds,ax 15 | ;nhap xau 16 | lea dx,tb1 17 | mov ah,9 18 | int 21h 19 | xor cx,cx 20 | lea dx,so 21 | mov ah,0Ah 22 | int 21h 23 | ;xuong hang 24 | mov ah,9 25 | lea dx,tb2 26 | int 21h 27 | ;dua ve ky tu dau tien nhap vao 28 | lea si,so + 2 29 | ;dua so ky tu vao 30 | mov cl,[so + 1] 31 | ;dua so vao b1 32 | Lap: 33 | mov Ax,b1 34 | xor bx,bx 35 | mov bl,[si] 36 | sub bl,48 37 | mul muoi 38 | add ax,bx 39 | mov b1,ax 40 | inc si 41 | Loop Lap 42 | mov ah,01h 43 | int 21h 44 | sub al,30h 45 | xor cx,cx 46 | mov cl,al 47 | 48 | mov ax,1 49 | mov bx,1 50 | Giaithua: 51 | Mul bx 52 | inc bx 53 | cmp bx,cx 54 | jle giaithua 55 | mov b2,ax 56 | 57 | lea dx, xuong 58 | mov ah,9 59 | int 21h 60 | 61 | mov bx,b1 62 | mov dx,b2 63 | 64 | Lap3: 65 | cmp bx,dx 66 | jz thoat 67 | ja A 68 | jb B 69 | A: 70 | mov ax,bx 71 | sub ax,dx 72 | mov bx,ax 73 | jmp Lap3 74 | B: 75 | mov ax,dx 76 | sub ax,bx 77 | mov dx,ax 78 | jmp Lap3 79 | thoat: 80 | 81 | mov ax,bx 82 | xor cx,cx 83 | Lapchia: 84 | xor dx,dx 85 | div muoi 86 | 87 | add ah,30h 88 | mov dl,ah 89 | push dx 90 | inc cx 91 | xor ah,ah 92 | cmp ax,0 93 | jne Lapchia 94 | Hienthi: 95 | pop dx 96 | mov ah,2 97 | int 21h 98 | loop Hienthi 99 | 100 | mov ah,4Ch 101 | int 21h 102 | 103 | main endp 104 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap17.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | mang db 20,0, 20 dup(?) 5 | tb2 db 10,13,'Chuoi da duoc dao nguoc: $' 6 | tb1 db "Nhap 1 chuoi vao: $" 7 | .code 8 | main proc 9 | mov ax,@data 10 | mov ds,ax 11 | 12 | mov ah,9 13 | lea dx, tb1 14 | int 21h 15 | 16 | mov ah,0ah 17 | lea dx,mang 18 | int 21h 19 | 20 | lea dx, tb2 21 | mov ah,9 22 | int 21h 23 | 24 | mov cl,[mang + 1] 25 | lea si, mang + 2 26 | Lap: 27 | push [si] 28 | inc si 29 | loop Lap 30 | mov cl, [mang + 1] 31 | Lap2: 32 | pop dx 33 | mov ah,2 34 | int 21h 35 | Loop Lap2 36 | mov ah,4ch 37 | int 21h 38 | main endp 39 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap18.asm: -------------------------------------------------------------------------------- 1 | .MODEL SMALL 2 | .STACK 100 3 | .DATA 4 | tong db 0 5 | muoi db 10 6 | tb2 db 10,13,'TB: $' 7 | chuoi db 50,0,50 dup($) 8 | count db 0 9 | b1 db 0 10 | tb1 db 'Nhap chuoi so can tinh trung binh: $' 11 | .CODE 12 | MAIN PROC 13 | MOV ax,@data 14 | MOV ds,ax 15 | xor cx,cx 16 | lea dx,tb1 17 | mov ah,9 18 | int 21h 19 | 20 | mov ah,0Ah 21 | lea dx,chuoi 22 | int 21h 23 | xor ax,ax 24 | mov cl,[chuoi+ 1] 25 | lea si,chuoi + 2 26 | Tongso: 27 | cmp [si],0dh 28 | je congcuoi 29 | cmp [si],' ' 30 | jne tiep 31 | congcuoi: 32 | inc count 33 | xor bx,bx 34 | mov bl,tong 35 | add bl,b1 36 | mov tong,bl 37 | mov b1,0 38 | inc si 39 | 40 | tiep: 41 | mov al,b1 42 | xor bx,bx 43 | mov bl,[si] 44 | sub bl,30h 45 | mul muoi 46 | add ax,bx 47 | mov b1,al 48 | inc si 49 | loop tongso 50 | Chia: 51 | mov ah,9 52 | lea dx,tb2 53 | int 21h 54 | XOR AX,AX 55 | mov al,tong 56 | mov cl,count 57 | div cl 58 | xor ah,ah 59 | xor cx,cx 60 | Lap: 61 | xor dx,dx 62 | div muoi 63 | mov dl,ah 64 | add dx, 30h 65 | push dx 66 | inc cx 67 | xor ah,ah 68 | cmp ax,0 69 | jne Lap 70 | Hienthi: 71 | pop dx 72 | mov ah,2 73 | int 21h 74 | loop Hienthi 75 | MOV ah,4Ch 76 | INT 21h 77 | MAIN ENDP 78 | END MAIN -------------------------------------------------------------------------------- /BaiTap/Baitap19.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | so db 10,0,10 dup($) 5 | tb1 db 'Nhap so: $' 6 | tb2 db 10,13,'Tong cac chu so: $' 7 | Tong db 0 8 | muoi db 10 9 | .code 10 | main proc 11 | mov ax,@data 12 | mov ds,ax 13 | 14 | lea dx,tb1 15 | mov ah,9 16 | int 21h 17 | ;nhap so vao 18 | lea dx,so 19 | mov ah,0Ah 20 | int 21h 21 | 22 | xor cx,cx 23 | lea si,so+2 24 | mov cl,[so+1] 25 | 26 | xor ax,ax 27 | Lap: 28 | xor bx,bx 29 | mov bl,[si] 30 | sub bl,30h 31 | add ax,bx 32 | inc si 33 | loop Lap 34 | 35 | 36 | xor cx,cx 37 | lapchia: 38 | xor dx,dx 39 | div muoi 40 | add ah,30h 41 | mov dl,ah 42 | push dx 43 | inc cx 44 | xor ah,ah 45 | cmp ax,0 46 | jne lapchia 47 | 48 | lea dx,tb2 49 | mov ah,9 50 | int 21h 51 | Hienthi: 52 | pop dx 53 | mov ah,2 54 | int 21h 55 | loop Hienthi 56 | mov ah,4Ch 57 | int 21h 58 | main endp 59 | end main 60 | -------------------------------------------------------------------------------- /BaiTap/Baitap2.asm: -------------------------------------------------------------------------------- 1 | ;nhap mot ky tu tu ban phim va hien thi lai 2 | ;khong dung bien phu 3 | .model small 4 | .stack 50 5 | .data 6 | str1 DB 10,13, 'Nhap ky tu:$' 7 | str2 DB 10,13, 'Ky tu vua nhap:$' 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds,ax 12 | 13 | mov ah,09h 14 | lea dx,str1 15 | int 21h 16 | 17 | mov ah,01h 18 | int 21h 19 | mov bl,al 20 | 21 | mov ah, 09h 22 | mov dx,offset str2 23 | int 21h 24 | 25 | mov ah,2 26 | mov dl,bl 27 | int 21h 28 | 29 | mov ah,4CH 30 | int 21h 31 | 32 | 33 | 34 | main endp 35 | end main 36 | -------------------------------------------------------------------------------- /BaiTap/Baitap20.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | so db 50, 0 , 50 dup($) 5 | b1 dw 0 ; so duoc nhap vao 6 | muoi dw 10 7 | b2 dw 0 ; tong cac uoc cua so duoc nhap vao 8 | b3 dw 0 9 | hoanhao db 10, 13, "so hoan hao$" 10 | khh db 10, 13, "Khong hoan hao$" 11 | .code 12 | main proc 13 | mov ax,@data 14 | mov ds,ax 15 | 16 | lea dx,so 17 | mov ah,0Ah 18 | int 21h 19 | xor cx,cx 20 | lea si, so +2 21 | mov cl, [so + 1] 22 | 23 | Lap: 24 | mov ax,b1 25 | xor bx,bx 26 | mov bl, [si] 27 | sub bl,30h 28 | mul muoi 29 | add ax,bx 30 | mov b1,ax 31 | inc si 32 | loop Lap 33 | 34 | mov ax, b1 35 | mov bx, 2 36 | div bx 37 | mov b3, ax 38 | 39 | mov cx, 1 40 | Tongu: 41 | xor dx, dx 42 | mov ax, b1 43 | cmp b2, ax 44 | jae thoat 45 | div cx 46 | cmp dx, 0 47 | jne boqua 48 | add b2, cx 49 | boqua: 50 | inc cx 51 | cmp cx, b3 52 | jle tongu 53 | 54 | thoat: 55 | mov bx, b1 56 | cmp bx, b2 57 | je HH 58 | lea dx, khh 59 | jmp inra 60 | HH: 61 | lea dx, hoanhao 62 | inra: 63 | mov ah, 9 64 | int 21h 65 | 66 | mov ah,4ch 67 | int 21h 68 | main endp 69 | end main 70 | -------------------------------------------------------------------------------- /BaiTap/Baitap3.asm: -------------------------------------------------------------------------------- 1 | ;Nhap vao chu cai 2 | ;neu chu hoa bien thanh chu cai thuong 3 | ;neu chu cai thuong bien thanh chu cai hoa 4 | .model small 5 | .stack 50 6 | .data 7 | str1 DB 10,13, 'Nhap vao chu cai:$' 8 | xuong db 10, 13 , "$" 9 | .code 10 | main proc 11 | mov ax, @data 12 | mov ds,ax 13 | 14 | Lap: 15 | mov ah,09 16 | lea dx,str1 17 | int 21h 18 | 19 | mov ah,01h 20 | int 21h 21 | 22 | cmp al,'A' 23 | JL Lap 24 | cmp al,'z' 25 | Ja Lap 26 | cmp al,'Z' 27 | Jl Low 28 | cmp al,'a' 29 | JL Lap 30 | cmp al,'z' 31 | JL Up 32 | 33 | Up: 34 | and al,11011111b 35 | mov dl,al 36 | mov ah,02 37 | int 21h 38 | JMP Exit1 39 | 40 | Low: 41 | 42 | add al,32 43 | mov ah,02 44 | int 21h 45 | Exit1: 46 | mov ah,4CH 47 | int 21h 48 | main endp 49 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap4.asm: -------------------------------------------------------------------------------- 1 | ;nhap vao chuoi ky tu 2 | ;hien thi Xin chao 3 | .model small 4 | .stack 100h 5 | .data 6 | str1 DB 10,13, 'Nhap vao chu cai:$' 7 | str2 DB 10,13, 'Xin chao $' 8 | mang DB 30, 0, 30 dup('$'), '$' 9 | .code 10 | main proc 11 | mov ax, @data 12 | mov ds,ax 13 | ;nhap chuoi ky tu 14 | mov ah,0Ah 15 | lea dx,mang 16 | int 21h 17 | 18 | mov ah,9 19 | 20 | lea dx,str2 21 | int 21h 22 | ;dua dx chi ve phan tu thu 2 cua mang la ky tu dau tien duoc nhap vao 23 | lea dx,[mang + 2] 24 | int 21h 25 | 26 | mov ah,4CH 27 | int 21h 28 | 29 | main endp 30 | end main 31 | -------------------------------------------------------------------------------- /BaiTap/Baitap5.asm: -------------------------------------------------------------------------------- 1 | ;Nhap vao 1 ky tu 2 | ;'S'/'s' hien thi "Good Morning!", 'T'/'t' "Good Afternoon!", 'C'/'c' "Good Everning" 3 | .model small 4 | .stack 50 5 | .data 6 | gm DB 10,13, 'Good Morning!$' 7 | ga DB 10,13, 'Good Afternoon!$' 8 | ge DB 10,13, 'Good Everning!$' 9 | str DB 10,13,'Nhap ky tu:$' 10 | .code 11 | main proc 12 | mov ax, @data 13 | mov ds,ax 14 | 15 | mov ah,09h 16 | lea dx,str 17 | int 21h 18 | mov ah,01 19 | int 21h 20 | 21 | cmp al,'S' 22 | Je Morning 23 | cmp al,'s' 24 | je Morning 25 | 26 | cmp al,'T' 27 | Je Afternoon 28 | cmp al,'t' 29 | je Afternoon 30 | 31 | cmp al,'C' 32 | Je Everning 33 | cmp al,'c' 34 | je Everning 35 | jmp thoat 36 | Morning: 37 | mov ah,09h 38 | lea dx,gm 39 | int 21h 40 | jmp Thoat 41 | Afternoon: 42 | mov ah,09h 43 | lea dx,ga 44 | int 21h 45 | jmp Thoat 46 | Everning: 47 | mov ah,09h 48 | lea dx,ge 49 | int 21h 50 | jmp Thoat 51 | Thoat: 52 | mov ah,4CH 53 | int 21h 54 | 55 | 56 | 57 | main endp 58 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap6.asm: -------------------------------------------------------------------------------- 1 | ;Nhap vao 1 chu cai thuong/ hien thi tu chu cai do den z 2 | .model small ;hien thi tu ?-z 3 | .stack 50 4 | .data 5 | str DB 10,13,'Nhap ky tu thuong:$' 6 | str1 DB ' $' 7 | ktu DB ? 8 | 9 | .code 10 | main proc 11 | mov ax, @data 12 | mov ds,ax 13 | 14 | mov ah,09h 15 | mov dx,offset str 16 | int 21h 17 | 18 | 19 | mov ah,01h 20 | int 21h 21 | mov ktu,al 22 | Lap: 23 | lea dx, str1 24 | mov ah,09 25 | int 21h 26 | 27 | inc ktu 28 | cmp ktu, 'z' 29 | jg Thoat 30 | lea dx,str1 31 | mov ah,9 32 | mov dl,ktu 33 | mov ah,2 34 | int 21h 35 | jmp Lap 36 | Thoat: 37 | 38 | mov ah,4CH 39 | int 21h 40 | 41 | main endp 42 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap7.asm: -------------------------------------------------------------------------------- 1 | ;khong su dung 0Ah/21h nhap vao chuoi ky tu va dem so ky tu hien thi lai chuoi ky tu do 2 | .model small 3 | .stack 50 4 | .data 5 | mang DB 50 dup(?) 6 | kt Db ? 7 | tb1 db 'Nhap chuoi: $' 8 | tb2 db 10, 13, 'So ki tu: $' 9 | tb3 db 10, 13, 'Chuoi da nhap vao: $' 10 | chia db 10 11 | .code 12 | main proc 13 | mov ax,@data 14 | mov ds,ax 15 | lea dx, tb1 16 | mov ah,9 17 | int 21h 18 | 19 | ;nhap mang 20 | Lea Si,mang 21 | xor cx,cx 22 | Lapnhap: 23 | mov ah,1 24 | int 21h 25 | cmp al,0Dh 26 | je Xuong 27 | mov [si], al 28 | inc si 29 | inc cx 30 | jmp Lapnhap 31 | ;xuong dong 32 | Xuong: 33 | lea dx, tb2 34 | mov ah,09h 35 | int 21h 36 | ;hien thi so ky tu 37 | mov kt,cl 38 | mov al,cl 39 | mov ah,0 40 | xor cx,cx 41 | Lap: 42 | xor dx,dx 43 | div chia 44 | 45 | add ah,30h 46 | mov dl,ah 47 | push dx 48 | inc cx 49 | xor ah,ah 50 | cmp ax,0 51 | jne Lap 52 | Hienthi: 53 | pop dx 54 | mov ah,2 55 | int 21h 56 | loop Hienthi: 57 | 58 | lea dx,tb3 59 | mov ah,09h 60 | int 21h 61 | ;hien thi da nhap vao 62 | mov cl,kt 63 | lea si,mang 64 | XUat: 65 | mov dl,[si] 66 | mov ah,2 67 | int 21h 68 | inc si 69 | loop xuat 70 | 71 | mov ah,4Ch 72 | int 21h 73 | 74 | main endp 75 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap8.asm: -------------------------------------------------------------------------------- 1 | ;Nhap vao chuoi ky tu bat ky 2 | ;bien tat ca thanh chu thuong roi in ra 3 | ;bien tat ca chu cai thanh hoa r in ra 4 | .model small 5 | .stack 50 6 | .data 7 | mang db 50,0, 50 dup('$') 8 | xuong db 10 , 13,'$' 9 | Gach db ' - $' 10 | ktu db ? 11 | .code 12 | main proc 13 | mov ax,@data 14 | mov ds,ax 15 | 16 | mov ah,0Ah 17 | lea dx,mang 18 | int 21h 19 | 20 | lea dx,xuong 21 | mov ah,09 22 | int 21h 23 | 24 | lea si,mang+ 2 25 | mov cl, [mang + 1] 26 | Lap1: 27 | cmp [si],'A' 28 | Jl Boqua 29 | cmp [si],'Z' 30 | JA Boqua 31 | add [si],32 32 | 33 | Boqua: 34 | inc si 35 | loop lap1 36 | 37 | 38 | call xuat 39 | lea dx,gach 40 | mov ah,9 41 | int 21h 42 | 43 | Lea si,mang + 2 44 | mov cl,[mang + 1] 45 | Lap2: 46 | cmp [si],'a' 47 | Jl Boqua2 48 | cmp [si],'z' 49 | JA Boqua2 50 | sub [si], 32 51 | 52 | Boqua2: 53 | inc Si 54 | loop Lap2 55 | 56 | call xuat 57 | 58 | mov ah,4ch 59 | int 21h 60 | main endp 61 | 62 | xuat PROC 63 | mov cl,[mang + 1] 64 | lea si,mang + 2 65 | lap: 66 | mov dl,[si] 67 | mov ah,2 68 | int 21h 69 | inc si 70 | loop lap 71 | ret 72 | xuat endp 73 | end main -------------------------------------------------------------------------------- /BaiTap/Baitap9.asm: -------------------------------------------------------------------------------- 1 | ;nhap vao hai chuoi so roi tinh tong 2 | .model small 3 | .stack 50 4 | .data 5 | so db 10,0, 10 dup($) 6 | muoi dw 10 7 | xuong db 10,13,'Ket Qua: $' 8 | B1 Dw 0 9 | b2 dw 0 10 | tb1 db 10,13, 'Nhap vao so dau: $' 11 | tb2 db 10,13, 'Nhap vao so thu 2: $' 12 | .code 13 | main proc 14 | mov ax,@data 15 | mov ds,ax 16 | ;nhap xau 17 | lea dx,tb1 18 | mov ah,9 19 | int 21h 20 | xor cx,cx 21 | lea dx,so 22 | mov ah,0Ah 23 | int 21h 24 | call xulichuoi 25 | mov b1,dx 26 | ;xuong hang 27 | mov ah,9 28 | lea dx,tb2 29 | int 21h 30 | 31 | 32 | mov ah,0Ah 33 | lea dx,so 34 | int 21h 35 | 36 | mov ah,9 37 | lea dx,xuong 38 | int 21h 39 | 40 | call xulichuoi 41 | mov b2,dx 42 | 43 | ;cong b1 va b2 vao dx 44 | mov dx,b2 45 | add dx,b1 46 | 47 | mov ax,dx 48 | xor cx,cx 49 | Lapchia: 50 | xor dx,dx 51 | div muoi 52 | add dx,30h 53 | push dx 54 | inc cx 55 | ;xor ah,ah 56 | cmp ax,0 57 | jne Lapchia 58 | Hienthi: 59 | pop dx 60 | mov ah,2 61 | int 21h 62 | loop Hienthi 63 | 64 | mov ah,4Ch 65 | int 21h 66 | 67 | main endp 68 | 69 | xulichuoi PROC 70 | xor dx,dx 71 | xor cx,cx 72 | lea si,so + 2 73 | mov cl,[so+1] 74 | Lap: 75 | mov ax,dx 76 | xor bx,bx 77 | mov bl,[si] 78 | sub bl,30h 79 | mul muoi 80 | add ax,bx 81 | mov dx,ax 82 | inc si 83 | loop Lap 84 | ret 85 | xulichuoi ENDP 86 | 87 | end main -------------------------------------------------------------------------------- /BaiTap/baitap15.asm: -------------------------------------------------------------------------------- 1 | ;Nhap vao so va tinh giai thua 2 | .model small 3 | .stack 50 4 | .data 5 | muoi dw 10 6 | xuong db 10,13,'$' 7 | tb1 db 'Nhap so khong am be hon hoac bang 8: $' 8 | .code 9 | main proc 10 | mov ax,@data 11 | mov ds,ax 12 | 13 | lea dx, tb1 14 | mov ah,9 15 | int 21h 16 | 17 | mov ah,01h 18 | int 21h 19 | 20 | sub al,30h 21 | xor cx,cx 22 | mov cl,al 23 | 24 | lea dx,xuong 25 | mov ah,09 26 | int 21h 27 | 28 | mov ax,1 29 | mov bx,1 30 | Giaithua: 31 | Mul bx 32 | inc bx 33 | cmp bx,cx 34 | jle giaithua 35 | xor cx,cx 36 | Lappush: 37 | xor dx,dx 38 | div muoi 39 | add dx,30h 40 | push dx 41 | inc cx 42 | cmp ax,0 43 | jne Lappush 44 | Hienthi: 45 | pop dx 46 | mov ah,2 47 | int 21h 48 | Loop HienThi 49 | 50 | mov ah,4Ch 51 | int 21h 52 | main endp 53 | end main -------------------------------------------------------------------------------- /Dectobinsimple.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | so db 10,0,10 dup($) 5 | muoi db 10 6 | xuong db 10, 13, '$' 7 | b1 dw 0 8 | .code 9 | main proc 10 | mov ax,@data 11 | mov ds,ax 12 | 13 | mov ah,0Ah 14 | lea dx, so 15 | int 21h 16 | 17 | lea dx, xuong 18 | mov ah, 9 19 | int 21h 20 | 21 | lea si, so +2 22 | mov cl, [so + 1] 23 | Lap: 24 | mov ax,b1 25 | xor bx, bx 26 | mov bl,[si] 27 | sub bl,30h 28 | mul muoi 29 | add ax,bx 30 | mov b1,ax 31 | inc si 32 | loop Lap 33 | mov bx,b1 34 | mov cx,16 35 | tobin: 36 | mov dl,30h 37 | shl bx,1 38 | adc dl,0 39 | mov ah,2 40 | int 21h 41 | loop tobin 42 | mov ah, 4Ch 43 | int 21h 44 | main endp 45 | end main 46 | -------------------------------------------------------------------------------- /Hienthibin.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | xuong db 10,13,'$' 5 | count db 0 6 | muoi db 10 7 | .code 8 | Main proc 9 | mov ax,@data 10 | mov ds,ax 11 | 12 | xor bx,bx 13 | mov cx,16 14 | Lap: 15 | mov ah,1 16 | int 21h 17 | sub al,30h 18 | shl bx,1 19 | add bl,al 20 | add count,al 21 | Loop Lap 22 | 23 | lea dx,xuong 24 | mov ah,9 25 | int 21h 26 | 27 | mov cx,16 28 | Lap1: 29 | mov dl,30h 30 | shl bx,1 31 | adc dl,0 32 | mov ah,2 33 | int 21h 34 | loop Lap1 35 | xor ax,ax 36 | mov al,count 37 | xor cx,cx 38 | Lap2: 39 | xor dx,dx 40 | 41 | div muoi 42 | add ah,30h 43 | mov dl,ah 44 | push dx 45 | inc cx 46 | xor ah,ah 47 | cmp ax,0 48 | jne lap2 49 | hienthi: 50 | pop dx 51 | mov ah,2 52 | int 21h 53 | loop hienthi 54 | mov ah,4ch 55 | int 21h 56 | main endp 57 | end main -------------------------------------------------------------------------------- /Mang.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | str1 DB 10,13, 'Nhap vao chu cai:$' 5 | str2 DB 10,13, '$' 6 | ktu DB ? 7 | mang DB 5 dup(?) ;10 phan tu co gia tri ? 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds,ax 12 | ;Nhap mang 13 | lea SI,ktu ;dua con tro si ve phan tu dau tien cua mang 14 | mov cx,10 15 | Lap: 16 | mov ah,1 17 | int 21h 18 | mov [si],al; 19 | inc si 20 | loop Lap 21 | ;Xuong dong 22 | Lea Dx,str2 23 | mov ah,9 24 | int 21h 25 | ;Xuat mang 26 | lea Si,mang 27 | mov cx,10 28 | Lap2: 29 | mov dl,[si] 30 | mov ah,2 31 | int 21h 32 | inc si 33 | Loop Lap2 34 | 35 | mov ah,4CH 36 | int 21h 37 | 38 | main endp 39 | end main 40 | -------------------------------------------------------------------------------- /Nhapstring.asm: -------------------------------------------------------------------------------- 1 | .MODEL Small 2 | 3 | .STACK 100h 4 | 5 | .DATA 6 | prompt DB "Enter a string: $" 7 | prompt2 DB 10, 13, "You typed: $" 8 | inBuff DB 21, ?, 21 DUP('$') 9 | 10 | .CODE 11 | 12 | Start: 13 | mov ax, @data 14 | mov ds, ax 15 | mov ah, 09h 16 | lea dx, prompt 17 | int 21h 18 | 19 | mov ah, 0Ah 20 | lea dx, inBuff 21 | int 21h 22 | 23 | mov ah, 09h 24 | lea dx, prompt2 25 | int 21h 26 | 27 | lea dx, [inBuff + 2] 28 | int 21h 29 | 30 | mov ax, 4c00h ; 31 | int 21h ; 32 | END Start 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # code ASM 2 | Bài tập assembly 3 | Đồ Án Lập Trình Hệ Thống 4 | Bài Tập 1 (Assembly) 5 | 6 | 1. Viết chương trình sử dụng hàm 7, ngắt 21h để nhận 1 ký tự từ bàn phím, dùng 1 7 | biến để lưu trữ ký tự nhận được (do sinh viên tự đặt tên biến), sau đó sử dụng hàm 8 | 2, ngắt 21h để in ra màn hình ký tự nhận được đang lưu trong biến ấy. Chương 9 | trình phải có đủ các câu thông báo nhập và xuất. 10 | Ví dụ: Hay go 1 phim: B 11 | Ky tu nhan duoc la: B 12 | 13 | 2. Làm lại chương trình bài 1 sao cho không cần sử dụng biến để lưu trữ ký tự mà 14 | kết quả chạy chương trình vẫn không thay đổi. 15 | 16 | 3. Viết chương trình nhận 1 ký tự từ bàn phím, sau đó in ra màn hình ký tự kế 17 | trước và kế sau của ký tự vừa nhập 18 | Ví dụ: Hay go 1 phim: B 19 | Ky tu ke truoc : A 20 | Ky tu ke sau : C 21 | 22 | 4. Viết chương trình cho phép nhập từ bàn phím tên của 1 người, sao đó in ra màn 23 | hình chuỗi có dạng như sau: 24 | Xin chao 25 | Ví dụ: Khi chạy chương trình, nhập vào là: Nguyen Van A 26 | Chuỗi in ra màn hình sẽ là: Xin chao Nguyen Van A 27 | 5. Viết chương trình cho nhập 1 ký tự từ màn hình và xuất câu thông báo tương ứng 28 | sau: 29 | - Nếu ký tự nhập là ‘S’ hay ‘s’ thì in ra “Good morning!” 30 | - Nếu ký tự nhập là ‘T’ hay ‘t’ thì in ra “Good Afternoon!” 31 | - Nếu ký tự nhập là ‘C’ hay ‘c’ thì in ra “Good everning!” 32 | 33 | 6. Viết chương trình nhập từ bàn phím 1 ký tự thường. Sau đó in ra màn hình lần lượt 34 | các ký tự từ ký tự nhận được đến 'z' sao cho giữa các ký tự có 1 khoảng trống. 35 | 36 | 7. Không dùng hàm 0Ah/21h, hãy dùng lệnh lặp để viết chương trình nhập vào 1 37 | chuỗi ký tự. Sau khi nhập xong đếm xem chuỗi có bao nhiêu ký tự. In ra màn hình 38 | chuỗi nhận được và số ký tự có trong chuỗi. 39 | Ví dụ: S = "Hello world !" ==> Số kí tự trong chuỗi là 13. 40 | 41 | 8. Viết chương trình cho phép nhập vào một chuỗi bất kỳ. Sau đó: 42 | - Đổi tất cả ký tự thường thành ký tự hoa và in ra màn hình. 43 | - Đổi tất cả ký tự hoa thành ký tự thường và in ra màn hình. 44 | Ví dụ: S = ‘weLcOme To AssEmblY’ 45 | In ra: welcome to assembly - WELCOME TO ASSEMBLY 46 | 47 | 9. Nhập vào 2 chuỗi số, đổi 2 chuỗi thành số, sau đó cộng hai số, đổi ra chuỗi và xuất 48 | chuỗi tổng. 49 | Ví dụ: S1 = "123" => N1 = 123 50 | S2 = "456" => N2 = 456 51 | N = N1 + N2 = 123 + 456 = 579 => S = "579" (xuất S ra màn hình) 52 | 53 | 10. Nhập 2 số nguyên dương A, B. Tính A/B, A*B (không dùng lệnh DIV, MUL) và 54 | in ra màn hình kết quả. 55 | Ví dụ: A=18, B=3 56 | Tính A/B: 18 - 3 - 3 - 3 - 3 - 3 - 3 = 0, vậy A/B = 6 (tổng trừ B cho đến khi A = 0). 57 | Tính A*B = 18 + 18 + 18 = 54 58 | 11. Viết chương trình nhập 2 số nhị phân 16 bit A và B. Sau đó in ra màn hình các kết 59 | quả ở dạng nhị phân: A + B, A – B, A and B, A or B. 60 | Ví dụ: Nhập số nhị phân A: 10101010 61 | Nhập số nhị phân B: 01010101 62 | A + B = 11111111 A – B = 01010101 63 | A and B = 00000000 A or B = 11111111 64 | 65 | 12. Viết chương trình nhập 1 ký tự từ bàn phím, sau đó in ra màn hình mã ASCII của 66 | ký tự nhận được ở dạng thập lục phân, thập phân và nhị phân. 67 | Ví dụ: Nhập 1 ký tự: A 68 | Mã ASCII dạng Hex: 41h 69 | Mã ASCII dạng Dec: 65 70 | Mã ASCII dạng Bin: 01000001b 71 | 72 | 13. Viết lại chương trình bài 11 nhưng 2 số A và B được nhập theo dạng thập lục 73 | phân. Các kết quả được in ra màn hình ở dạng nhị phân. 74 | 75 | 14. Viết lại chương trình bài 11 nhưng 2 số A và B được nhập theo dạng thập phân. 76 | In các kết quả ở dạng thập phân: A + B, A – B. 77 | 78 | 15. Viết chương trình tính giai thừa n! Với n là số nguyên dương nhập từ bàn phím. In 79 | kết quả ra màn hình ở dạng thập phân. Cho biết, khả năng của 8086 tính được n 80 | lớn nhất là bao nhiêu? 81 | 16. Viết chương trình tính ước số chung lớn nhất của 2 số a và b! Với a, b là số nguyên dương nhập từ bàn phím. In kết quả ra màn hình ở dạng thập phân. 82 | 83 | 17. Viết chương trình nhập 1 chuỗi ký tự. In chuổi dã nhập theo thứ tự ngược. Chương trình có dạng. 84 | Nhập ký tự: abcdef 85 | Chuổi ngược: fedcba 86 | 87 | 18. Nhập vào một dãy số, tính trung bình cộng của dãy số đó. 88 | Nhập vào dãy số: 1 3 5 6 8 89 | Trung bình cộng: (1+3+5+6+8)/5 = 4 90 | 91 | 19. Nhập vào một số, tính tổng các chữ số của một số 92 | Nhập vào số: 1234 93 | Tổng các chữ số: 10 94 | 95 | 20. Nhập vào n, kiểm tra n có phải là số hoàn hảo. Số hoàn hảo là số có tổng các ước số tự nhiên không kể chính nó bằng nó 96 | Ví dụ: 6 = 1 + 2 + 3 => 6 là số hoàn hảo 97 | 98 | -------------------------------------------------------------------------------- /VD1file.asm: -------------------------------------------------------------------------------- 1 | ;vi du ve file 1 2 | ;tao 1 tep moi,doc du lieu tu ban phim va luu vao tep 3 | .model small 4 | .stack 50 5 | .data 6 | controf dw ? 7 | tenf db 'ab.txt',0 8 | buff db ? 9 | 10 | .code 11 | main proc 12 | mov ax, @data 13 | mov ds, ax 14 | 15 | mov cx,0 ; cx = 0 binh thuong, 1 chi doc 2 an 4 tap tin he thong 16 | lea dx,tenf 17 | mov ah,3Ch 18 | int 21h 19 | mov controf, ax 20 | 21 | Lapdoc: 22 | xor dx,dx 23 | mov ah,1 24 | int 21h 25 | cmp al,13 26 | je thoat 27 | mov buff,al 28 | lea dx,buff 29 | mov bx,controf 30 | mov cx,1 31 | mov ah,40h 32 | int 21h 33 | jmp Lapdoc 34 | 35 | thoat: 36 | mov ah,3Eh 37 | mov bx,controf 38 | int 21h 39 | 40 | mov ah,4Ch 41 | int 21h 42 | main endp 43 | end main -------------------------------------------------------------------------------- /bai1-11.asm: -------------------------------------------------------------------------------- 1 | ;Nhap 2 so nhi phan 16 bit A,B 2 | ;In ra ket qua o dang nhi phan A+B, A-B, A and B, A or B 3 | 4 | .model small 5 | .stack 50h 6 | .data 7 | tbA db "Nhap 2 so nhi phan 16 bit A,B:",10,13,"A:$" 8 | tbB db 10,13,"B:$" 9 | x db 17,0,17 dup('$') 10 | y db 17,0,17 dup('$') 11 | s1 db 16 dup('0'),'$' 12 | tb1 db 10,13,"A+B=$" 13 | .code 14 | ;khoi tao ds: 15 | mov ax,@data 16 | mov ds,ax 17 | 18 | xor cx,cx 19 | ;in ra tbA: 20 | mov ah,9 21 | lea dx,tbA 22 | int 21h 23 | 24 | ;nhap A luu vao chuoi x: 25 | mov ah,10 26 | lea dx,x 27 | int 21h 28 | 29 | ;in ra tbB: 30 | mov ah,9 31 | lea dx,tbB 32 | int 21h 33 | 34 | ;nhap B luu vao chuoi y: 35 | mov ah,10 36 | lea dx,y 37 | int 21h 38 | 39 | ;sao chep chuoi y vao s1 40 | lea si,y+2 ;si tro den dau chuoi y 41 | lea di,s1 ;di tro den dau chuoi s1 42 | mov cx,16 ;lap 16 lan 43 | saochep1: 44 | mov bl,[si] ; 45 | mov [di],bl ;gan s1[di]=y[si] 46 | inc si 47 | inc di 48 | loop saochep1 49 | ;sau do lay x + s1 50 | lea si,x+17 ;si tro den cuoi chuoi x 51 | lea di,s1+15 ;di tro den cuoi chuoi s1 52 | mov cx,16 ;lap 16 lan 53 | mov bl,0 ;bl bien nho 54 | lap1: 55 | mov al,bl ;khoi tao al=bl 56 | add al,[si] ; 57 | sub al,48 ; 58 | add al,[di] ; 59 | sub al,48 ;al=bl+x[si]-48+s1[di]-48 60 | ;x[si]-48 de chuyen ki tu sang so 61 | ;s1[di]-48 de chuyen ki tu sang so 62 | 63 | cmp al,3 64 | jz bang3 65 | cmp al,2 66 | jz bang2 67 | cmp al,1 68 | jz bang1 69 | mov [di],'0' ;mac dinh neu al=0 thi gan s1[di]=0 70 | mov bl,0 ;va so du bl=0 71 | jmp thoat1 72 | 73 | 74 | 75 | bang3: ;neu al=3 76 | mov [di],'1' ;gan s1[di]=1 77 | mov bl,1 ;va so du bl=1 78 | jmp thoat1 79 | bang2: ;neu al=2 80 | mov [di],'0' ;gan s1[di]=0 81 | mov bl,1 ;va so du bl=1 82 | jmp thoat1 83 | bang1: ;neu al=1 84 | mov [di],'1' ;gan s1[di]=1 85 | mov bl,0 ;va so du bl=0 86 | thoat1: 87 | dec si 88 | dec di 89 | loop lap1 90 | 91 | ;in ra s1 92 | mov ah,9 93 | lea dx,tb1 94 | int 21h 95 | lea dx,s1 96 | int 21h 97 | 98 | ;ket thuc chuong trinh: 99 | mov ah,4ch 100 | int 21h 101 | end -------------------------------------------------------------------------------- /btmovsb.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | b1 db 'Chao$' 5 | b2 db 5 dup(0) 6 | .code 7 | main PROC 8 | mov ax, data 9 | mov es,ax 10 | mov ds,ax 11 | 12 | ;cld 13 | lea SI,b1 14 | lea di,b2 15 | mov cx,5 16 | rep movsb 17 | 18 | 19 | mov ah,9 20 | lea dx,b2 21 | int 21h 22 | mov ah,4Ch 23 | int 21h 24 | main ENDP 25 | END MAIN -------------------------------------------------------------------------------- /dectobin.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | tb1 db 'Nhap so (>2 chu so): $' 5 | tb2 db 10,13,'Chuyen sang he nhi phan: $' 6 | tb3 db 10,13,'Nhap lai: $' 7 | xuongdong db 10,13,'$' 8 | nhan db 10 9 | s1 dw ? 10 | s2 dw ? 11 | 12 | .code 13 | main proc 14 | mov ax,@data 15 | mov ds,ax 16 | 17 | xor cx,cx 18 | mov ah,9 19 | lea dx, tb1 20 | int 21h 21 | 22 | Nhap: 23 | mov ah,1 24 | int 21h 25 | inc cx 26 | cmp al,13 27 | je enter 28 | 29 | sub al,30h 30 | xor bx,bx 31 | mov bl,al 32 | mov ax,s1 33 | MUL nhan 34 | add ax,bx 35 | mov s1,ax 36 | jmp nhap 37 | 38 | enter: 39 | cmp cx,3 40 | jb loi 41 | ja inra 42 | 43 | Loi: 44 | mov ah,9 45 | lea dx,tb3 46 | int 21h 47 | xor cx,cx 48 | mov s1,0 49 | jmp nhap 50 | 51 | inra: 52 | lea dx,xuongdong 53 | mov ah,9 54 | int 21h 55 | xor ax,ax 56 | xor bx,bx 57 | 58 | mov ah,9 59 | lea dx,tb2 60 | int 21h 61 | 62 | mov bx,s1 63 | mov cx,16 64 | mov s2,0 65 | 66 | lap: 67 | SHL bx,1 68 | inc s2 69 | jc inra1 70 | mov ah,2 71 | mov dl,'0' 72 | int 21h 73 | jmp hienthi 74 | inra1: 75 | mov ah,2 76 | mov dl,'1' 77 | int 21h 78 | 79 | hienthi: 80 | cmp s2,4 81 | jb lap1 82 | mov ah,2 83 | mov dl,' ' 84 | int 21h 85 | mov s2,0 86 | 87 | lap1: 88 | loop Lap 89 | 90 | mov ah,4ch 91 | int 21h 92 | endp 93 | end main -------------------------------------------------------------------------------- /diem.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | diem db 3 5 | xs db 'Xuat sac$' 6 | gi db 'Gioi$' 7 | tb db 'Trung binh$' 8 | yk db 'Kem$' 9 | .code 10 | 11 | main proc 12 | mov ax,@data 13 | mov ds,ax 14 | 15 | cmp diem,9 16 | jae xuatsac 17 | cmp diem,8 18 | jae gioi 19 | cmp diem,5 20 | jae trungbinh 21 | 22 | lea dx,yk 23 | jmp exit 24 | 25 | xuatsac: 26 | lea dx,xs 27 | jmp exit 28 | 29 | gioi: 30 | lea dx,gi 31 | jmp exit 32 | 33 | trungbinh: 34 | lea dx,tb 35 | jmp exit 36 | 37 | exit: 38 | mov ah,9 39 | int 21h 40 | 41 | mov ah,4Ch 42 | int 21h 43 | main endp 44 | end main -------------------------------------------------------------------------------- /howtogit.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/can-ne/codeASM/7c5f3193d819f9deb18902da8723f182e21230e9/howtogit.txt -------------------------------------------------------------------------------- /laytungchuso.asm: -------------------------------------------------------------------------------- 1 | .model small ;chuong trinh in mot so tu thanh ghi ax 2 | .stack 50 3 | .data 4 | chia8 db 10 5 | chia16 dw 10 6 | mang db 30, 0, 30 dup('$') 7 | .code 8 | main proc 9 | mov ax, @data 10 | mov ds,ax 11 | 12 | mov ax,2517 ;dua so vao thanh ghi ax 13 | xor cx,cx ;gan cx = 0 de dem so ky tu so 14 | Lapchia: 15 | xor dx,dx ;dua dx =0 16 | div chia8 ;chia cho ax cho 10 o dang 8 bit ah chua so du al chua thuong 17 | 18 | add ah,30h ;bien so trong ah thanh ky tu so 19 | mov dl,ah ; dua ah vao dx 20 | push dx ;dua dx vao ngang xep 21 | inc cx ;them mot chu so la cong them 22 | xor ah,ah ;xoa ah 23 | cmp ax,0 ;neu thuong bang 0 thi dung lai 24 | jne Lapchia 25 | 26 | Dochienthi: ;luc nay cx co gia tri la so ky tu 27 | pop dx ;lay tung ky tu so in ra 28 | mov ah,2 29 | int 21h 30 | loop Dochienthi 31 | ;vi du 32 | ; ax = 2517 33 | ;vong lap dau tien 34 | ; div thi ah =7 + 30h =>> '7' dua vao dl, de vao ngan xep 7 , tang dem cx len 1 35 | ;al con la 251d 36 | ;phai xoa ah khong ax =07FBh xoa ah =>> ax = 251d 37 | mov ah,4CH 38 | int 21h 39 | 40 | main endp 41 | end main -------------------------------------------------------------------------------- /mycode1.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | str1 DB 10,13, 'Chao ban$' 5 | .code 6 | main proc 7 | mov ax, @data 8 | mov ds,ax 9 | 10 | 11 | mov cx,10 12 | Nhan1: 13 | mov ah,09h 14 | mov dx,offset str1 15 | int 21h 16 | loop Nhan1 17 | 18 | mov ah,4CH 19 | int 21h 20 | 21 | 22 | 23 | main endp 24 | end main -------------------------------------------------------------------------------- /mycode2.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | str1 DB 10,13, 'Nhap ky tu:$' 5 | str2 DB 10,13, 'Ky tu vua nhap:$' 6 | ktu DB ? 7 | .code 8 | main proc 9 | mov ax, @data 10 | mov ds,ax 11 | 12 | mov ah,09h 13 | lea dx,str1 14 | int 21h 15 | 16 | 17 | mov ah,01h 18 | int 21h 19 | mov ktu,al 20 | 21 | mov ah, 09h 22 | mov dx,offset str2 23 | int 21h 24 | 25 | 26 | mov ah,2 27 | mov dl,ktu 28 | int 21h 29 | 30 | mov ah,4CH 31 | int 21h 32 | 33 | main endp 34 | end main -------------------------------------------------------------------------------- /nhapst.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100h 3 | .data 4 | str1 DB 10,13, 'Nhap vao chu cai:$' 5 | str2 DB 10,13, 'Da nhap: $' 6 | mang DB 30, ?, 30 dup('$'), '$' 7 | .code 8 | main proc 9 | mov ax, @data 10 | mov ds,ax 11 | 12 | mov ah,0Ah 13 | lea dx,mang 14 | int 21h 15 | 16 | mov ah,9 17 | 18 | lea dx,str2 19 | int 21h 20 | 21 | lea dx,[mang + 2] 22 | int 21h 23 | 24 | mov ah,4CH 25 | int 21h 26 | 27 | main endp 28 | end main 29 | -------------------------------------------------------------------------------- /printday.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | chia10 dw 10 5 | nam dw ? 6 | thang dw ? 7 | ngay dw ? 8 | thu dw ? 9 | ngaytam db ? 10 | .code 11 | printday macro thoigian 12 | mov ax,thoigian 13 | xor cx,cx 14 | local lapchia 15 | local docstack 16 | lapchia: 17 | xor dx,dx 18 | div chia10 19 | add dx,30h 20 | push dx 21 | inc cx 22 | cmp ax,0 23 | jne lapchia 24 | docstack: 25 | pop dx 26 | mov ah,2 27 | int 21h 28 | loop docstack 29 | printday endm 30 | main proc 31 | mov ax,@data 32 | mov ds,ax 33 | 34 | mov ah,2ah 35 | int 21h 36 | 37 | mov nam,cx 38 | 39 | mov ngaytam,dl 40 | 41 | mov dl,dh 42 | xor dh,dh 43 | mov thang,dx 44 | 45 | xor dh,dh 46 | mov dl,ngaytam 47 | mov ngay,dx 48 | xor ah,ah 49 | add ax,1 50 | mov thu,ax 51 | printday nam 52 | printday thang 53 | printday ngay 54 | printday thu 55 | 56 | mov ah,4ch 57 | int 21h 58 | main endp 59 | end main 60 | -------------------------------------------------------------------------------- /stringtonumbe.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | so db 10,0, 10 dup($) 5 | nhan db 10 6 | xuong db 10,13,'$' 7 | B Dw 0 8 | .code 9 | main proc 10 | mov ax,@data 11 | mov ds,ax 12 | 13 | mov ah,0Ah 14 | lea dx,so 15 | int 21h 16 | 17 | mov ah,9 18 | lea dx,xuong 19 | int 21h 20 | 21 | lea si,so + 2 22 | mov cl,[so + 1] 23 | Lap: 24 | mov Ax,b 25 | xor bx,bx 26 | mov bl,[si] 27 | sub bl,48 28 | mul nhan 29 | add ax,bx 30 | mov b,ax 31 | inc si 32 | Loop Lap 33 | mov ah,4Ch 34 | int 21h 35 | 36 | main endp 37 | end main -------------------------------------------------------------------------------- /vd2file.asm: -------------------------------------------------------------------------------- 1 | ;vi du ve file 2 2 | ;tao 1 tep moi,doc du lieu tu ban phim va luu vao tep 3 | .model small 4 | .stack 50 5 | .data 6 | controf dw ? 7 | tenf db 'ab.txt',0 8 | buff db 100,0, 100 dup('$') 9 | 10 | .code 11 | main proc 12 | mov ax, @data 13 | mov ds, ax 14 | 15 | mov cx,0 ; cx = 0 binh thuong, 1 chi doc 2 an 4 tap tin he thong 16 | lea dx,tenf 17 | mov ah,3Ch 18 | int 21h 19 | mov controf, ax 20 | 21 | mov ah,0Ah 22 | lea dx, buff 23 | int 21h 24 | 25 | xor cx,cx 26 | lea dx, buff + 2 27 | mov cl, [buff + 1] 28 | mov bx, controf 29 | mov ah,40h 30 | int 21h 31 | 32 | mov ah,3Eh 33 | mov bx,controf 34 | int 21h 35 | 36 | mov ah,4Ch 37 | int 21h 38 | main endp 39 | end main -------------------------------------------------------------------------------- /vd3file.asm: -------------------------------------------------------------------------------- 1 | ;vi du ve file 3 2 | ;tao 1 tep moi,doc du lieu tu ban phim va luu vao tep 3 | .model small 4 | .stack 50 5 | .data 6 | controf dw ? 7 | tenf db 'ab.txt',0 8 | buff db 5 dup('$') 9 | 10 | .code 11 | main proc 12 | mov ax, @data 13 | mov ds, ax 14 | 15 | mov cx,0 ; cx = 0 binh thuong, 1 chi doc 2 an 4 tap tin he thong 16 | lea dx,tenf 17 | mov ah,3Ch 18 | int 21h 19 | mov controf, ax 20 | 21 | Lea Si,buff 22 | xor cx,cx 23 | Lapnhap: 24 | mov ah,1 25 | int 21h 26 | cmp al,0Dh 27 | je thoat 28 | mov [si], al 29 | inc si 30 | inc cx 31 | cmp cx,5 32 | je thoat 33 | jmp Lapnhap 34 | 35 | thoat: 36 | ;cx da duoc tang o tren 37 | lea dx, buff 38 | mov bx, controf 39 | mov ah,40h 40 | int 21h 41 | 42 | mov ah,3Eh 43 | mov bx,controf 44 | int 21h 45 | 46 | mov ah,4Ch 47 | int 21h 48 | main endp 49 | end main -------------------------------------------------------------------------------- /xulifile.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 50 3 | .data 4 | tb1 db 'Da ghi xong$' 5 | tb2 db 'welcome' 6 | tenf db 'w2a.txt',0 7 | thef dw ? 8 | .code 9 | main proc 10 | mov ax,@data 11 | mov ds, ax 12 | 13 | mov ah,3Ch 14 | lea dx,tenf 15 | mov cx,0 16 | int 21h 17 | mov thef,ax 18 | 19 | mov ah,40h ;lenh ghi file 20 | mov bx,thef;dua con tro file vao 21 | mov cx,7 ;so ky tu ghi vao file 22 | lea dx,tb2; thu can ghi vao file 23 | int 21h 24 | 25 | lea dx,tb1 26 | mov ah,9 27 | int 21h 28 | 29 | mov ah,3Eh 30 | mov bx,thef 31 | int 21h 32 | 33 | mov ah,4Ch 34 | int 21h 35 | main endp 36 | end main --------------------------------------------------------------------------------