+TheBF Posted May 7 Author Share Posted May 7 I have been cleaning up the sieve benchmark code written in ASMForth. I am beginning to think I am onto something with ASMForth, which is a "Machine Forth" written specifically for TSM9900 versus trying to shoe-horn Chuck Moore's CPU architecture onto the 9900. I expanded the translation table at the top of the source code so here is a syntax side-by-side comparison. \ TI Assembler ASMForth Equivalent \ ------------------- ------------------------- \ MOV R1,R4 R1 R4 ! \ MOV *R1,R4 R1 @ R4 ! \ MOV *R1+,R4 R1 @+ R4 ! \ data \ * n/a HEX \ MEAT EQU >BEEF BEEF CONSTANT MEAT \ LABEL DATA 0000 VARIABLE LABEL \ LABL2 DATA >DEAD CREATE LABL2 DEAD , \ TABL BSS >100 CREATE TABL 100 ALLOT \ LI R0,MEAT MEAT R0 #! \ AI R0,7 7 R0 #+! \ MOV @LABEL,R4 LABEL @ R4 ! \ MOV R3,@LABEL R3 LABEL ! ( store is smart and compiles symbolic if needed) \ MOV @LABL2,@LABEL LABL2 @ LABEL ! And here are some Forth "primitives" written in ASMForth to show something real. The definer called NATIVE: creates sub-routine "objects" that compile code at compile time but at runtime they compile themselves into your code. \ Hi-level Forth word compiled as native sub-routines ASMFORTH NATIVE: 0= TOS 0 CI, EQ ;NATIVE NATIVE: COUNT ( Caddr -- addr len ) DUP NOS 1+ *TOS TOS C! TOS 8 RSHIFT ;NATIVE NATIVE: BOUNDS ( adr len -- adr2 adr1) NOS R1 ! TOS NOS + R1 TOS ! ;NATIVE NATIVE: ?TERMINAL ( -- ?) 0020 @@ BL, NOT \ calls ROM code to test BREAK key ;NATIVE NATIVE: /STRING ( addr len n -- addr' len' ) TOS NOS - TOS 3RD + DROP ;NATIVE NATIVE: * ( n n -- n') \ multiply operator NOS^ R3 ! TOS R3 MPY, ;NATIVE NATIVE: UM* ( n n -- d) \ unsigned mixed multiply NOS TOS MPY, R5 NOS ! ;NATIVE NATIVE: * ( n n -- n) NOS^ R3 ! TOS R3 MPY, \ cool trick ! result goes to R4 ie: TOS ;NATIVE NATIVE: UM/MOD ( d n -- n n) TOS R0 ! NOS^ TOS ! NOS R5 ! R0 TOS DIV, R5 NOS ! ;NATIVE NATIVE: U*/ ( n n n -- n ) TOS R0 ! \ move TOS cache register R0 (divisor) NOS^ R1 ! \ POP multiplier to R1 NOS^ TOS ! \ multiplicand -> TOS R1 MPY, \ 32 bit multiply R5 R3 ! \ low order word to R3 R0 TOS DIV, \ unsigned division ;NATIVE NATIVE: U/ ( n n -- n ) \ unsigned divide. FAST but be careful TOS R0 ! \ divisor->R0 TOS OFF NOS^ R5 ! \ MOVE low word to r5 R0 TOS DIV, \ perform unsigned division ;NATIVE 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.