I am supposed to write a program to show all possible color combinations, but I am having problems. It will give me all 256 colors, but not in all possible combinations.
Here is me code.

include irvine32.inc

.data

colors byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

.code

main PROC

mov ecx, 16
mov esi, offset colors
mov eax, 0


     Outer:
         
        push ecx
	    mov al, [esi]

	    call settextcolor
	    mov al, '#'
         call gotoxy
	    call Writechar

        mov ecx, 16

mov esi, offset colors

              Inner:
			      
                   mov al, [esi]
                   inc esi 
	               call settextcolor
                   mov al, '#'

	               call Writechar
	            
inc dh
              loop Inner
       inc esi
        pop ecx

	  loop Outer
	  	
exit
main ENDP
END main

You might want to remember to load (E)DS at the beginning of your program.

All the functions you are using (with 'call') have a register call type, meaning that arguments are passed in registers. Hence, to settextcolor( attribute: byte ) the attribute must first be placed in AL (as you have done).

Make sure to keep the two parts (loading the registers and calling the function) together for each function. Use commentary to help:

; Set the text attribute to colors[esi]
	mov al, [esi]
	call settextcolor

	; Write a '#' to show the colors
	mov al, '#'
	call Writechar

etc. The reason I want you to do this is so that you don't make mistakes like you did with gotoxy (which should take two arguments: one in AX and one in BX, if I remember correctly).

Be careful how you use (E)SI. When you change it for the inner loop, you completely loose your place in the outer loop. I would recommend pushing and popping SI and CX at the same places in the code.

; Prepare to enter the inner loop
	push si, cx

	...

	; Prepare to return from the inner loop
	pop cx, si

The last thing to think about is how a text color attribute is stored. Remember: four bits for the background and four bits for the foreground. You'll have to use some bit manipulations (shift and add) to combine the current foreground color with the current background color, then settextcolor and Writechar.

Hope this helps.

This question has already been answered. Start a new discussion instead.