Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .MODEL Small
- .CODE
- org 100h
- Jmp Start
- st dw 100
- y2 dw 120
- x2 dw 120
- on dw 100
- ent db 13, 13, 13, 10, '$'
- Color db 4 ; mau do
- hcnd db 'Nhap do dai canh doc: $'
- hcnn db 'Nhap do dai canh ngang: $'
- tgc db 'Nhap do dai chieu cao: $'
- th db 'Nhap do dai duong cheo: $'
- Start:
- Mov AH,0h ; thiet lap che do do hoa
- Mov AL,12h ; VGA mode
- Int 10h
- Mov AX, 0
- Mov AH, 1; Cho 1 phim go vao
- Int 21h
- Push AX
- Mov AH, 9
- Lea DX, ent
- Int 21H
- Mov AX, 0
- Pop AX
- ;Mov DL, AL
- ;Mov AH,2
- ;Int 21H
- Cmp AL, '1'
- Je RE
- Cmp AL, '2'
- Je TRI
- Cmp AL, '3'
- Je RHOM
- Cmp AL, '#'
- Je END
- Jmp Start
- RE:
- Call Rectangle
- Jmp Start
- TRI:
- Call Triangle
- Jmp Start
- RHOM:
- Call Rhombus
- Jmp Start
- ;Ve hinh chu nhat
- Rectangle Proc
- Mov AH, 9
- Lea DX, hcnd
- Int 21H
- Call input
- Mov y2, AX
- Add y2, 100
- Mov AH, 9
- Lea DX, hcnn
- Int 21H
- Call input
- Mov x2, AX
- Add x2, 100
- Mov CX,x2
- Sub CX,st
- Mov SI,st
- Mov DI,st
- ; Ve canh tren
- TopR:
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Inc DI ;
- Loop TopR
- Mov CX, y2
- Sub CX, st
- Mov SI, st
- ; Ve canh 2 canh ben
- SideR:
- Mov DI, st
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Mov DI, x2
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Inc SI
- Loop SideR
- Mov CX, x2
- Sub CX, st
- Mov SI, y2
- Mov DI, st
- ; Ve canh duoi
- BotR:
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Inc DI ;
- Loop BotR
- mov ah, 8
- int 21h
- Mov AH,0
- Mov AL,2
- Int 10h
- Ret
- Rectangle Endp
- ;Ve hinh tam giac
- Triangle Proc
- Mov st, 100
- Mov x2, 100
- Mov AH, 9
- Lea DX, tgc
- Int 21H
- Call input
- Mov y2, AX
- Add y2, 100
- Mov CX, y2
- Sub CX, st
- Mov SI, st
- ;Ve 2 canh ben
- SideT:
- Mov DI, st
- Sub st, 1
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Mov DI, x2
- Add x2, 1
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Inc SI
- Loop SideT
- Mov CX, x2
- Sub CX, st
- Mov SI, y2
- Mov DI, st
- ; Ve canh duoi
- BotT:
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Inc DI ;
- Loop BotT
- Mov ah, 8
- Int 21h
- Mov AH,0
- Mov AL,2
- Int 10h
- Ret
- Triangle Endp
- Rhombus proc
- Mov st, 100
- Mov x2, 100
- Mov AH, 9
- Lea DX, th
- Int 21H
- Call input
- Mov y2, AX
- Add y2, 100
- Mov CX, y2
- Sub CX, st
- Mov SI, st
- ;Ve 2 canh ben tren
- TopSideRH:
- Mov DI, st
- Sub st, 1
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Mov DI, x2
- Add x2, 1
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Inc SI
- Loop TopSideRH
- Mov CX, on
- Sub CX, st
- Add CX, 1
- ;Mov SI, y2
- ; Ve 2 canh ben duoi
- BotSideRH:
- Mov DI,st
- Add st, 1
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Mov DI, x2
- Sub x2, 1
- Call DrawPixel ; goi chuong trinh con ve diem anh
- Inc SI
- Loop BotSideRH
- mov ah, 8
- int 21h
- Mov AH,0
- Mov AL,2
- Int 10h
- Ret
- Rhombus Endp
- ;To mau 1 pixel
- DrawPixel Proc
- Push AX
- Push CX
- Push DX
- Mov DX, SI
- Mov CX,DI
- Mov AL, Color
- Mov AH,0CH
- Int 10h
- Pop DX
- Pop CX
- Pop AX
- Ret
- DrawPixel Endp
- input Proc
- Push bx
- Push cx
- Push dx
- STA:
- Mov ah, 2
- Xor bx, bx
- Xor cx, cx
- Mov ah, 1
- Int 21h
- Cmp al, '-'
- Je SUBT
- Cmp al, '+'
- Je ADDN
- Jmp CON
- SUBT:
- Mov cx, 1
- ADDN:
- Int 21h
- CON:
- Cmp al, '0'
- Jnge NOTN ; khong lop hon hoac bang
- Cmp al, '9'
- Jnle NOTN ; Khong nho hon hoac bang
- And ax, 000fh ; doi thanh chu so
- Push ax ; cat vao ngan xep
- Mov ax, 10
- Mul bx ; ax = tong*10
- Mov bx, ax
- Pop ax
- Add bx, ax ; tong = tong*10 + so
- Mov ah, 1
- Int 21h
- Cmp al, 13 ; da enter chua?
- Jne CON ; nhap tiep
- Mov ax, bx ; chuyen KQ ra ax
- Or cx, cx ; co phai so am khong
- Je O
- Neg ax ; neu la so am thi doi ax ra so am
- O:
- Pop dx
- Pop cx
- Pop bx
- Ret
- NOTN:
- Mov ah, 2
- Mov dl, 0dh
- Int 21h
- Mov dl, 0ah
- Int 21
- Jmp STA
- Ret
- input Endp
- END:
- Mov ah, 4CH
- Int 21h
- End Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement