6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 12:05 pm

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Thu Feb 21, 2008 1:40 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
True, and you're reminding me of why I abandoned my quest for relocatable code on the 6502-- code that could be scooted around in memory after it was loaded and may have already been running. It wasn't so much the code location that was the problem as the data location. It can still be done, but it was getting too cumbersome to be worth it. If you have some slick ideas though, I might take it up again.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 21, 2008 4:33 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
dcl raises a point that I didn't consider at the time. However, if you're willing to invest in using 5 bytes of zero-page at a fixed (or linker-patched) address,

Code:
.proc whereAmI
  ldx #3
again:
  lda thunk,x
  sta zpThunk,x
  dex
  bpl again
  jsr zpThunk

thunk:
  pla
  tax
  pla
  rts
.endproc


You have to JSR to whereAmI -- JMPing to it will likely cause a crash.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Feb 22, 2008 2:45 am 
Offline
User avatar

Joined: Thu Mar 11, 2004 7:42 am
Posts: 362
I've added Where-Am-I routines to the wiki at:

http://6502org.wikidot.com/software-whereami


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: