Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .8086
- .model small
- .stack 2048
- dseg segment para public 'data'
- myvector db "6","2","3","4",0
- numbers dw 4 ;we will calculate 4 numbers (6,2,3 and 4)
- 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"
- mov cx, numbers ;how much numbers we will calculate?
- mov dl, 0 ;dl will be used to know, how much cells we used in second line
- mov dh, 2 ;we will divide by two, to verify if it's pair or not
- xor di, di
- mov si, 15*160 ;this is to where we will put the text. Line 15
- ciclo:
- mov bh, myvector[di];get the text from screen
- mov al, bh
- mov ah, 0 ;ah has zero because we will divide ax
- div dh ;ax / dh -> ah:al
- cmp ah, 0 ;if number is par, the rest is zero
- jne impar ;otherwise odd
- ;pair:
- mov bl, 00100000b ;[0][010][0000]b -> binary (*see below)
- mov es:[si], bh ;move the space to video adreess (in other words, write a space on screen)
- mov es:[si+1], bl ;change color
- add si, 2
- jmp goAhead
- impar:
- mov ax, si ;save what is in si (we will use si)
- mov dh, 0 ;zero to dh because we will use dx, but just want dl
- mov si, 16*160 ;line 16
- add si, dx ;move to the first unset cell
- mov bl, 01000000b ;[0][100][0000]b -> binary (*see below)
- mov es:[si], bh ;move the space to video adreess (in other words, write a space on screen)
- mov es:[si+1], bl ;change color
- add dl, 2 ;
- mov dh, 2 ;return the two, to make divisions
- mov si, ax ;return to si his value
- goAhead:
- inc di ;every video adress have a size of word, so let's add 2
- loop ciclo ;repeat until cx = 0, In every loop, cx is decremented
- 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