Author Topic: Features Wishlist  (Read 613649 times)

0 Members and 3 Guests are viewing this topic.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Features Wishlist
« Reply #2130 on: April 10, 2011, 06:52:32 pm »
Well, with new stack commands, wouldn't it be possible to exit from a subroutine like this?

Code: [Select]
Lbl EXT
π -> A
Return

That should pop the address of the call to the routine, and then return like a normal program exit.  Correct me if I am mistaken.

Though this would not work in flash apps.

That assumes you're exactly one subroutine deep, so you have to think about the cases where you're calling a subroutine from a subroutine (or you just happened to jump to the subroutine).




Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Features Wishlist
« Reply #2131 on: April 10, 2011, 06:57:38 pm »
This reminds me, would the new stack commands conflict with operations that implicitly use the stack? For example, A->π B-(π+C) would in theory compile to something like:
Code: [Select]
ld hl,(axv_A)
push hl
ld hl,(axv_B)
push hl
pop hl
ld de,(axv_C)
add hl,de
pop de
ex de,hl
or a
sbc hl,de

Long story short, the pops would happen in the wrong order. How will this be handled?
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Ashbad

  • Guest
Re: Features Wishlist
« Reply #2132 on: April 10, 2011, 06:59:53 pm »
Hmm.. Good point.  I guess there would be another way though -- for each subroutine you call, increment a counter somewhere in saferam starting at 0.  Within each subroutine, just increment this.  Then when you go to call the EXT routine, it checks the counter, and pops the amount of times the counter specifies and then just simply calls return.  Requires just a few cycles off of each subroutine (completely unoticeable) and a few bytes (maybe around say, 4 more per subroutine?) and it would make exiting a snap.

Or, if someone knows the address the OS calls to the beginning of the program, you could just push that to the stack and return -- however, that would lead to stack overflow after a while.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Features Wishlist
« Reply #2133 on: April 10, 2011, 07:28:44 pm »
Or, if you stick with pi->A, you now have the ability to exit two subroutine layers at once.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Features Wishlist
« Reply #2134 on: April 10, 2011, 07:28:55 pm »
I just want to sort of bump up this post from a short while back. A bunch of people have been debating how to get a "hard return" function working and I don't know if they missed this post I made 2 pages ago. It details both how a programmer could manually add this functionality and how the command could be built-in to Axe.


Because the OS return location is dug into the stack at an unknown depth, you cannot access it. The solution to this is to backup the OS return location at the start of your program when you know that it is the topmost stack entry. I would suggest using code like the following:


Code: [Select]
.MYPROG

Asm(ED73E383)          .Back up the OS return location

.YOUR PROGRAM GOES HERE

Asm(ED7BE383ED56C9)    .Exit program from anywhere, put this wherever you want it




EDIT: Quigibo, perhaps you could add a Returnr function for this? I could be wrong, but I believe I see a very easy way to handle this. If a Returnr is detected in the first pass, set a flag to say so, but otherwise parse the Returnr command and the rest of the pass as normal. Before starting the second pass but after the header has been added, check this flag. If it isn't set, resume as normal. If it is set, add the 4-byte stack pointer backup code to the beginning of the program and then step through every static pointer, increasing them by 4. The rest of the program should then be able to be parsed normally.
« Last Edit: April 10, 2011, 07:30:21 pm by Runer112 »

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Features Wishlist
« Reply #2135 on: April 10, 2011, 07:38:39 pm »
Here's a slightly easier way that might be less compatible with shells:
Code: [Select]
Asm(2ADE86 2B 2B F9 C9)You don't need to place any special code at the start of the program.

It uses the fact that the OS (and probably all shells) always wraps programs in an error handler when it runs them. So if any shells don't do that, or place any extra pushes on the stack before running the program, it'll crash. But all shells have to use an error handler, or else an error will quit the shell itself.
Spoiler For Actual assembly code:
Code: [Select]
ld hl, (86DEh) ; This address is how the OS always knows how to restore the stack with APP_POP_ERR
dec hl
dec hl
ld sp, hl
ret

Really late edit: That will also have problems if your program installs an error handler of its own, so be sure to pop off any error handlers you have installed before running that. It will also have problems if you modify port 6, so you must restore its value before running that code.
« Last Edit: June 11, 2011, 11:22:03 pm by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Features Wishlist
« Reply #2136 on: April 11, 2011, 04:05:05 pm »
This reminds me, would the new stack commands conflict with operations that implicitly use the stack? For example, A->π B-(π+C) would in theory compile to something like:
Code: [Select]
ld hl,(axv_A)
push hl
ld hl,(axv_B)
push hl
pop hl
ld de,(axv_C)
add hl,de
pop de
ex de,hl
or a
sbc hl,de

Long story short, the pops would happen in the wrong order. How will this be handled?

Ah, but this is exactly my point about scoping!  Because of those extra parenthesis after the subtraction, those stack calls would not be in the same scope and therefore be illegal.  This is one of the reasons I don't want to support an override for the scope checking because it would be very confusing and incompatible with future versions if any of the underlying stack usages in the background of the program change.

The Returnr is a good idea, but that implementation won't work because pointers actually are being added to the code in the first pass for labels.  The second pass just fills in static storage and built-in subroutines.  I might still try to come up with another way though.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: Features Wishlist
« Reply #2137 on: April 11, 2011, 08:55:15 pm »
It would be nice to have left and top clipping for rectangles. :)
ld a, 0
ld a, a

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Features Wishlist
« Reply #2138 on: April 13, 2011, 08:43:16 am »
Here's a slightly easier way that might be less compatible with shells:
Code: [Select]
Asm(2ADE86 2B 2B F9 C9)You don't need to place any special code at the start of the program.

It uses the fact that the OS (and probably all shells) always wraps programs in an error handler when it runs them. So if any shells don't do that, or place any extra pushes on the stack before running the program, it'll crash. But all shells have to use an error handler, or else an error will quit the shell itself.
Spoiler For Actual assembly code:
Code: [Select]
ld hl, (86DEh) ; This address is how the OS always knows how to restore the stack with APP_POP_ERR
dec hl
dec hl
ld sp, hl
ret

DrDnar, the seems very good, thank you :)

Also Quigibo, what about including in Axe commands a list of the Asm(HEX commands that may be useful for Axe programmers?
« Last Edit: April 13, 2011, 08:43:52 am by Scout »

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Features Wishlist
« Reply #2139 on: April 14, 2011, 03:29:03 am »
Also Quigibo, what about including in Axe commands a list of the Asm(HEX commands that may be useful for Axe programmers?
You (plural) should make Wiki for that. WikiTI might work, if you don't feel like setting up a separate one.

By the way, the code I posted earlier is based on my disassembly of the code that runs programs. It's definitely not something you're likely to come up with just by reading the SDK.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Features Wishlist
« Reply #2140 on: April 14, 2011, 05:50:51 am »
Also Quigibo, what about including in Axe commands a list of the Asm(HEX commands that may be useful for Axe programmers?
You (plural) should make Wiki for that. WikiTI might work, if you don't feel like setting up a separate one.

By the way, the code I posted earlier is based on my disassembly of the code that runs programs. It's definitely not something you're likely to come up with just by reading the SDK.

You're prob. right, Zeda also has a pdf with hundreds of commands.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Features Wishlist
« Reply #2141 on: April 18, 2011, 03:34:49 pm »
Yeah an Axe Wiki should be really useful. Do you think there should be one setup on this hosting or something?

Also I edited the top page poll, because it was left without an edit for far too long.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Features Wishlist
« Reply #2142 on: April 18, 2011, 03:59:32 pm »
Functions.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Features Wishlist
« Reply #2143 on: April 18, 2011, 04:07:46 pm »
Don't we already have those?

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Features Wishlist
« Reply #2144 on: April 18, 2011, 04:11:04 pm »
I'm talking about, like, expr(X-3^27)->R and wherever R is encountered, the expression X-3^27 is inserted into the ASM instead of the value R.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!