Jupiter Lander code

Basic and Machine Language

Moderator: Moderators

Post Reply
bradw2k
Vic 20 Newbie
Posts: 11
Joined: Thu Aug 02, 2007 10:39 am

Jupiter Lander code

Post by bradw2k »

Hello,

As I try to get started understanding the Jupiter Lander code, I am immediately having newbie issues, so I hope someone can give me a hint about what I should try. Part of the problem is that I've ordered the Vic PRG but it is still in the mail, and another part is that I haven't touched 6502 code in two decades.

I am able to run the Recomment disassembler under Cygwin, but I think I'm making it misassemble rather than disassemble. When it loads Jupiter Lander.prg, here is the start of the output:

Code: Select all

.word $A000

; *** text follows ***

 *=$A000

; A000: Illegal instruction.

 A000             .byte $1F, $A0, $09, $A0, $41, $30, $C3, $C2  ;_ i a0CB
 A008             .byte $CD, $68, $A8, $68, $AA, $68, $40       ;MH(H*H@
 A00F  xA00F      .byte $03, $1C, $17, $2E, $00, $FD, $00, $00  ;c\w.....
And here are the first few bytes of the prg file itself:

Code: Select all

00 a0 1f a0 09 a0 41 30 c3 c2 cd 68 a8 68 aa 68
So as I understand it, the first two bytes of a prg file represent the load address, and Recomment seems to read this as $A000. I guess that is correct, if the byte ordering is supposed to be reversed (is it?).

But then Recomment sees the very first instruction as an illegal machine code. And looking at the 6502 machine code chart here http://ericclever.com/6500/ I am unable to disassemble by hand as well.

If the A0 (fourth byte) is the first instruction (because bytes are reversed), that's an immediate LDY, which would be fine except that the sixth byte is an A0 as well, and I can't think why there'd be two immedate LDY's in a row. So that seems like barking up the wrong tree.

On the other hand (if bytes are not reversed), if the 1F is to be the first instruction, it doesn't appear in the chart, so it would seem to be an illegal machine code. And I take it that is the same conclusion Recomment is coming to.

So I think one or more of my assumptions must be wrong. Are bytes really in "reversed" order? Is the third/fourth byte really supposed to be the first instruction, or is there some special address that a cartridge boots to besides the code at the load address?

I am also unable to load and run the Jupter Lander.prg in VICE, can anyone help explain how to do that? That would probably shed a lot of light.

Thanks for any help! I'm sure I am just being dense.

Brad
User avatar
eslapion
ultimate expander
Posts: 5458
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

Post by eslapion »

Pretty much anything that loads at $A000 on the VIC is autostart cartridges.

For the autostart to be activated by the VIC's kernal, you have to have a very specific sequence of bytes at the beginning of the code.

You are right in interpreting that the first two bytes indicates the load address to be $A000, however, what follows is not machine code.

The bytes 1f a0 09 a0 are addresses where the CPU is expected to jump upon reset ($A01F and $A009) with the most significant byte last.

The following five bytes (41 30 c3 c2 cd ) represent the code A0CBM which are mandatory to confirm this is an autostartable code.

Since the CPU is expected to jump to $A009, counting the bytes, you get $68 which is 6502 opcode PLA then $A8 which is 6502 opcode TAY and so on...

Also note that you can never "RUN" an autostartable cart, you have to trigger a software or hardware reset to get the kernal to execute it. Only Basic programs can be started with RUN or machine language programs that use the basic command SYS to start themselves.
bradw2k
Vic 20 Newbie
Posts: 11
Joined: Thu Aug 02, 2007 10:39 am

Post by bradw2k »

Thanks very much. :D

You mentioned there are two jump-upon-reset addresses, what's the difference between them?

Is there a canonical resource for this info, by the way? I don't see these details in the PRG.

Regards,
Brad
User avatar
eslapion
ultimate expander
Posts: 5458
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

Post by eslapion »

bradw2k wrote:Thanks very much. :D

You mentioned there are two jump-upon-reset addresses, what's the difference between them?

Is there a canonical resource for this info, by the way? I don't see these details in the PRG.

Regards,
Brad
I think one is an address for reset and the other is for NMI or interrupt.

I am surprized other more knowledgeable people haven't replied to this one.

The Programmer's reference guide truly sucks when it comes to this kind of secret information. It should have been in there but for reasons that only Michael Tomczyk and Andy Finkel knows its not.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

The first is the address to jump to when a reset occurs. The second is the address to jump to when you hit RESTORE key.
Anders Carlsson

Image Image Image Image Image
Post Reply