flat assembler
Message board for the users of flat assembler.
Index
> DOS > Trouble with VGA...Half of screen is Rainbowed. Why? |
Author |
|
macgub 20 Nov 2023, 15:58
Hi !
Keep in mind mode 13h is palette mode. If you put byte into [es:di] you adress an 18 bit pallette register. So I guess in your case byte 32 adress blue color.. But if you dont intialise palette dont rely on this info. Sometimes 32 value will mean blue, sometimes red, black and any other from range 2^18 possible.. At last try always put '32' value in every byte form A0000h to AFA00h - you will get every pixel with same color. Best wishes to you and your coding work! I hope you get more and more experience and get satisfy your job ! |
|||
20 Nov 2023, 15:58 |
|
SeproMan 20 Nov 2023, 20:45
Quote: I don't know why I have a rainbowed screen after the first half (horizontal of the screen) There's nothing wrong with the video memory, but you have a tiny error in your program. Code: test1: mov ax,bx cmp bx,320 je Rainbow jg cl0 jmp Rainbow Rainbow: The value that you have in the BX register is an address. Addresses are unsigned quantities and you should use the unsigned versions of the conditional jumps on them. The quick fix is to replace 'jg cl0' by 'ja cl0'. For unsigned values you need to think in terms of BELOW and ABOVE. For signed values you need to think in terms of LESS and GREATER. If the contents of a 16-bit register (like BX) are to be considered unsigned, then the value ranges from 0 to 65535. On the other hand, if the contents of a 16-bit register are to be considered signed, then the value ranges from -32768 to 32767. In your program, somewhere in the middle of the screen, the address in BX got incremented from 32767 to 32768, thereby entering the negative range when interpreted as signed which the CPU did because of the 'jg' (JumpIfGreater) instruction. Sadly, being not greater, the wrong execution path was taken. If you really want to "Set initial colors (black)" then rather use 'mov cl, 0'. Next is the better way to correct your program: Code: test1: ; I see no need to use 'mov ax, bx' cmp bx, 320 jae .a inc cl ; Rainbow cmp cl, 48 jb bxOne mov cl, 32 jmp bxOne .a: mov cl, 0 ; Rest of screen in black jmp bxOne _________________ Real Address Mode. |
|||
20 Nov 2023, 20:45 |
|
macgub 20 Nov 2023, 21:25
@SeproMan
You go deeper in code - thanks for explanation.... |
|||
20 Nov 2023, 21:25 |
|
Kitsune 20 Nov 2023, 21:34
Thanks! You solved the trouble. The program does what I expected now...And I would have had a really hard time finding this because I didn't know these instructions "jae" and "jb". Merci
|
|||
20 Nov 2023, 21:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.