not completely black

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

not completely black

utsav
My fill.hack is working fine except that there are few white lines left .
In order to turn screen completely black , each bit of all 8192 registers should be 1 which can be done by loading 65535 in each register . But whenever I try to load anything greater than 32767 , assembler or CPUemulator turns that value in register to 16. Why's that and how do I solve this ?
Reply | Threaded
Open this post in threaded view
|

Re: not completely black

ybakos
Hint: What negative number is represented as sixteen 1's in binary?
Reply | Threaded
Open this post in threaded view
|

Re: not completely black

cadet1620
Administrator
In reply to this post by utsav
utsav wrote
My fill.hack is working fine except that there are few white lines left .
In order to turn screen completely black , each bit of all 8192 registers should be 1 which can be done by loading 65535 in each register . But whenever I try to load anything greater than 32767 , assembler or CPUemulator turns that value in register to 16. Why's that and how do I solve this ?
Since A-commands always have the most significant bit set, you can't use them to load numbers greater than 32767. Note that 65535 is the signed number -1 so you can use a C-command to load -1.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: not completely black

utsav
In reply to this post by ybakos
Okay. Thanks.
I loaded -1 in register instead of 65535, but after running the test script as I press any key it shows an error saying -
"At line 32767 : Can't continue past last line"
Reply | Threaded
Open this post in threaded view
|

Re: not completely black

cadet1620
Administrator
utsav wrote
Okay. Thanks.
I loaded -1 in register instead of 65535, but after running the test script as I press any key it shows an error saying -
"At line 32767 : Can't continue past last line"
Your program ran off the end of ROM. Perhaps there was an attempt to jump to 65535?

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: not completely black

utsav
When I was loading 32767 in registers, program was working fine (except few white lines ), but when I loaded -1 (with no other change in code) , it showed the error as i mentioned above . So to load -1, I first loaded 0 and then did D=A-1. this time it worked completely fine . Why wasn't it working  on loading -1 directly ?
Reply | Threaded
Open this post in threaded view
|

Re: not completely black

cadet1620
Administrator
utsav wrote
When I was loading 32767 in registers, program was working fine (except few white lines ), but when I loaded -1 (with no other change in code) , it showed the error as i mentioned above . So to load -1, I first loaded 0 and then did D=A-1. this time it worked completely fine . Why wasn't it working  on loading -1 directly ?
'@' commands are A-Instructions, see section 4.2.2. The value must be between 0 and 32767, inclusive.
The ALU can compute the constants 0, 1 and -1 (fig. 4.3), so you can use the C-Instruction dest=-1 to load -1 into A, D or M.

There's a bug in the CPU emulator as noted in this post that causes it to behave very strangely in response to @-1.

--Mark