Fix comment spacing and added Return stack operations
This commit is contained in:
parent
968f5852bf
commit
eea718599e
153
stage2/forth.s
153
stage2/forth.s
|
@ -195,10 +195,10 @@
|
|||
&Add_Entry ; Pointer to +
|
||||
&Sub_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
POPR R1 R14
|
||||
SUB R0 R0 R1
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
POPR R1 R14 ; Get second item on Stack
|
||||
SUB R0 R0 R1 ; Perform the subtraction
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; MUL
|
||||
|
@ -208,10 +208,10 @@
|
|||
&Sub_Entry ; Pointer to -
|
||||
&MUL_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
POPR R1 R14
|
||||
MUL R0 R0 R1
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
POPR R1 R14 ; Get second item on Stack
|
||||
MUL R0 R0 R1 ; Perform the multiplication and keep bottom half
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; MULH
|
||||
|
@ -221,10 +221,10 @@
|
|||
&MUL_Entry ; Pointer to *
|
||||
&MULH_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
POPR R1 R14
|
||||
MULH R0 R0 R1
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
POPR R1 R14 ; Get second item on Stack
|
||||
MULH R0 R0 R1 ; Perform multiplcation and keep top half
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; /
|
||||
|
@ -234,10 +234,10 @@
|
|||
&MULH_Entry ; Pointer to MULH
|
||||
&DIV_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
POPR R1 R14
|
||||
DIV R0 R0 R1
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
POPR R1 R14 ; Get second item on Stack
|
||||
DIV R0 R0 R1 ; Perform division and keep top half
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; %
|
||||
|
@ -247,10 +247,10 @@
|
|||
&DIV_Entry ; Pointer to /
|
||||
&MOD_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
POPR R1 R14
|
||||
MOD R0 R0 R1
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
POPR R1 R14 ; Get second item on Stack
|
||||
MOD R0 R0 R1 ; Perform division and keep remainder
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; =
|
||||
|
@ -260,12 +260,12 @@
|
|||
&MOD_Entry ; Pointer to %
|
||||
&Equal_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R1 R14
|
||||
POPR R2 R14
|
||||
POPR R1 R14 ; Get top of stack
|
||||
POPR R2 R14 ; Get second item on Stack
|
||||
FALSE R0 ; Assume comparision is True
|
||||
CMPSKIP.E R1 R2 ; Check if they are equal and skip if they are
|
||||
TRUE R0 ; Looks like our assumption was wrong
|
||||
PUSHR R0 R14
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; !=
|
||||
|
@ -275,12 +275,12 @@
|
|||
&Equal_Entry ; Pointer to =
|
||||
&NEqual_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R1 R14
|
||||
POPR R2 R14
|
||||
POPR R1 R14 ; Get top of stack
|
||||
POPR R2 R14 ; Get second item on Stack
|
||||
FALSE R0 ; Assume comparision is True
|
||||
CMPSKIP.NE R1 R2 ; Check if they are not equal and skip if they are
|
||||
TRUE R0 ; Looks like our assumption was wrong
|
||||
PUSHR R0 R14
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; <
|
||||
|
@ -290,12 +290,12 @@
|
|||
&NEqual_Entry ; Pointer to !=
|
||||
&Less_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R1 R14
|
||||
POPR R2 R14
|
||||
POPR R1 R14 ; Get top of stack
|
||||
POPR R2 R14 ; Get second item on Stack
|
||||
FALSE R0 ; Assume comparision is True
|
||||
CMPSKIP.L R1 R2 ; Check if less than and skip if they are
|
||||
TRUE R0 ; Looks like our assumption was wrong
|
||||
PUSHR R0 R14
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; <=
|
||||
|
@ -305,12 +305,12 @@
|
|||
&Less_Entry ; Pointer to <
|
||||
&LEqual_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R1 R14
|
||||
POPR R2 R14
|
||||
POPR R1 R14 ; Get top of stack
|
||||
POPR R2 R14 ; Get second item on Stack
|
||||
FALSE R0 ; Assume comparision is True
|
||||
CMPSKIP.LE R1 R2 ; Check if they are less than or equal and skip if they are
|
||||
TRUE R0 ; Looks like our assumption was wrong
|
||||
PUSHR R0 R14
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; >
|
||||
|
@ -320,12 +320,12 @@
|
|||
&LEqual_Entry ; Pointer to <=
|
||||
&Greater_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R1 R14
|
||||
POPR R2 R14
|
||||
POPR R1 R14 ; Get top of stack
|
||||
POPR R2 R14 ; Get second item on Stack
|
||||
FALSE R0 ; Assume comparision is True
|
||||
CMPSKIP.G R1 R2 ; Check if greater and skip if they are
|
||||
TRUE R0 ; Looks like our assumption was wrong
|
||||
PUSHR R0 R14
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; >=
|
||||
|
@ -335,12 +335,12 @@
|
|||
&Greater_Entry ; Pointer to >
|
||||
&GEqual_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R1 R14
|
||||
POPR R2 R14
|
||||
POPR R1 R14 ; Get top of stack
|
||||
POPR R2 R14 ; Get second item on Stack
|
||||
FALSE R0 ; Assume comparision is True
|
||||
CMPSKIP.GE R1 R2 ; Check if they are equal and skip if they are
|
||||
TRUE R0 ; Looks like our assumption was wrong
|
||||
PUSHR R0 R14
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; AND
|
||||
|
@ -350,10 +350,10 @@
|
|||
&GEqual_Entry ; Pointer to >=
|
||||
&AND_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
POPR R1 R14
|
||||
AND R0 R0 R1
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
POPR R1 R14 ; Get second item on Stack
|
||||
AND R0 R0 R1 ; Perform AND
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; OR
|
||||
|
@ -363,10 +363,10 @@
|
|||
&AND_Entry ; Pointer to AND
|
||||
&OR_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
POPR R1 R14
|
||||
OR R0 R0 R1
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
POPR R1 R14 ; Get second item on Stack
|
||||
OR R0 R0 R1 ; Perform OR
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; XOR
|
||||
|
@ -376,10 +376,10 @@
|
|||
&OR_Entry ; Pointer to OR
|
||||
&XOR_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
POPR R1 R14
|
||||
XOR R0 R0 R1
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
POPR R1 R14 ; Get second item on Stack
|
||||
XOR R0 R0 R1 ; Perform XOR
|
||||
PUSHR R0 R14 ; Store the result
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; NOT
|
||||
|
@ -389,9 +389,9 @@
|
|||
&XOR_Entry ; Pointer to XOR
|
||||
&NOT_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14
|
||||
NOT R0 R0
|
||||
PUSHR R0 R14
|
||||
POPR R0 R14 ; Get top of stack
|
||||
NOT R0 R0 ; Bit flip it
|
||||
PUSHR R0 R14 ; Store it back onto stack
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; LIT
|
||||
|
@ -495,6 +495,7 @@
|
|||
POPR R1 R14 ; Where to put the result
|
||||
POPR R2 R14 ; Where it is coming from
|
||||
FALSE R4 ; Prepare for Zeroing
|
||||
|
||||
:Cmove_Main
|
||||
CMPSKIPI.GE R0 4 ; Loop if we have 4 or more bytes to move
|
||||
JUMP @Cmove_Slow ; Otherwise slowly move bytes
|
||||
|
@ -546,11 +547,55 @@
|
|||
:Here_Text
|
||||
"HERE"
|
||||
:Here_Entry
|
||||
&Latest_Entry ; Pointer to
|
||||
&Latest_Entry ; Pointer to LATEST
|
||||
&Here_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
PUSHR R8 R14 ; Put HERE onto stack
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; Return Stack functions
|
||||
|
||||
;; >R
|
||||
:TOR_Text
|
||||
">R"
|
||||
:TOR_Entry
|
||||
&Here_Entry ; Pointer to HERE
|
||||
&TOR_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R14 ; Get top of Parameter stack
|
||||
PUSHR R0 R15 ; Shove it onto return stack
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; R>
|
||||
:FROMR_Text
|
||||
"R>"
|
||||
:FROMR_Entry
|
||||
&TOR_Entry ; Pointer to >R
|
||||
&FROMR_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R0 R15 ; Get top of Return stack
|
||||
PUSHR R0 R14 ; Shove it onto parameter stack
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; RSP@
|
||||
:RSPFetch_Text
|
||||
"RSP@"
|
||||
:RSPFetch_Entry
|
||||
&FROMR_Entry ; Pointer to R>
|
||||
&RSPFetch_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
PUSHR R14 R15 ; Push Return stack pointer onto Parameter stack
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
;; RSP!
|
||||
:RSPStore_Text
|
||||
"RSP!"
|
||||
:RSPStore_Entry
|
||||
&RSPFetch_Entry ; Pointer to RSP@
|
||||
&ore_Text ; Pointer to Name
|
||||
NOP ; Flags
|
||||
POPR R15 R14 ; Replace Return stack pointer from parameter stack
|
||||
JSR_COROUTINE R11 ; NEXT
|
||||
|
||||
:cold_start
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue