Question: Hi, I have a problem when I writing this x86 assembly language. I want to change the color of the colored squares and redisplay the

Hi, I have a problem when I writing this x86 assembly language.

I want to change the color of the colored squares and redisplay the board, and continue until the program shows the map 16 times, using all possible 4-bit background colors. (the white squares remain white throughout)

I already figure out how to display it 16 times, but I don't know how to change the color.

Can anyone help me? And please attach your screenshot if possible, thank you all in advance.

Please don't post wrong code!

Below is my current program:

INCLUDE Irvine32.inc

SetColor PROTO forecolor : BYTE, backcolor : BYTE WriteColorChar PROTO char : BYTE, forecolor : BYTE, backcolor : BYTE PrintRowOdd PROTO color : BYTE PrintRowEven PROTO color : BYTE

.data rows = 8 columns = 8 horizCharsPerSquare = 2 colorConstant DWORD ?

.code main PROC

mov ecx, 16 mov colorConstant,0 L1: push ecx mov ecx, rows / horizCharsPerSquare L2: INVOKE PrintRowOdd, gray call Crlf

INVOKE PrintRowEven, gray call Crlf loop L2

mov eax, 500 call Delay INVOKE SetColor, lightGray, black inc colorConstant call Crlf

pop ecx loop L1 exit main ENDP ; -------------------------------------------------- -

PrintRowOdd PROC uses ecx, color:BYTE mov ecx, columns / horizCharsPerSquare L1 : INVOKE WriteColorChar, ' ', color, color INVOKE WriteColorChar, ' ', color, color INVOKE WriteColorChar, ' ', white, white INVOKE WriteColorChar, ' ', white, white loop L1 ret PrintRowOdd ENDP

; -------------------------------------------------- -

PrintRowEven PROC uses ecx, color:BYTE mov ecx, columns / horizCharsPerSquare L1 : INVOKE WriteColorChar, ' ', white, white INVOKE WriteColorChar, ' ', white, white INVOKE WriteColorChar, ' ', color, color INVOKE WriteColorChar, ' ', color, color loop L1 ret PrintRowEven ENDP

; ------------------------------------------------ -

WriteColorChar PROC USES eax, char:BYTE, forecolor : BYTE, backcolor : BYTE INVOKE SetColor, forecolor, backcolor mov al, char call WriteChar ret WriteColorChar ENDP

; -------------------------------------------------- -

SetColor PROC, forecolor:BYTE, backcolor : BYTE movzx eax, backcolor shl eax, 4 or al, forecolor call SetTextColor ret SetColor ENDP END MAIN

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To address the problem of changing the color of the colored squares while displaying the board 16 times we need to modify the background color on each ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!