TOS in zero page? #375
Replies: 22 comments 1 reply
-
Paging @chitselb. Pettil does use a zero page TOS. |
Beta Was this translation helpful? Give feedback.
-
Hi! Yes I considered it, but |
Beta Was this translation helpful? Give feedback.
-
Right, in many words the size comes out the same. A few words take a hit, but I believe there are more cases where it's a win. In particular, memory fetches and stores benefit a lot from being able to use the address TOS in zero page indirect mode. I'm coding up both versions for a new Forth, so I'll get back with actual code samples and total size for the kernel. |
Beta Was this translation helpful? Give feedback.
-
Indeed |
Beta Was this translation helpful? Give feedback.
-
My ephasis is on small size, not speed. It turns out I was able to optimize the no-TOS version quite a bit by sharing code between primitives. I haven't been able to share as much code in the TOS version. Here's a detailed listing of primitives, with code size in bytes.
|
Beta Was this translation helpful? Give feedback.
-
Hi!
Ok, so I take it then that it is better to keep things as is and not have a
dedicated TOS element in zp.
Thanks for sharing!
On Tue, 5 Sep 2017 at 07:38, Lars Brinkhoff ***@***.***> wrote:
My ephasis is on small size, not speed. It turns out I were able to
optimize the no-TOS version quite a bit by sharing code between primitives.
I hasn't been able to share as much code in the TOS version.
Here's a detailed listing of primitives, with code size in bytes.
No TOS TOS
dup 10 10
drop 2 10
2drop 3 4
swap 17 17
over 7 10
>r 18 19
r> 13 21
r@ 16 19
+ 15 15
1+ 7 7
and, or, xor 12 13
invert 13 13
2* 5 5
2/ 8 8
@ 24 17
c@ 6 7
! 15 10
c! 8 9
branch? 6 10
*Total* 205 224
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#199 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADG-O9vMQ01YMwpP-H14v_j8fs5L7C7Tks5sfN5wgaJpZM4PKCBl>
.
--
---
http://www.littlesounddj.com
|
Beta Was this translation helpful? Give feedback.
-
Not if you go for the smallest code size. I'm not sure if you want to optimize for speed. Here are some code samples. They're in my own Forth assembler syntax.
|
Beta Was this translation helpful? Give feedback.
-
For Durexforth I came to think that speed is more important than size. C64 anyway has "a lot" of RAM and so far I haven't gotten complaints that people run out. Speed improvements are more noticeable. I am not sure if that is an argument in either direction for the TOS. But anyway. |
Beta Was this translation helpful? Give feedback.
-
Update! I have now managed to squeeze down the TOS version to the exact same size as the no-TOS version. I'm not sure what this means for speed. Zero page addressing is one cycle faster than indexed addressing, but the need to copy data in and out of TOS may make it come out the same or slower anyway. |
Beta Was this translation helpful? Give feedback.
-
A thing that would weigh slightly in favor of "classic" approach then is
that DROP/2DROP can be an inlined inx.
On Tue, 5 Sep 2017 at 10:13, Lars Brinkhoff ***@***.***> wrote:
Update! I have now managed to squeeze down the TOS version to the exact
same size as the no-TOS version.
I'm not sure what this means for speed. Zero page addressing is one cycle
faster than indexed addressing, but the need to copy data in and out of TOS
may make it come out the same or.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#199 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADG-O9kkXcvSH2LmSs-Uuv-BYkYBYIG1ks5sfQKOgaJpZM4PKCBl>
.
--
---
http://www.littlesounddj.com
|
Beta Was this translation helpful? Give feedback.
-
Sorry for being late. I just saw this in my gmail. One of the main reasons for isolated standalone separated TOS is so it could be used as a (tos),y pointer without having to create a pointer from stackl+stackh. Another big reason is that unindexed z.p. operations are a clock or two faster than using zp,x for everything. But it would probably speed things up a bit. Trading off speed vs. size isn't always fun. Garth Wilson thinks the PETTIL approach to the data stack was a bad idea, and he's usually right about these things. |
Beta Was this translation helpful? Give feedback.
-
Thanks @chitselb. What did Garth think was right, just a plain stack with no special TOS treatment? |
Beta Was this translation helpful? Give feedback.
-
At this point I don't even remember. It was a couple years ago at least, somewhere on forum.6502.org Forth section, in a thread I participated in (if you're in a mood to go searching I'd be curious to see what he said again, please drop a link here?) |
Beta Was this translation helpful? Give feedback.
-
well. that was easy. http://forum.6502.org/viewtopic.php?f=9&t=3280 |
Beta Was this translation helpful? Give feedback.
-
Looks like this thread: |
Beta Was this translation helpful? Give feedback.
-
I concur. That is the thread, http://forum.6502.org/viewtopic.php?p=11215#p11215 and that is the message I refer to. We're both going on gut-feel here, it seems, with few solid metrics. I have done some small amount of experimenting with benchmarking PETTIL vs. Blazin' Forth in side-by-side emulators, and PETTIL beats the pants off of it. Probably that's more the direct-threaded vs. indirect-threaded thing, and the attention I try to pay to speed/size tradeoffs throughout |
Beta Was this translation helpful? Give feedback.
-
It looks to me like Garth is also objecting against a split stack, i.e. low bytes separated from high bytes. |
Beta Was this translation helpful? Give feedback.
-
[Reopening this issue to preserve the interesting discussion] |
Beta Was this translation helpful? Give feedback.
-
FWIW, this Forth went from plain to split zeropage stack in v1.32. The change was mentioned in the changelog as a "nice optimization" :) |
Beta Was this translation helpful? Give feedback.
-
With a split-stack-separated-TOS setup, it's cumbersome to copy the 2OS to and from the TOS. But burying stuff just underneath in the stackl,x stackh,x memory is pretty cheap and convenient, and primitives could take advantage of that. Consider the following, that pops
I have similar routines,
The idea is to have single reusable chunks of code to move small blocks of data among the various entities: memory; machine stack; data stack; N-area |
Beta Was this translation helpful? Give feedback.
-
FYI, I did some soul searching, trying to figure out the reason why I did not put TOS as a separate zp register already. |
Beta Was this translation helpful? Give feedback.
-
Interesting topic, I should really spend some time reading the issue-graveyard to get insights from the main development of Durexforth :D |
Beta Was this translation helpful? Give feedback.
-
Hello,
Have you considered putting the top element of the data stack in the zero page? I have a vague sense this would be a win.
Beta Was this translation helpful? Give feedback.
All reactions