OSDN Git Service

v206
[fast-forth/master.git] / ADDON / ANS_COMPLEMENT.asm
index 83221bf..ea9c99b 100644 (file)
 ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-    .IFNDEF ALIGNMENT
-    .include "ADDON\ALIGNMENT.asm"
-    .ENDIF
+    FORTHWORD "{ANS_COMP}"
+    mNEXT
+
     .IFNDEF ARITHMETIC
-    .include "ADDON\ARITHMETIC.asm"
+    .include "ADDON/ARITHMETIC.asm"
+    .ENDIF
+    .IFNDEF ALIGNMENT
+    .include "ADDON/ALIGNMENT.asm"
     .ENDIF
     .IFNDEF PORTABILITY
-    .include "ADDON\PORTABILITY.asm"
+    .include "ADDON/PORTABILITY.asm"
     .ENDIF
     .IFNDEF DOUBLE
-    .include "ADDON\DOUBLE.asm"
+    .include "ADDON/DOUBLE.asm"
     .ENDIF
 
+;https://forth-standard.org/standard/core/AND
+;C AND    x1 x2 -- x3           logical AND
+            FORTHWORD "AND"
+ANDD        AND     @PSP+,TOS
+            mNEXT
+
+;https://forth-standard.org/standard/core/OR
+;C OR     x1 x2 -- x3           logical OR
+            FORTHWORD "OR"
+ORR         BIS     @PSP+,TOS
+            mNEXT
+
+;https://forth-standard.org/standard/core/XOR
+;C XOR    x1 x2 -- x3           logical XOR
+            FORTHWORD "XOR"
+XORR        XOR     @PSP+,TOS
+            mNEXT
+
+;https://forth-standard.org/standard/core/INVERT
 ;C INVERT   x1 -- x2            bitwise inversion
             FORTHWORD "INVERT"
 INVERT      XOR     #-1,TOS
             mNEXT
 
+;https://forth-standard.org/standard/core/LSHIFT
 ;C LSHIFT  x1 u -- x2    logical L shift u places
             FORTHWORD "LSHIFT"
 LSHIFT      MOV     @PSP+,W
@@ -47,6 +70,7 @@ LSH_1:      ADD     W,W
 LSH_X:      MOV     W,TOS
             mNEXT
 
+;https://forth-standard.org/standard/core/RSHIFT
 ;C RSHIFT  x1 u -- x2    logical R shift u places
             FORTHWORD "RSHIFT"
 RSHIFT      MOV     @PSP+,W
@@ -59,26 +83,19 @@ RSH_1:      BIC     #1,SR           ; CLRC
 RSH_X:      MOV     W,TOS
             mNEXT
 
-;C 1+      n1/u1 -- n2/u2       add 1 to TOS
-            FORTHWORD "1+"
-ONEPLUS     ADD     #1,TOS
-            mNEXT
-
-;C 1-      n1/u1 -- n2/u2     subtract 1 from TOS
-            FORTHWORD "1-"
-ONEMINUS    SUB     #1,TOS
-            mNEXT
-
+;https://forth-standard.org/standard/core/TwoTimes
 ;C 2*      x1 -- x2         arithmetic left shift
             FORTHWORD "2*"
-TWOSTAR     ADD     TOS,TOS
+TWOTIMES    ADD     TOS,TOS
             mNEXT
 
+;https://forth-standard.org/standard/core/TwoDiv
 ;C 2/      x1 -- x2        arithmetic right shift
             FORTHWORD "2/"
-TWOSLASH    RRA     TOS
+TWODIV      RRA     TOS
             mNEXT
 
+;https://forth-standard.org/standard/core/MAX
 ;C MAX    n1 n2 -- n3       signed maximum
             FORTHWORD "MAX"
 MAX:        CMP     @PSP,TOS    ; n2-n1
@@ -86,6 +103,7 @@ MAX:        CMP     @PSP,TOS    ; n2-n1
 SELn2:      ADD     #2,PSP
             mNEXT
 
+;https://forth-standard.org/standard/core/MIN
 ;C MIN    n1 n2 -- n3       signed minimum
             FORTHWORD "MIN"
 MIN:        CMP     @PSP,TOS    ; n2-n1
@@ -93,17 +111,20 @@ MIN:        CMP     @PSP,TOS    ; n2-n1
 SELn1:      MOV     @PSP+,TOS
             mNEXT
 
+;https://forth-standard.org/standard/core/PlusStore
 ;C +!     n/u a-addr --       add to memory
             FORTHWORD "+!"
 PLUSSTORE   ADD     @PSP+,0(TOS)
             MOV     @PSP+,TOS
             mNEXT
 
+;https://forth-standard.org/standard/core/CHAR
 ;C CHAR   -- char           parse ASCII character
             FORTHWORD "CHAR"
 CHARR       mDOCOL
             .word   FBLANK,WORDD,ONEPLUS,CFETCH,EXIT
 
+;https://forth-standard.org/standard/core/BracketCHAR
 ;C [CHAR]   --          compile character literal
             FORTHWORDIMM "[CHAR]"        ; immediate
 BRACCHAR    mDOCOL
@@ -111,6 +132,7 @@ BRACCHAR    mDOCOL
             .word   lit,lit,COMMA
             .word   COMMA,EXIT
 
+;https://forth-standard.org/standard/core/FILL
 ;C FILL   c-addr u char --  fill memory with char
             FORTHWORD "FILL"
 FILL        MOV     @PSP+,X     ; count
@@ -124,24 +146,28 @@ FILL_1:     MOV.B   TOS,0(W)    ; store char in memory
 FILL_X:     MOV     @PSP+,TOS   ; pop new TOS
             mNEXT
 
+;https://forth-standard.org/standard/core/HEX
             FORTHWORD "HEX"
 HEX         MOV     #16,&BASE
             mNEXT
 
+;https://forth-standard.org/standard/core/DECIMAL
             FORTHWORD "DECIMAL"
 DECIMAL     MOV     #10,&BASE
             mNEXT
 
+;https://forth-standard.org/standard/core/p
 ;C (                \  --     paren ; skip input until )
             FORTHWORDIMM "\40"      ; immediate
-LPAREN      mDOCOL
+PARENT       mDOCOL
             .word   lit,')',WORDD,DROP,EXIT
 
-    .IFDEF LOWERCASE
-
+;https://forth-standard.org/standard/core/Dotp
 ; .(                \  --     dotparen ; type comment immediatly.
             FORTHWORDIMM ".\40"        ; immediate
-DOTLPAREN   mDOCOL
+DOTPAREN    mDOCOL
+
+    .IFDEF LOWERCASE
             .word   CAPS_OFF
             .word   lit,')',WORDD
             .word   CAPS_ON
@@ -149,14 +175,12 @@ DOTLPAREN   mDOCOL
             .word   EXIT
     .ELSE
 
-; .(                \  --     dotparen ; type comment immediatly.
-            FORTHWORDIMM ".\40"        ; immediate
-DOTLPAREN   mDOCOL
             .word   lit,')',WORDD
             .word   COUNT,TYPE
             .word   EXIT
     .ENDIF ; LOWERCASE
 
+;https://forth-standard.org/standard/core/SOURCE
 ;C SOURCE   -- adr u    current input buffer
             FORTHWORD "SOURCE"
             SUB     #4,PSP
@@ -165,7 +189,18 @@ DOTLPAREN   mDOCOL
             MOV     &SOURCE_ADR,0(PSP)
             mNEXT
 
-; >BODY     -- PFA      leave PFA of created word
-            FORTHWORD ">BODY"
-            ADD     #4,TOS
-            mNEXT
+;https://forth-standard.org/standard/core/toIN
+;C >IN     -- a-addr       holds offset in input stream
+            FORTHWORD ">IN"
+FTOIN       mDOCON
+            .word   TOIN    ; VARIABLE address in RAM space
+
+
+    .IFNDEF PAD
+;https://forth-standard.org/standard/core/PAD
+; PAD           --  pad address
+            FORTHWORD "PAD"
+PAD         mDOCON
+            .WORD    PAD_ORG
+
+    .ENDIF
\ No newline at end of file