6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon Apr 29, 2024 2:54 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Jul 19, 2019 9:30 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
Saw this post by Gregory Nacu and thought it might be of interest:

Object Orientation in 6502 (Take 2)

(For those already familiar with 6502, skipping to the section "Structuring Object Oriented Code on the 6502" might be worthwhile.)

This in the context of the work-in-progress C64 OS. There are difficulties of very constrained storage, and difficulties of not being able to chase pointers or use jump tables without some zero page use:

Quote:
The pointer for indirect indexed addressing must be in zero page. So, C64 OS reserves 4 bytes in ZP for 2 pointers, which the toolkit header defines as THIS and CLASS. The first step is to copy a pointer to an object from main memory into the THIS pointer. Via that pointer the ISA property can be read. The next step is to copy the ISA property into the CLASS pointer. From the CLASS pointer, then, we can use a label for the offset into its jump table for the desired method, and JSR to it. Wait, not so fast, remember, the 6502 does not support indirect indexed with the JSR instruction. Instead, C64 OS reserves 3 more bytes of workspace memory for a JMP instruction plus its two byte address. The next step then is to use indirect indexed LDAs to read the address of the routine and write it into this method redirect vector.



It's his second take on the subject - and he suggests one should not read the earlier take, from a couple of years ago:
Object Orientation in 6502


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 19, 2019 12:16 pm 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
Surely you'd only need to reserve 2 bytes, and perform a JMP (abs) from a fixed location after the JSR? But maybe that is slower.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 19, 2019 1:43 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3349
Location: Ontario, Canada
Quote:
a JMP instruction plus its two byte address
Perhaps there's sometimes a need for that JMP opcode to be $6C (rather than $4C)... ?

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 01, 2019 7:10 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
(This recent thread might also be of interest:
)


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

All times are UTC


Who is online

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