Answer to Question #210709 in Assembler for qamar zaib

Question #210709

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.


1
Expert's answer
2021-06-25T10:48:11-0400
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS