assembly - Strange output with Irvine's WriteString -


The point of the following program is to print the letter "c" with the combination of each background and foreground color

< P> I am using colors in the library 0-15 defined and with the following code:

  mov eax, foreagon + (background * 16) call SetTextColor  

Here's my code:

  IrwinNine.In.com. Data character BYTE "c" count DWORD? Background DWORD 0. Code Main Proxy Call Clrscr mov ecx, 15; Our main counter 0-15 colors L1: MOV calculation, ecx; Our external loop counter mov ecx, 15; Internal loop counter L2:; Since our color is defined as ... mov eax, exotic + (background * 16) mov eax, count; Setup our foreground color eX, add background; SettextColor setup our background color; Instead of multiplying the color of each background from 16, we are going; Add 16 times each time to add background, 16; Character mov ADX, Offset Character Call ListString loop L2 mov ecx, count print; Reset our external loop loop L1 call Exit CRLF main ENDP end main  

Now, I am using Windows 7, the code above works "works" but for some reason From, it goes to a certain point, the program stops, and the computer starts beeping. In addition, at a certain point in the program, this letter starts printing random characters with C .. Here is my output:

  c♀c♀c♀c♀c♀c ♀c♀ C♀c♀c♀c♀c♀c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂cccccccccccccccccccccccccccccccccccc cccccccccccccccccc ♠ c ♠ c ♠ c C ♠ c ♠ c ♠ c ♠ c ♠ c ♠ c ♠ c ♠ c ♠ c ♠ c ♠ c ♣ c ♣ c ♣ c ♣ c ♣ c ♣ c ♣ c ♣ c ♣ c ♣ c ♣ c ♣ c ♣ C ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♦ c ♥ c ♥ c ♥ c ♥ c ♥ c ♥ c ♥ c ♥ c ♥ c ♥ C ♥ c ♥ c ♥ c ♥ c ♥ c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c C☺c☺c☺c☺c☺c☺c☺c☺c☺c☺c☺c to press any key to continue. . .  

Can anyone tell me why this is happening?

  character byte "c"  

:

  Character byte "c", 0dh, 0ah, 0  

Comments