Author Topic: Features Wishlist  (Read 620941 times)

0 Members and 3 Guests are viewing this topic.

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 #2100 on: April 09, 2011, 08:20:26 pm »
Which one?
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 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 #2101 on: April 09, 2011, 08:31:16 pm »
Can we have a feature like "Zeros()," but for any data.  For instance, something like this:
Command(1,12) would be the same as [010101010101010101010101]
Command([56],4) would be the same as [56565656]
Command(127,6) would be the same as Data(127,127,127,127,127,127)
Potentially, this command could even be used for repeating sets of data.  For instance:
Command([010203],12) would be the same as [010203010203010203010203]
Command("Text"[00],15) would be the same as "Text"[00]"Text"[00]"Text"[00]

So, what do you think?  Could this be a command?  I think it's a good idea, to avoid situations like this. :)

I really like that idea. What about changing Zeros( (det() to something more universal?




Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Features Wishlist
« Reply #2102 on: April 09, 2011, 08:59:14 pm »
Can we have a feature like "Zeros()," but for any data.  For instance, something like this:
Command(1,12) would be the same as [010101010101010101010101]
Command([56],4) would be the same as [56565656]
Command(127,6) would be the same as Data(127,127,127,127,127,127)
Potentially, this command could even be used for repeating sets of data.  For instance:
Command([010203],12) would be the same as [010203010203010203010203]
Command("Text"[00],15) would be the same as "Text"[00]"Text"[00]"Text"[00]

So, what do you think?  Could this be a command?  I think it's a good idea, to avoid situations like this. :)

I really like that idea. What about changing Zeros( (det() to something more universal?

I would suggest changing the token replacement to Block(). Feeding 1 argument would create a block of the specified size filled with zeroes. Feeding 2 arguments would create a block of the specified size filled with a specified value. Maybe you could even add a Block()r command for creating a block filled with a specified word while you're at it, although this probably isn't as necessary as a normal byte-filling block command.
« Last Edit: April 09, 2011, 09:00:07 pm by Runer112 »

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 #2103 on: April 09, 2011, 09:23:25 pm »
I would suggest changing the token replacement to Block(). Feeding 1 argument would create a block of the specified size filled with zeroes. Feeding 2 arguments would create a block of the specified size filled with a specified value.

I like that idea. It would make it compatible with previous versions.




Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Features Wishlist
« Reply #2104 on: April 09, 2011, 09:24:01 pm »
I would suggest changing the token replacement to Block(). Feeding 1 argument would create a block of the specified size filled with zeroes. Feeding 2 arguments would create a block of the specified size filled with a specified value.

I like that idea. It would make it compatible with previous versions.

That's the idea. :)

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 #2105 on: April 09, 2011, 10:25:19 pm »
Maybe it would be cool to expose the ex (sp),hl instruction somehow, which basically pops a value (and returns it) then pushes the previous value. Alternatively, think of it as swapping the previous value with the value on the top of the stack. (Of course, this command should be valid only if something has been pushed to the stack)

Edit:
Maybe ->πr? Which would mean storing to the stack while returning the previous value.

Edit2:
I suppose the right side of binary operations (which you mentioned before) will be optimized? For example, should compile to pop de \ add hl,de.

Edit3:
Hmm, this:
Code: [Select]
{A*3->π->π}->X {π+1}->Y {π+2}->ZCould even be optimized to:
Code: [Select]
{A*3->π}->X {π+1->π}->Y {π+1}->ZBut yeah, you did need an example of nested pushes/pops anyway.
« Last Edit: April 09, 2011, 11:58:47 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

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 #2106 on: April 10, 2011, 01:12:31 pm »
A way to Exit the program from within a subroutine, because both Return and goto end-of-program just end the subroutine.
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 Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Features Wishlist
« Reply #2107 on: April 10, 2011, 01:14:15 pm »
A way to Exit the program from within a subroutine, because both Return and goto end-of-program just end the subroutine.

Code: [Select]
Lbl SR
.CODE
Return

Lbl CP
.CODE
Goto E
Return

.Code
Lbl E
« Last Edit: April 10, 2011, 01:28:03 pm by Scout »

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 #2108 on: April 10, 2011, 01:26:38 pm »
A way to Exit the program from within a subroutine, because both Return and goto end-of-program just end the subroutine.

There's no real command to do that in ASM either. In fact, you could think of the program itself as a big subroutine that calls smaller subroutines. There's are JForce bcalls in ASM, but they leave an extra copy of the program in RAM, causing a memory leak.

There are workarounds though, but the one Scout suggested will not work. It just returns control to wherever the routine was called at the first Return (at the end of the program).

Also Scout, where are Lbl SR and Lbl CP defined?
« Last Edit: April 10, 2011, 01:29:52 pm by Deep Thought »




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Features Wishlist
« Reply #2109 on: April 10, 2011, 01:28:17 pm »
Deep: Mine will work, I didn't mean sub( but Lbl.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Features Wishlist
« Reply #2110 on: April 10, 2011, 01:30:15 pm »
Scout, that would not work. The problem has to do with the state of the stack when hitting a Return. If you're in a subroutine, the return address to actually exit the program, and not just return from the subroutine, is somewhere hidden in the stack. When your program is just starting up, the stack will look something like this:
Code: [Select]
OS return location
Stuff
...

But when you're in a subroutine, the stack will look something like this:
Code: [Select]
Subroutine return location
Possibly more subroutine return locations
...
OS return location
Stuff
...

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, 02:08:16 pm by Runer112 »

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 #2111 on: April 10, 2011, 01:31:37 pm »
Nope, it won't.

When you call sub(CP), it'll jump to Lbl E, which returns -- back to the place where you did sub(CP), which means it never runs the second Return at the end of Lbl CP.

EDIT: Runer112's routine above is pretty much the only way to do it without problems. Use that.
« Last Edit: April 10, 2011, 01:32:19 pm by Deep Thought »




Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Features Wishlist
« Reply #2112 on: April 10, 2011, 01:31:54 pm »
My best suggestion is to store sp somewhere, and then load sp back when you are done, and then return.  This works because something calls $9D95 or your ASM program, and the address to return to is stored at sp.  So you store sp at the start to some location, and then change it back to sp when you are done, and return.

EDIT: Uber-ninja'd with code.
« Last Edit: April 10, 2011, 01:33:12 pm by graphmastur »

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Features Wishlist
« Reply #2113 on: April 10, 2011, 01:42:10 pm »
I've always wondered: Wouldn't the method Runer described cause a memory leak in the stack because everything wasn't poped off the stack before placing the return address on the stack?

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 #2114 on: April 10, 2011, 01:42:52 pm »
What about Basic's Stop? How does that work?
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!