Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create two procedures: (1) SetColor receives two BYTE parameters: forecolor and

ID: 3536156 • Letter: C

Question

Create two procedures: (1) SetColor receives two BYTE parameters: forecolor and backcolor.It calls the SetTextColor procedure from the Irvine32 library. (2) WriteColorChar receives three byte parameters: char, forecolor, and backcolor. It displays a single character, using the color attributes specified in forecolor and backcolor. It calls the SetColor procedure, and it also calls WriteChar from the Irvine32 library. Both SetColor and WriteColorChar must contain declared parameters. Complete the missing part of the code for the two procedures.

Explanation / Answer

INCLUDE Irvine32.inc


; procedure prototypes:

SetColor PROTO forecolor:BYTE, backcolor:BYTE

WriteColorChar PROTO char:BYTE, forecolor:BYTE, backcolor:BYTE



.data


.code

main PROC


INVOKE WriteColorChar, 'A', green,red

INVOKE WriteColorChar, 'B', black,yellow

INVOKE WriteColorChar, 'C', gray,blue

INVOKE WriteColorChar, 'D', blue,white

call Crlf


exit

main 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 ; from Irvine32.lib

ret

SetColor ENDP


END main