6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Apr 25, 2024 7:46 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Mon Jun 12, 2017 11:54 pm 
Offline

Joined: Wed Jan 08, 2014 3:31 pm
Posts: 559
Not strickly a 6502 topic, but it is relevant. The 6502 and all other machines I've used Forth on were byte addressable machines. On such architectures the word CELL returns a number like 2 or 4. But there are computers that are word machines like the PDP-8 (12 bit words and address space). Such architectures refer to the first 12 bits as address 0, the next 12 as 1, and so on.

Assuming that you could port Forth to something like a PDP-8, would CELL return 1?


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 12:22 am 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 269
Location: Placerville, CA
Probably depends on the cell size of the implementation. I can't remember if there were any standard Forth implementations for PDP-8, say, but doesn't the standard specify a minimum cell size of 16 bits? I'd imagine that a PDP-8 Forth would likely use two words per cell. On the other hand, a larger word-addressable machine (there were a few 16-bit word-addressable computers, and multiple 18-, 24-, and 36-bit ones) probably would use one word per cell.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 3:24 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8427
Location: Southern California
commodorejohn wrote:
but doesn't the standard specify a minimum cell size of 16 bits?

I just looked in my old paper ANS Forth spec and found what I was sure was there, §3.1.3:
"Cells shall be at least one address unit wide and contain at least 16 bits. The size of a cell shall be an integral multiple of the size of a character."
Obviously my HP-71's Forth wouldn't qualify. It came around before ANS Forth anyway; but since it has a 4-bit data bus and a 20-bit address bus, a cell is 20 bits, and a character is 8 bits or two address units. (It addresses a meganybble, or half a megabyte without banking.) That was my intro to Forth, in about 1989 or 1990.

_________________
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 Jun 13, 2017 3:37 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1925
Location: Sacramento, CA, USA
I just looked at my 65m32 Forth, and CELL is ( -- 1 ) . CELL+ is defined as 1+ and CELLS is a no-op. Also, C@ is defined as @ , C! is ! , and ALIGN and ALIGNED are no-ops.

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 4:02 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3346
Location: Ontario, Canada
Martin_H wrote:
Assuming that you could port Forth to something like a PDP-8, would CELL return 1?

Apparently not, if it's ANS compliant. (Thanks, Garth, for the reference.) You'd need two 12-bit words to reach the 16-bit minimum for a cell, so CELL would return 2. But certainly a non-compliant Forth could use 12-bit cells and reside in a 4 Kword space, in which case CELL would return 1. Except the word CELL might not exist -- you'd have to trim a lot of the non-essentials in order to fit in so cramped a space! But the speed would far exceed that of an ANS-compliant implementation. :twisted:

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 6:53 am 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 269
Location: Placerville, CA
GARTHWILSON wrote:
I just looked in my old paper ANS Forth spec and found what I was sure was there, §3.1.3:
"Cells shall be at least one address unit wide and contain at least 16 bits. The size of a cell shall be an integral multiple of the size of a character."

Ah, that's an interesting wrinkle. So for the PDP-8, that would seem to imply a minimum cell size of two words (24 bits) unless the size of a character is itself implementation-dependent.

Lord only knows what 18-bit systems would do.

Dr Jefyll wrote:
Apparently not, if it's ANS compliant. (Thanks, Garth, for the reference.) You'd need two 12-bit words to reach the 16-bit minimum for a cell, so CELL would return 2. But certainly a non-compliant Forth could use 12-bit cells and reside in a 4 Kword space, in which case CELL would return 1. Except the word CELL might not exist -- you'd have to trim a lot of the non-essentials in order to fit in so cramped a space!

Well, if it's an -8 with extended addressing (which is, I think, most of them,) there's up to 32 KW to work with, although I'm not up on what the ANS standard implies for address sizes and/or segmented address space.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 7:10 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
commodorejohn wrote:
Lord only knows what 18-bit systems would do.

No problem:
Quote:
The DEC SIXBIT format packs three characters in each 18-bit word each 6-bit character obtained by stripping the high bits from the 7-bit ASCII code, which folds lowercase to uppercase letters.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 1:03 pm 
Offline

Joined: Wed Jan 08, 2014 3:31 pm
Posts: 559
Thanks for the replies. It sounds like a word addressable architecture that is at least 16 bits with a word size that is a multiple of 8 could have a cell of size 1. For example if we had a 16 bit machine with a 16 bit address space, then CELL would return 1 and be 16 bits wide.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 1:05 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
Bruce Clark ported EForth to the 6502 and the 65Org16 - that's a word-addressed machine. See
http://biged.github.io/6502-website-arc ... eforth.htm for a download.

Quote:
The files are:

EFO16I##.ASM - eForth for the 65org16, indirect threaded code (ITC)
EFO16S##.ASM - eForth for the 65org16, subroutine threaded code (STC)
EFHYBI##.ASM - a version of EFO16I01.ASM that runs on the 65C816
EFHYBS##.ASM - likewise for EFO16S01.ASM


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 1:08 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
(We might yet try to port EForth to the OPC5 machine, which is a 16-bit word-oriented machine expressed in one page of code. Judging by recent experience porting Bruce's pi program from 65Org16 to OPC5, it shouldn't be too challenging.)


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 30, 2017 9:05 am 
Offline

Joined: Thu Nov 30, 2017 7:36 am
Posts: 5
Martin_H wrote:
Assuming that you could port Forth to something like a PDP-8, would CELL return 1?


I have, and yes, it does. I feel that wasting 4 bits per character in a string isn't too bad and that strict adherence to the standard isn't necessary. EDIT: Also, I'm ok with just addressing one field. (A "field" is 4K words, i.e. what can be adressed with a 12-bit word.)

Now, the PDP-10 is also word adressed but with 36-bit words. That's more of a conundrum.


Last edited by larsbrinkhoff on Thu Nov 30, 2017 7:15 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 30, 2017 3:53 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1925
Location: Sacramento, CA, USA
larsbrinkhoff wrote:
Now, the PDP-10 is also word adressed but with 36-bit words. That's more of a conundrum.

I'm interested in any of your detailed thoughts on this, for slightly selfish reasons.

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 30, 2017 7:03 pm 
Offline

Joined: Thu Nov 30, 2017 7:36 am
Posts: 5
barrym95838 wrote:
I'm interested in any of your detailed thoughts on this, for slightly selfish reasons.


I hesitate to go off topic here, so let me know if I'm out of line.

I see three options, none quite satisfying:

  • Have the addressing unit be the word. CELL = 1. Store characters one per word and waste lots of space.
  • As previous option, but pack four (or five) characters per word. So there's no straightforward way to iterate over characters in a string. Add new wordset to deal with packed strings?
  • Have the addressing unit be a 9-bit byte. CELL = 4. The PDP-10 has byte pointers, but it would probably be somewhat painful to go back and forth between word addresses and byte pointers.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 30, 2017 9:15 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
I think option 1 with some PACK and UNPACK utility functions would be the most useful and most performant in the general case.

Strings would be represented as packed words, rather than arrays of characters, then they're treated as a "whole", rather than a collection.

You could also implement "PC@" and "PC!" to act directly on the packed structures. Good for onesey twosey stuff, but if you were doing serious work, you would be better to unpack the structure and work from that. Take the memory hit, do big operations, and then repack it.

Pascal formalized around the concept of "PACKED" for arrays and records to work with machine like the CDC 60 Bit machines, and things like the 36 bit PDPs.


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 14, 2018 8:58 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851
whartung wrote:
You could also implement "PC@" and "PC!" to act directly on the packed structures.

PC@ and PC! are words in FPC, a Forth by Tom Zimmer that runs under MS-DOS. They, as well as P@ and P! are used to access i/o ports.

Cheers,
Jim


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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: