; -*- coding: utf-8 -*- ; http://patorjk.com/software/taag/#p=display&f=Banner&t=Fast Forth ; Fast Forth For Texas Instrument MSP430FRxxxx FRAM devices ; Copyright (C) <2015> ; ; This program is free software: you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program. If not, see . FORTHWORD "{ANS_COMP}" mNEXT .IFNDEF ARITHMETIC .include "ADDON\ARITHMETIC.asm" .ENDIF .IFNDEF ALIGNMENT .include "ADDON\ALIGNMENT.asm" .ENDIF .IFNDEF PORTABILITY .include "ADDON\PORTABILITY.asm" .ENDIF .IFNDEF DOUBLE .include "ADDON\DOUBLE.asm" .ENDIF ;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 AND #1Fh,TOS ; no need to shift more than 16 JZ LSH_X LSH_1: ADD W,W SUB #1,TOS JNZ LSH_1 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 AND #1Fh,TOS ; no need to shift more than 16 JZ RSH_X RSH_1: BIC #1,SR ; CLRC RRC W SUB #1,TOS JNZ RSH_1 RSH_X: MOV W,TOS mNEXT ;https://forth-standard.org/standard/core/OnePlus ;C 1+ n1/u1 -- n2/u2 add 1 to TOS FORTHWORD "1+" ADD #1,TOS mNEXT ;https://forth-standard.org/standard/core/OneMinus ;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*" TWOTIMES ADD TOS,TOS mNEXT ;https://forth-standard.org/standard/core/TwoDiv ;C 2/ x1 -- x2 arithmetic right shift FORTHWORD "2/" 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 JL SELn1 ; n2BODY -- PFA leave PFA of created word FORTHWORD ">BODY" ADD #4,TOS mNEXT