6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 5:58 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Feb 23, 2021 7:44 am 
Offline

Joined: Sun Apr 26, 2020 3:08 am
Posts: 357
Just for fun I wanted to see how much memory could be saved with a headerless Forth and I came up with this definition.


0 VARIABLE BSCNTR

: HDRLESS LATEST BEGIN DUP C@ 1F AND 3 + BSCNTR +! PFA LFA @ DUP 0= UNTIL DROP BSCNTR @ . ;

The +3 is for: one byte for the Name Field byte and two for the Link field address, which would not be needed as well.

Currently I could save about 2700 bytes out of 16.4 k used so far. Which is about 16.5%. Doesn't seem like a lot.
The 16.4 k is just strictly memory used by word definitions and does not included memory used by errors, buffers or the User Area.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 23, 2021 8:56 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8428
Location: Southern California
On the automated test equipment I did at my last place of work around 30 years ago, I got a much bigger percentage; but I had a lot of longish names like PAUSE_TEST# which was a two-byte variable.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 23, 2021 4:22 pm 
Offline

Joined: Sun Apr 26, 2020 3:08 am
Posts: 357
GARTHWILSON wrote:
On the automated test equipment I did at my last place of work around 30 years ago, I got a much bigger percentage; but I had a lot of longish names like PAUSE_TEST# which was a two-byte variable.

I can see a few factors affecting the percentage.
Working on an 8-bit, 16-bit, 32-bit or 64-bit system would have various percentages saved. An 8-bit system with 32-bit support creates a lot of overhead in the main part of the Forth system, which is probably why my percentage is so low. A 16-bit system would probably show a higher percentage of space saved due to a much smaller footprint for the Forth system due to better 16-bit mnemonics.

I suppose in all actuality, one should really only take in account new words added to the Forth system since the words are more likely to be definitions rather than primitives. Which would make the percentage-saved closer among all systems.


Top
 Profile  
Reply with quote  
PostPosted: Sun Feb 05, 2023 9:47 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851
IamRob wrote:
Just for fun I wanted to see how much memory could be saved with a headerless Forth and I came up with this definition.


0 VARIABLE BSCNTR

: HDRLESS LATEST BEGIN DUP C@ 1F AND 3 + BSCNTR +! PFA LFA @ DUP 0= UNTIL DROP BSCNTR @ . ;

The +3 is for: one byte for the Name Field byte and two for the Link field address, which would not be needed as well.

Currently I could save about 2700 bytes out of 16.4 k used so far. Which is about 16.5%. Doesn't seem like a lot.
The 16.4 k is just strictly memory used by word definitions and does not included memory used by errors, buffers or the User Area.


With Fleet Forth I would define this:
Code:
: HSIZE  ( -- )
   0 WITH-WORDS
   C@ $1F AND 3 + + ;

And use it like this:
Code:
ASSEMBLER HSIZE .
EDITOR HSIZE .
FORTH HSIZE .

Or like this:
Code:
ASSEMBLER HSIZE
EDITOR HSIZE +
FORTH HSIZE + .



Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: