Jump to content

Photo

Reset vector with 2K ROM

reset vector 2k rom

10 replies to this topic

#1 FizzyChicken OFFLINE  

FizzyChicken

    Combat Commando

  • 3 posts
  • Location:Merseyside, UK

Posted Wed Jun 15, 2016 2:51 AM

Hi, as I understand it when the 2600 is powered on the PC is set by the reset vector, which is held in ROM memory locations $fffc & $fffd. But when a 2K ROM is inserted the ROM only reaches up to $f7ff. When I look at the hex dump of Combat I can see the reset vector ($f000) in locations $f7fc & $f7fd.

 

So does the reset vector location depend on the ROM size or am I missing something ?

 

Thanks



#2 alex_79 OFFLINE  

alex_79

    Dragonstomper

  • 913 posts
  • Location:Italy

Posted Wed Jun 15, 2016 7:56 AM

Address line A11 is not connected to a 2k rom, so the rom is mirrored twice in the 4k address space. Addresses '$F7FC' and '$FFFC' both point to location '$7FC' in the 2k rom.

 

These aren't the only mirrors you can use.

In 4k rom, address lines A15,A14,A13 are ignored (those pins aren't present at all on the 6507), A12 must be '1' to select the rom and A0 to A11 are used to address the rom. This results in the rom being mirrored 8 times in the entire 16bit address space:

$1000-$1FFF
$3000-$3FFF
$5000-$5FFF
$7000-$7FFF
$9000-$9FFF
$B000-$BFFF
$D000-$DFFF
$F000-$FFFF

In a 2k rom, in addition to that, A11 is also not connected and only A0 to A10 are used to address the rom, so in this case there are 16 mirrors:

$1000-$17FF
$1800-$1FFF
$3000-$37FF
$3800-$3FFF
$5000-$57FF
$5800-$5FFF
$7000-$77FF
$7800-$7FFF
$9000-$97FF
$9800-$9FFF
$B000-$B7FF
$B800-$BFFF
$D000-$D7FF
$D800-$DFFF
$F000-$F7FF
$F800-$FFFF

You can use any of these mirrors in your program, as they all point to the same phisical memory.



#3 FizzyChicken OFFLINE  

FizzyChicken

    Combat Commando

  • Topic Starter
  • 3 posts
  • Location:Merseyside, UK

Posted Wed Jun 15, 2016 10:01 AM

Ah, that explains it. Thank you  ;-)



#4 SpiceWare OFFLINE  

SpiceWare

    Quadrunner

  • 10,975 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Wed Jun 15, 2016 1:07 PM

TIA, RAM, IO and Timers are also mirrored multiple times in the 2600.  More info about that in this topic.



#5 tschak909 ONLINE  

tschak909

    Stargunner

  • 1,592 posts
  • Location:USA

Posted Wed Jun 15, 2016 2:21 PM

Gotta love partial address decoding... ;)

 

-Thom



#6 Omegamatrix OFFLINE  

Omegamatrix

    Quadrunner

  • 6,098 posts
  • Location:Canada

Posted Wed Jun 15, 2016 7:31 PM

The three highest bits of a pointer are also useful for temporary storage during the kernel since they will just access a mirrored address. They are especially great for branching with BIT tests (BMI, BPL, BVC, BVS).



#7 alex_79 OFFLINE  

alex_79

    Dragonstomper

  • 913 posts
  • Location:Italy

Posted Thu Jun 16, 2016 2:08 AM

They're also a way to pass parameters to a subroutine. Jump to a mirror address according to the parameters that you need to pass before calling the subroutine and it can test the return address in the stack. (the 6507 is a full 6502 internally, so the program counter is 16 bit wide and all bits are stored in the stack when executing a jsr)
 



#8 FizzyChicken OFFLINE  

FizzyChicken

    Combat Commando

  • Topic Starter
  • 3 posts
  • Location:Merseyside, UK

Posted Thu Jun 16, 2016 2:46 AM

Wow. Some good tips there. I learnt to program the 6502 on the C64/128 when I was a kid. Used to do demo's and rip games apart etc. The only other asm I've done is a couple of years coding 68K on the MegaDrive. The 2600 is quite a challenge after 20-odd years of making games with higher level languages and tools. Absolutely loving getting back down to the metal again. Makes me feel like a big kid  8).


Edited by FizzyChicken, Thu Jun 16, 2016 2:46 AM.


#9 Omegamatrix OFFLINE  

Omegamatrix

    Quadrunner

  • 6,098 posts
  • Location:Canada

Posted Thu Jun 16, 2016 7:54 PM

They're also a way to pass parameters to a subroutine. Jump to a mirror address according to the parameters that you need to pass before calling the subroutine and it can test the return address in the stack. (the 6507 is a full 6502 internally, so the program counter is 16 bit wide and all bits are stored in the stack when executing a jsr)
 

Another cool use is aligning the stack pointer to some color registers, and then JSR to a certain address. The return address gets written to the color registers. You can also use BRK to do three color writes in 7 cycles.

 

 

Here is another example of stack abuse different to the one I posted above. We were making a two color AtariAge logo.



#10 gauauu OFFLINE  

gauauu

    Chopper Commander

  • 244 posts
  • Location:Illinois

Posted Fri Jun 17, 2016 9:53 PM

You guys have made me realize just how little skill I have with 6502 magic when it comes to the Atari. Keep the tricks coming, this is amazing.



#11 tschak909 ONLINE  

tschak909

    Stargunner

  • 1,592 posts
  • Location:USA

Posted Fri Jun 17, 2016 10:33 PM

I still love using the stack pointer over the missile and ball registers and PHPing them to enable the missiles and ball in O(1) time.

 

-Thom







Also tagged with one or more of these keywords: reset, vector, 2k, rom

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users