[comp.lang.forth] how to make NMI forth call assembly routines

bryan@intvax.UUCP (Jon R Bryan) (02/26/91)

From article <157997@felix.UUCP>, by dennisg@felix.UUCP (Dennis Griesser):
> I have a single-board computer from New Micros Inc, based on their forth
> interpreter masked into the Motorola 68HC11.  As a novice to forth, I have
> enjoyed fiddling around with the thing.
> 
> Now I would like to write some assembly-language routines for time-critical
> work that can be called from forth.  I have both the hardware manual (thin)
> for the SBC and the 318-page MAX-FORTH reference manual, but neither gives
> plain-English instructions for doing this.  I suspect that a well-seasoned
> forth user would find this documentation sufficient, but not me.  I have
> tried permutations of the following, to no avail:
> 	CODE NAME1 01 END-CODE
> 	CODE-SUB NAME2 01 39 END-CODE
> (where the 01 is a NOP and 39 is RTS)
> 
> I have already hand-assembled the (short) routines.  I don't mind feeding
> hex into the SBC.
> 
> I have noticed other users of NMI forth on this board.  Would anybody care to
> explain how to hook in these routines?  Thanks!

Try this:
HEX

( I don't have the manuals here, but I remember this constant )
( being defined somewhere.  The "easy" way to do this is to   )
( spend $50 on the assembler that NMI sells.                  )

???? CONSTANT NEXT

CODE NAME1   ( -- )
	01 C, ( NOP )
	7E C, ( JMP extended )
	NEXT ,
END-CODE

CODE-SUB NAME2   ( -- )
	01 C, ( NOP )
	39 C, ( RTS )
END-CODE

( If you have NMI's assembler it looks like this: )

CODE NAME1   ( -- )
	NOP,
	NEXT JMP,
END-CODE

CODE-SUB NAME2   ( -- )
	NOP,
	RTS,
END-CODE
-- 
Jon R. Bryan	<=>	bryan@intvax.UUCP
Sandia National Laboratories
Intelligent Machine Principles Division
Albuquerque, New Mexico