LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-20-2014, 02:54 AM   #256
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled

How would you feel about my using your stack machine on one of my products? A reasonable royalty could be worked out for you for each machine sold. I am considering using a USB to to PC connection with a PIC18 which has 16k words program space and 3.7k ram bytes. I was considering using bit byte and int all fixed point. I would prefer using java as the software would then be usable on mac windows and linux on the PC side. Programs would be small (small ram) but would use I2C, SPI, UART and possibly PWM with I2C being both a master and a slave (2 I2C) Programs and data would be sent between PC and PIC via an ascii packet. some interface would have to be developed to allow to connect the USB on PC side to user programs. Just a thought.
 
Old 08-20-2014, 06:05 AM   #257
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
No problem. Nothing in it is really proprietary, mostly what is (or should be) in a sophmore level CS class. You could even use that ZPU stack machine I ran across - that one even has a C compiler available.

It makes it easy to extend for custom use, and very small memory use. That was the point of using software stack machines - simple architecture, with easy to write applications. Anything really complex or time dependent could be added as just another instruction, or through a multiplexed instruction (like the system call instruction). The JVM had really huge things buried there - the entire automatic package loading and linking was there; I think even the network download of missing packages was there too. All of the type and object checking it did is what made the JVM huge. But the foundation is really small.
 
Old 08-21-2014, 12:26 AM   #258
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
You may have already given it to me but do you have a reference card for your stack machine instruction set. I know this will grouse you out but I was considering an interpreter that would run instructions in ascii. This would be so that the only requirement would be a com program that would hook to the usb through say com1 and edit the instructions in the micro like a basic editor - may even use line numbers.
 
Old 08-21-2014, 03:30 AM   #259
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
Well I have come full circle to FORTH. And a PIC24 - 512KB (170kwords) program area and 53KB Ram -- a great book to have: Programming a Problem Oriented Language: Forth - how the internals work by Charles H. Moore. $4 kindle price.

http://www.amazon.com/Programming-Pr...internals+work
 
Old 08-21-2014, 06:13 AM   #260
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by schmitta View Post
You may have already given it to me but do you have a reference card for your stack machine instruction set. I know this will grouse you out but I was considering an interpreter that would run instructions in ascii. This would be so that the only requirement would be a com program that would hook to the usb through say com1 and edit the instructions in the micro like a basic editor - may even use line numbers.
There is a table in the documentation.
 
Old 08-21-2014, 06:14 AM   #261
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by schmitta View Post
Well I have come full circle to FORTH. And a PIC24 - 512KB (170kwords) program area and 53KB Ram -- a great book to have: Programming a Problem Oriented Language: Forth - how the internals work by Charles H. Moore. $4 kindle price.

http://www.amazon.com/Programming-Pr...internals+work
Yup. FORTH is another approach.
 
Old 08-22-2014, 05:47 AM   #262
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
I have a question. How would you multitask a stack machine? How would you save state? Multiple stacks?
 
Old 08-22-2014, 10:42 AM   #263
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
You have to have multiple stacks at a minimum to allow for threads (this assumes sharing the code space) as well as having a way to switch stacks (saving registers and status on the stack at the same time would be useful as well).

It was what made shared memory usage (stack data + static data) machines more flexible - it was easy to have multiple stacks. Likely the most successful was the PDP-11 (still being used for some power plant controls...).

Even though it was a 16 bit base architecture, the PDP supported the use of any register (other than the PC, so all 7) for a stack. One stack (register 6) was for function call/return and had a fixed size increment (always 2). The other registers all allowed for 1/2/4/8 (4/8 for the single/double precision floating load/store instructions). On the smallest machines (no MMU) the stack was used to save the PC, and status register, then jumping loading PC and status register from the interrupt vector ( shifted two bits before use) used as an index into the first 1000 memory locations. This allowed the interrupt service function to save the registers on the stack before switching the stack pointer to a system stack. Since it was all software driven it took a bit of time, so drivers got split into two parts - ones that didn't need any registers (other than the ones it specifically saved which was rather fast), and then a more heavy handed part that would actually change stack pointers. Interrupt service and system calls would use an RTI/RTT (return from interrupt/return from interrupt suppressing trace trap) to restore the PC and status registers in an atomic manner (the status register held the current priority which is why it needed to be done atomically). I don't remember ever using the RTT, unless it was in the debugger.

BTW, there IS a way to use one stack in a threading manner - it doesn't prevent stack collisions though. Using the frame pointer to switch stacks is possible. This would allow code to partition the physical stack space into parts that could use each part as a "separate" stack, though something might need to have to add the status register to the set, the call/return instructions already do most of the work (call the "switch function", save status, then setup the frame pointer for a return, load status, then return... which would set the stack pointer to the new stack. The call/return convention saves everything but the status register, which is not exactly needed for a cooperative co-routine (at known points, the status register can be ignored - it only has the NZCV flags, and the C & V flags never got fully implemented as overflow is hard to detect directly without causing the SVM to trap on overflow itself).

Last edited by jpollard; 08-22-2014 at 11:06 AM. Reason: BTW
 
Old 08-22-2014, 03:48 PM   #264
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
Can you have a FORTH multitasking machine?
 
Old 08-22-2014, 09:52 PM   #265
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
That one, I don't know.

It should be possible - by establishing two instances of the interpreter (sharing the instructions of the interpreter) with two different code/data/stack/dictionaries. To do it within the interpreter might be a bit tricky. One (slow way) is to have the interpreter switch between threads on each interpreter action. This isn't as fast as true parallel threads, but is a simulation and since the switch is always between interpretation steps, synchronization primitives can be implemented within the language rather than within the interpreter(careful coding though, and primitives within the interpreter would be faster).

Actual parallel threads would be supported by the hardware (and associated interrupts), but that would also need synchronization primitives defined if the threads communicate with each other, and have faster interrupt response.
 
Old 08-23-2014, 02:53 PM   #266
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
probably this: http://home.iae.nl/users/mhx/i4faq.html
 
Old 08-24-2014, 02:15 AM   #267
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
SEE: http://demin.ws/blog/english/2012/09/27/fcode/ for interesting information on forth and a neat little stack machine - most of the stuff is for DOS and would need dosbox.
 
Old 08-30-2014, 12:54 PM   #268
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
Found a forth that has the right license and is written in ansi C . pForth http://www.softsynth.com/pforth/ also has file I/O . Now I need to concentrate in producing the PIC24 board for testing.
 
Old 08-30-2014, 05:26 PM   #269
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
It will be interesting to see how the project does.
 
Old 08-31-2014, 01:59 AM   #270
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
Charles Moore - The Ultimate Minimalist -- http://www.forth.com/resources/evolution/evolve_0.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions nova49 Linux - Newbie 4 07-13-2011 08:05 AM
Regular Expressions Wim Sturkenboom Programming 10 11-19-2009 02:21 AM
regular expressions. stomach Linux - Software 1 02-10-2006 07:41 AM
Regular Expressions overbored Linux - Software 3 06-24-2004 03:34 PM
help with REGULAR EXPRESSIONS ner Linux - General 23 11-01-2003 12:09 AM


All times are GMT -5. The time now is 02:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration