Help w/ Fill.asm

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

Help w/ Fill.asm

rpc0618
I am at a specific part in my code that is baffling me.

Here is four lines of a code snippet that seems to be the cause for weird behavior.
"
    @KBD    
    D=M     // [KBD] --> D
    @LIGHT  
    D;JEQ   // If NO key is pressed, Jump to (LIGHT) ELSE continue with next instruction
"
What I think happens is it checks for a keypress (this part works, and the value is moved to D). If no key is pressed, it jumps to a later section of code that is called (LIGHT). That also works.

Where it fails horribly is in the blank line of code that's mysteriously inserted into the ROM code right after this last D;JEQ line. Once that's executed, the PC moves to the ROM address that equals the ASCII code of the key pressed. If I hold down an "A" while it's executing automatically, suddenly the PC jumps to line 65. If I use F11 to move line by line, i'm now at empty ROM address 151.

If anyone would like a copy of my whole original fill.asm code, I'll be happy to send it! My email address is rcollins0618 (AT) gmail (D0T) com.

I think I must have messed up the syntax or something in my code and it's probably staring me right in the face, but i don't know what I did wrong.

HELP!?!

Thanks,

Rich :)
"If you wish to make an apple pie from scratch, you must first invent the universe." - Carl Sagan
Reply | Threaded
Open this post in threaded view
|

Re: Help w/ Fill.asm

cadet1620
Administrator
Rich's problem was that he had the line
    @-1
in his code where he wanted to set -1 into a variable.

The CPU Emulator accepts this line without error, but displays it in the ROM window as a blank line. When the CPU Emulator tries to execute this illegal instruction, it gets rather confused and copies D into M and A and executes a jump to A!

The supplied assembler also accepts @-1 without error. It generates 1111 1111 1111 1111 as the binary code.

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

Re: Help w/ Fill.asm

rpc0618
WooHoo! Where's the +1 option? Can I "Like" this?

Anyway, Thanks a bunch to Cadet1620 for helping me out with this so promptly!

 - Rich
"If you wish to make an apple pie from scratch, you must first invent the universe." - Carl Sagan