6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Nov 12, 2024 9:18 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Thu Dec 23, 2010 2:10 am 
Offline

Joined: Thu Dec 23, 2010 2:03 am
Posts: 2
Hello,

I'm not sure if this is the right forum to post this in but.. I'm writing a 6502 assembler and have a question about labels. Having looked at hex dumps it does not appear to be addresses, I'm a bit confused about how this works. I have tried to search for the info but my search terms might have been to general. Any insight into this would be appreciated, thanks.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 2:16 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
Are you looking for what the branches to labels assemble? The branch instruction's operand is a single byte, specifying a relative branch distance, up to 127 bytes forward or 128 bytes backward, zero being the byte following the operand of the branch instruction. I don't know if that's what you're looking for. The label itself is only used by the assembler, and does not take any space at all in the final code that you would see in the hex dump.


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 23, 2010 2:28 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8482
Location: Midwestern USA
Garth, he may be wondering how the label gets internally used in the assembler. In that case, a (usually) 16 bit value is associated with the label, usually in a separate array maintained in core or in a temp file on the disk. The meaning of the value would depend on the context in which it is used. It might be an address or a constant (e.g., a register mask or offset).

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 23, 2010 4:41 am 
Offline

Joined: Thu Dec 23, 2010 2:03 am
Posts: 2
Garth thanks, I suspected it was something like an offset, dividing the byte of the operand into a negative or positive offset makes sense to what I saw in the hex dump. BigDumbDinosaur, right now I parse each row of assembly source into a hash. I'm thinking about counting the address relative from from the first row and give the labels 'key' the current address as 'value'. Then I can get the offset by subtracting the new address from the original address when ever the label re-appear in the source. Thank you guys.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 25, 2010 1:36 am 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Foo, if you run the raw dump through a dissembler, it comes out with readable code with address labels such as A4367 for an address used. You can then renamed those labels as you discover the functions.

Having fun right now doing that with Asteroids. The code project is woefully incomplete.

http://www.ionpool.net/arcade/astcode/a ... oject.html

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 25, 2010 7:52 pm 
Offline

Joined: Fri Aug 30, 2002 2:05 pm
Posts: 347
Location: UK
Quote:
Having fun right now doing that with Asteroids. The code project is woefully incomplete.

I did an almost fully commented disassembly of asteroids a couple of years ago.

Lee.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 27, 2010 8:56 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Lee, do you still have it? My head tech at work (supervisor) is keen on an Asteroids with a much higher speed fire power. I've still been trying to play round with the dissembly but tis a slow one. First experiment got the rocks moving 4 times as fast :)

Email is nightmartony@yahoo.com.

Thanks!

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 27, 2010 8:57 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
whoops, nightmaretony :)

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 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: