User Tools

Site Tools


aslfaqs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
aslfaqs [2025/09/09 17:33] – [How do I use local variables?] reggieaslfaqs [2025/09/09 19:26] (current) – [Which registers do I use?] reggie
Line 20: Line 20:
 ==== Which registers do I use? ==== ==== Which registers do I use? ====
  
-For an address variable pick an index register, X, Y or even (user stack) U, it doesn't matter which. For a character or small numberic variable pick an accumulator, A or B, again it doesn't matter which. If you need 16-bit values use D, which is the two accumulators combined (A high, B low).+For an address variable pick an index register, X, Y or even (user stack) U, it doesn't matter which. For a character or small numeric variable pick an accumulator, A or B, again it doesn't matter which. If you need 16-bit values use D, which is the two accumulators combined (A high, B low).
  
 Choice between index or accumulator severely limits the operations you can perform. Only LD, ST, and CMP are common between all user registers. General arithmetic operations (NEG, AND etc.) are limited to the 8-bit accumulators, except for ADD and SUB which are available to 16-bit D. Index registers uniquely have the LEAX operation, and the stacks (U and S) have PSH and PUL. Choice between index or accumulator severely limits the operations you can perform. Only LD, ST, and CMP are common between all user registers. General arithmetic operations (NEG, AND etc.) are limited to the 8-bit accumulators, except for ADD and SUB which are available to 16-bit D. Index registers uniquely have the LEAX operation, and the stacks (U and S) have PSH and PUL.
Line 441: Line 441:
  
 Yes, there's no reason why an assembly language subroutine shouldn't call itself. But the same caveats apply as in any other language. You must use local variables for instance, and not alter global memory in unexpected ways. Yes, there's no reason why an assembly language subroutine shouldn't call itself. But the same caveats apply as in any other language. You must use local variables for instance, and not alter global memory in unexpected ways.
 +
 +Beware of very deep recursion; a pixel flood-fill routine might call itself thousands of times, overwriting more than the available RAM with the system stack.
  
 ==== What is position independence and when do I use it? ==== ==== What is position independence and when do I use it? ====
Line 534: Line 536:
 There's no reason why a short routine shouldn't be reentrant. Simply allocate variables on the stack and never use globals. And avoid eccentricities like self-modifying code. For a larger program things become complex. Fresh memory might be allocated from a heap by the operating system for example. It's an advanced topic, but still doable on the 6809.  There's no reason why a short routine shouldn't be reentrant. Simply allocate variables on the stack and never use globals. And avoid eccentricities like self-modifying code. For a larger program things become complex. Fresh memory might be allocated from a heap by the operating system for example. It's an advanced topic, but still doable on the 6809. 
  
 +==== What is indirection and how do I use it? ====
  
 ==== How do I use virtual methods to create polymorphic objects? ==== ==== How do I use virtual methods to create polymorphic objects? ====
aslfaqs.1757439210.txt.gz · Last modified: 2025/09/09 17:33 by reggie

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki