Write a program that displays a string in all possible combinations of foreground and background colors (16 x 16 =256). The colors are numbered from 0 to 15, so you can use a nested loop to generate all possible combinations. Also use a delay of 1s in each foreground color change.
INCLUDE Irvine32.inc
.data
count DWORD ?
.code
main PROC
mov eax,0
mov ecx, 16 ; 16 foreground colors
foreground:
mov count, ecx ; counter of foreground colors
push eax
mov ecx, 16 ; 16 background colors
background: ; output one line
call SetTextColor ; Changes the color of all subsequent text output
push eax ; save color befor WriteChar
mov al,'*' ; Writes character
call WriteChar
pop eax ; restore color
add eax,10h ; next background color (Bits 4-7 )
loop background
call crlf ; new line
pop eax ; restore color
inc eax ; next background color (Bits 0-3)
mov ecx, count ; counter of line
push eax
mov eax,1000 ;delay 1 sec
call Delay
pop eax
loop foreground ; new foreground color
mov eax,white+(black*16)
call SetTextColor
call crlf ; Clears the screen
call WaitMsg
exit
main ENDP
END main
Comments
Leave a comment