Selecting Addressing Mode in XA

You need an actual VIC.

Moderator: Moderators

User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Selecting Addressing Mode in XA

Post by Mike »

Mike wrote:In the end, we still get all our code assembled, no? :wink:
chysn wrote:Although I'm starting to wonder how.... :)
That's probably also a matter of programming style.

I want most of my programs/tools for the VIC-20 to cooperate with BASIC and KERNAL, therefore I tend to minimize zeropage usage. It is rather unlikely that I would use bigger ranges in the ZP to operate upon array type structures. I declare zeropage addresses explicitly, with the odd "+1" or "-1" as they are used in the code.

In the other thread, I use $0100 as base to address into the stack, which wouldn't be optimized and which is guaranteed to have the same semantics regarding the X-indexed absolute addressing mode as the hypothetical "$0100,S" addressing mode of the stack instructions (or the interrupt behaviour) of the 6502.

When I use a blank address for self-modifying code, I usually take care to make this $FFFF or the like, as in:

Code: Select all

.Store
 STA $FFFF
 INC Store+1
 BNE Store_00
 INC Store+2
.Store_00
 RTS
I use this routine in code generators, where the operand of STA is initialised at the begin of the generator, and then lots of "JSR Store" instructions write the target code into memory. You find an example in the thread about my CGA viewer, which produces roughly 16 KB of code from a small routine only 350 bytes in size. (The JMP $0000 instruction in my implementation of the IRQ installer was probably an oversight in the matter, but then I also knew there are only the JMP ABS and JMP (IND) variants.)

About the only time where I explicitly used wraparound in zeropage was for a small memory display program you find here, note the LDA $80,X instruction in the ".Print" subroutine.
groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

Re: Selecting Addressing Mode in XA

Post by groepaz »

And you surely have similar rules memorized when you handle operator priorities. Or do you like to build labyrinths of parentheses?
i do indeed write parentheses around sub expressions most of the time, because again - remembering the rules of a dozen different assemblers and compilers is a waste of time to me. especially with assemblers this is a real mess, they all work slightly different, sometimes in very surprising ways even :)
There's no convention across different assemblers how to force address modes, either.
no, but its easy enough to look it up when i need it. BUT when i come back to code written in random assemblers, its a no brainer to read this code with explicit forced modes - unlike when relying on assembler specific implementations.

edit: forgot
That's probably also a matter of programming style.
probably one of the major reasons. i am used to define labels/contants for everything at the top of my sourcefiles, because very often i have to change the memory layout later (for example when linking demo parts together). and i like to format all numbers the same way, ie leading zeros :) (thats how i learned about octal in C ..... =P)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Post Reply