Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .8086
- .model small
- .stack 2048
- dseg segment para public 'data'
- ;this is the total size of flag, but somewhere above, you will see that
- ;I just decrement the left, right and middle column, and then
- ;when I jump between them, I use that value, without subtract by 2
- ;Remember, columns are "words" (theory) so, insted divide by 2 and multiply
- ;again, I just leave it as it is
- ;total size
- maxColumns dw 69 ;includes left, right and middle columns
- maxLines dw 19 ;same with lines
- toNextLine dw ?
- dseg ends
- cseg segment para public 'code'
- assume cs:cseg, ds:dseg
- Main proc
- mov ax, dseg
- mov ds, ax
- mov ax,0b800h ;B800 is the video memory adress
- mov es,ax ;move that adress to es
- ;es stands for "extra segment"
- ;code to clear screen (shared before)
- mov bx, ' ' ;space to bx. A space is what we will write in screen (to clean)
- xor di, di ;di -> 0
- mov cx, 24*80 ;24*80 is the size of window! 24 lines,80 columns
- clear:
- mov es:[di], bx ;move the space to video adreess (in other words, write a space on screen)
- add di, 2 ;every video adress have a size of word, so let's add 2
- loop clear ;repeat until cx = 0, In every loop, cx is decremented
- ;draw the flag
- mov bl, 00100000b ;[0][010][0000]b -> binary (*see below)
- mov bh, '*' ;this is the char we will print
- xor di, 320 ;the position we will start
- xor si, 320 ;in this case we will start e second line
- mov cx, maxColumns ;let's draw the top line
- theTop:
- mov es:[si], bh
- mov es:[si+1], bl
- add si, 2
- loop theTop ;done!
- mov cl, 2 ;now, calculate the middle line
- mov ax, maxLines
- dec ax
- div cl ;and the result will be saved in ax
- sub maxLines, 2 ;subtract 2 lines (top and bottom)
- ;the middle line will be decremented after
- sub maxColumns, 3 ;decremente 3 columns (left, middle and right)
- mov dx, maxColumns ;save value in ax
- mov toNextLine, 160 ;calculate ao much columns we need to jump
- sub toNextLine, 6 ;until next line
- sub toNextLine, dx
- sub toNextLine, dx ;the result will be in toNextLine
- add si, toNextLine ;now, jump to next line, because um print the top
- ;but we have more to print
- drawFlag:
- mov es:[si], bh ;print left column
- mov es:[si+1], bl
- add si, 2 ;jump this columns
- add si, maxColumns ;and the necessary number of columns until the middle
- mov es:[si], bh ;print middle column
- mov es:[si+1], bl
- add si, 2 ;again, jump to right column
- add si, maxColumns
- mov es:[si], bh ;print right column
- mov es:[si+1], bl
- add si, 2
- add si, toNextLine ;add the number of columns until next line
- dec maxLines ;decrement lines
- cmp maxLines, ax ;check if we are in the middle line
- jne keepGoing ;if not, keep print the flag
- mov cx, maxColumns ;if yes, print the middle line
- add cx, 3 ;add 3, because we decrement 3 before
- theMiddle:
- mov es:[si], bh
- mov es:[si+1], bl
- add si, 2
- loop theMiddle
- dec maxLines ;after middle line is printed, decremente one line
- add si, toNextLine ;and jump to next line
- keepGoing:
- cmp maxLines, 0 ;compare if we are in last line
- jne drawFlag ;if not, keep print the flag
- ;++++++++++++++++
- mov cx, maxColumns ;and now, print the bottom line of flag
- add cx, 3 ;add 3 again
- theTail:
- mov es:[si], bh
- mov es:[si+1], bl
- add si, 2
- loop theTail ;done!
- mov ah,4CH
- int 21H
- main endp
- cseg ends
- end main
- ;the first 0 means static, if 1, text will be blinking
- ;the next 3 digits is for brackground color [000-111]
- ;the next 4 digits is for text color [000-1111]
- ;colors
- ;black 0000
- ;blue 0001
- ;gren 0010
- ;cyan 0011
- ;red 0100
- ;magenta 0101
- ;brown 0110
- ;light grey 0111
- ;dark grey 1000
- ;light blue 1001
- ;light green 1010
- ;light cyan 1011
- ;light red 1100
- ;light magenta 1101
- ;yellow 1110
- ;white 1111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement