I am writing a simple program to display a character in all color variations of foreground and background colors using setTextColor. It is my understanding the procedure uses 4 bits for the foreground and 4 bits for the background. In my code below there apparently is an error in the way I'm storing data to eax and manipulating the bits to display both the character and the background in all combinations. Any hints I what I need to change?
I know my inner loop code is incorrect, but I think the rest may be okay.
INCLUDE Irvine32.inc
.data
character BYTE 'X' ;character to display
colors BYTE 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ;array of colors
count DWORD ? ;loop counter
back BYTE ? ;background color holder
dblBack DWORD ? ;32 bit holder for back
.code
main PROC
mov esi,OFFSET colors ;index register for array
mov ecx,SIZEOF colors ;loop counter
OUTTER:
mov count,ecx ;save outter loop counter
mov eax,[esi] ;get a foreground color
mov ecx,SIZEOF colors ;loop counter
mov edi,OFFSET colors ;index register for array
INNER:
mov al,[edi] ;get the background color
mov back,al ;move al into a variable
mov ebx, DWORD PTR back ;move the background color ito 32 bit register
shl ebx,4 ;shift all 4 bits to the left
add eax, ebx ;add background left 4 bits to eax
call SetTextColor ;set text color
mov al, character ;move character into al
call WriteChar ;write character
inc edi ;incriment index
loop INNER
inc esi ;incriment index
dec count
mov ecx,count ;set outter loop counter
loop OUTTER ;end loop
exit
main ENDP
END main