0 Members and 5 Guests are viewing this topic.
It's much easier to just draw two sprites in axe than to write a new set of wrapping sprite display routines in ASM.
A->T B->A T->B
A->π B->A π->B
{A*3}->X {A*3+1}->Y {A*3+2}->Z
{A*3->π->π}->X {π+1}->Y {π+2}->Z
Could you add an option to the options menu for expert users that would turn off the scope checking? Because I can definitely think of times when I wanted to be able to push/pop across multiple lines for extreme optimizations.
^ Not really. Pseudo-wrapping in the horizontal direction is smaller, but its not real wrapping because the half sprite on the right side of the screen would be shifted down by one pixel and additional clipping would be needed for the last row so it wouldn't leak into memory after the screen. This is better suited for an Axiom though since wrapping is rarely needed and can be done easily with 2 sprites.Anyway, I came up with a new advanced syntax idea! I was thinking of allowing programmers to take advantage of the stack the z80 offers but I'm concerned about memory leaks this could cause and undesired conflicts when calling routines since Axe uses the same stack behind the scenes. But then I realized there is a way I could do it that would be both easy to use and be impossible to leak memory. The solution is to:1) Only allow the pair if they are in the same scope. I define scope loosely... it has to fit on one line, but CAN intersect most single argument commands.2) Require a pop for each push in that scope or else throw a syntax error.3) Allow automatic integration into the right-hand side of binary operations.For a non-technical explanation: Think of it as storing a value (maybe the result of a large computation) to a place you want to read later without having to use a temporary variable or do the computation again. You can nest as many of these as you want without concern about memory. I decided to use the pi character (π) to implement this. Storing to it pushes the variable and reading from it pops it.For example here is code to swap the values of 2 variables using a temporary:Code: [Select]A->T B->A T->BHere is the same code using the stack instead.Code: [Select]A->π B->A π->BSince each variable read or write is 3 bytes, but each stack read or write is only 1 byte, this code saves 4 bytes and is slightly faster.Another example:Code: [Select]{A*3}->X {A*3+1}->Y {A*3+2}->ZHere is a case where you can nest them together:Code: [Select]{A*3->π->π}->X {π+1}->Y {π+2}->ZThis saves a HUGE amount of memory.When nesting, the most recent store to the stack is the one that gets read when you read from the stack. Here is a pairing example:A->π B->π C->π π->D π->E F->π π->Gπ->HI'm hoping this will lead to more possibilities to optimize code. I know at least one individual will have a field day with this Let me know if anyone, especially asm programmers, have questions or concerns. It seems to work in my head, but I haven't tried implementing it so there may be some unforeseen problems.
In other news, Frey continues kicking unprecedented levels of ass.
Too many consecutive pushes without pops will cause an overflow, even if the pops occur later on
A->pi->pi puts A once on the stack because, as it is now specified, pi-> is a pop, so pi->pi pops the top value then pushes it back in, doing nothing but waste cycles.
Could there be a command for reading that top value w/o popping it?
A complementary command for deleting the top value off the stack w/o having to store it anywhere?