To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.pbforthOpen lugnet.robotics.rcx.pbforth in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / pbFORTH / 350
349  |  351
Subject: 
RE: hforth register usage
Newsgroups: 
lugnet.robotics.rcx.pbforth
Date: 
Fri, 19 May 2000 12:49:43 GMT
Viewed: 
1492 times
  
Ralph,

I'm trying to add an assembler word and trying to deduce register.
usage. Could you verify for me please.

It looks like the top cell on the stack is actually a register (r6).
The second cell on the stack is pointer to by r7.

Right. If you look at the beginning of h8hforth.asm, I've abstracted
the actual register names so I could move them around....here's the
snippet from the file...

; The H8/300 Forth machine register usage has to be closely intertwined with
; the RCX. The following facts from Kekoa Proudfoot's page make things a little
; clearer.
;
; 1. The RCX (and the H8/300) use r7 as the stack pointer - so will we
; 2. The RCX clobbers r6 as the first parameter passed and the return value.
;    We will use it as the top of stack item, saving it when necessary.
; 3. The RCX clobbers r3-6 when processing math functions. We'll save them
;    if we ever call these routines. Registers r3-5 are otherwise preserved.
; 4. Other parameters are passed on the stack
;
; So we can summarize the H8/300 Register usage as:
;
; R7: Data stack pointer
; R6: Top of data stack item - RCX first parameter
; R5: Return stack pointer
; R4: FORTH virtual machine instruction pointer
; R3: Available as rD
; R2: Available as rC
; R1: Available as rB
; R0: Available as rA

And here's some more comments:

;------------------------------------------------------------------------------
; ASSEMBLY MACROS
;
; NOTE THAT THESE ARE REALLY m4 MACROS, NOT as MACROS. THIS IS BECAUSE as
; TENDS TO CHOKE ON MACROS WITH "," IN THE ARGUMENT LIST...
;
; THESE MACROS DEFINITELY NEED MORE COMMENTS...DON'T FIDDLE WITH THEM UNLESS
; YOU KNOW EXACTLY WHAT m4 IS DOING HERE
;
; SEE PREVIOUS COMMENTS FOR FORTH MACHINE REGISTER DEFINITIONS
;
; rDSP,  r7
; rTOS,  r6
; rRSP,  r5
; rFIP,  r4
;------------------------------------------------------------------------------

This means that consuming a stack cell means using the value in r6
and when done pop a new value into r6 from the data stack. Similarly
pushing a new value on the stack means first pushing r6 on the stack
and putting the new value in r6.

Yes, look at the definitions for DUP and DROP...

Am I close?

Yes you are. TOnce you get your head around all the threading and
indirection, the Forth machine is pretty simple. Also, there are
enough simple words that you can use as example skeletons.

Feel free to ask more questions.

Cheers,

Ralph Hempel - P.Eng

--------------------------------------------------------
Check out pbFORTH for LEGO Mindstorms at:
<http://www.hempeldesigngroup.com/lego/pbFORTH>
--------------------------------------------------------
Reply to:      rhempel at bmts dot com
--------------------------------------------------------



Message is in Reply To:
  hforth register usage
 
Ralph, I'm trying to add an assembler word and trying to deduce register. usage. Could you verify for me please. It looks like the top cell on the stack is actually a register (r6). The second cell on the stack is pointer to by r7. This means that (...) (25 years ago, 19-May-00, to lugnet.robotics.rcx.pbforth)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR