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

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Dec 30, 2018 4:00 pm 
Offline

Joined: Fri Nov 16, 2018 8:55 pm
Posts: 71
Learning 6502 assembly really is a slow process, but I'm enjoying it. I'm still playing with string output and changing boarder, background, and text colors and generally getting to know my assembler of choice (64tass) as I do.

While messing with strings it seems I habitually put my executable code right up against my text data with no extra space to move around. While space efficient, this seems "wrong" somehow. Add to that the fact that I'm going to be messing with sprites soon and I'm really starting to wonder... what are some rules of thumb for managing memory? Specifically, I'm looking for traditional locations for placing strings, sprite data, SID audio, etc? Also, any source-level conventions I should know (like, "always call Zero Page 'ZP.'") that I should know would be handy, too.

Also, are there any good/simple 64tass sources out there I can learn from? I've found some 6502 assembly code on GitHub, but it's almost always ACME which I've just never taken a liking to.


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 30, 2018 4:40 pm 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 679
The primary constraints of where to put things on the C64 come from the video banking. Since the built-in font ROM is always visible to the video chip in 2 locations, the banking tends to be outside those if you're running custom graphics. Other than that, it comes to contiguous space for variable use, which is broken up a bit by the I/O page at $d000.

Probably the most handy tip is to parallelize arrays. So for instance if you have an array of 16-bit pointers and an 8-bit data point per entry, instead of trying to multiply by 3 to find offsets, use 3 separate tables for each of the entries:
Code:
 ldx entryNum
 lda tableLo,x
 sta ptr
 lda tableHi,x
 sta ptr+1
 lda tableData,x
 jsr routine

; 256 entries in the table, each "entry" is effectively 3 bytes
tableLo:  <256 bytes of space>
tableHi:  <256 bytes of space>
tableData:  <256 bytes of space>


The fastest and easiest is to use fixed-size, fixed location buffers for everything, ensuring 8-bit offsets are always used. Of course, this might not be as flexible as a full malloc-style heap, but shuffling around pointers & doing pointer math is not the 6502's strong suit anyway. If there is dynamic memory allocation, it's usually of the same type of structure out of a pool array.

_________________
WFDis Interactive 6502 Disassembler
AcheronVM: A Reconfigurable 16-bit Virtual CPU for the 6502 Microprocessor


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 04, 2019 3:19 am 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
load81 wrote:
While messing with strings it seems I habitually put my executable code right up against my text data with no extra space to move around. While space efficient, this seems "wrong" somehow.

What's wrong with that?
As long as the text data is static (it doesn't change) it will be fine.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 04, 2019 1:36 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1250
Location: Soddy-Daisy, TN USA
About six years ago I started a little C64 tutorial repo that I never really finished. In it, I have some suggestions on memory layout that was used by a well respected C64 games programmer.

Might be useful...

https://github.com/cbmeeks/breadbin-leg ... igurations

https://github.com/cbmeeks/breadbin-legacy/wiki

_________________
Cat; the other white meat.


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: GARTHWILSON and 59 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: