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
- Color db 4 ; mau do
- Start:
- Mov AH,0h ; thiet lap che do do hoa
- Mov AL,12h ; VGA mode
- Int 10h
- Mov AX, 0
- Mov AH, 1
- int 21H
- mov st, AX
- mov on, AX
- Mov AX, 0
- Mov AH, 1
- int 21H
- mov x2, AX
- Mov AX, 0
- Mov AH, 1
- int 21H
- mov y2, AX
- Mov AX, 0
- Mov AH, 1; Cho 1 phim go vao
- Int 21h
- 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 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 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 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
- END:
- mov ah, 4CH
- int 21h
- End Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement