OSDN Git Service

V201, added MSP-EXP430FR2433
[fast-forth/master.git] / ADDON / DOUBLE.asm
1 ; -*- coding: utf-8 -*-
2 ; http://patorjk.com/software/taag/#p=display&f=Banner&t=Fast Forth
3
4 ; Fast Forth For Texas Instrument MSP430FRxxxx FRAM devices
5 ; Copyright (C) <2015>  <J.M. THOORENS>
6 ;
7 ; This program is free software: you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
11 ;
12 ; This program is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ; GNU General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 ;https://forth-standard.org/standard/core/StoD
22 ;C S>D    n -- d          single -> double prec.
23             FORTHWORD "S>D"
24 STOD:       SUB     #2,PSP
25             MOV     TOS,0(PSP)
26             JMP     ZEROLESS
27
28 ;https://forth-standard.org/standard/core/TwoFetch
29 ;C 2@    a-addr -- x1 x2    fetch 2 cells ; the lower address will appear on top of stack
30             FORTHWORD "2@"
31             SUB     #2, PSP
32             MOV     2(TOS),0(PSP)
33             MOV     @TOS,TOS
34             mNEXT
35
36 ;https://forth-standard.org/standard/core/TwoStore
37 ;C 2!    x1 x2 a-addr --    store 2 cells ; the top of stack is stored at the lower adr
38             FORTHWORD "2!"
39             MOV     @PSP+,0(TOS)
40             MOV     @PSP+,2(TOS)
41             MOV     @PSP+,TOS
42             mNEXT
43
44 ;https://forth-standard.org/standard/core/TwoDUP
45 ;C 2DUP   x1 x2 -- x1 x2 x1 x2   dup top 2 cells
46             FORTHWORD "2DUP"
47             SUB     #4,PSP          ; -- x1 x x x2
48             MOV     TOS,2(PSP)      ; -- x1 x2 x x2
49             MOV     4(PSP),0(PSP)   ; -- x1 x2 x1 x2
50             mNEXT
51
52 ;https://forth-standard.org/standard/core/TwoDROP
53 ;C 2DROP  x1 x2 --          drop 2 cells
54             FORTHWORD "2DROP"
55             ADD     #2,PSP
56             MOV     @PSP+,TOS
57             mNEXT
58
59 ;https://forth-standard.org/standard/core/TwoSWAP
60 ;C 2SWAP  x1 x2 x3 x4 -- x3 x4 x1 x2
61             FORTHWORD "2SWAP"
62             MOV     @PSP,W          ; -- x1 x2 x3 x4    W=x3
63             MOV     4(PSP),0(PSP)   ; -- x1 x2 x1 x4
64             MOV     W,4(PSP)        ; -- x3 x2 x1 x4
65             MOV     TOS,W           ; -- x3 x2 x1 x4    W=x4
66             MOV     2(PSP),TOS      ; -- x3 x2 x1 x2    W=x4
67             MOV     W,2(PSP)        ; -- x3 x4 x1 x2
68             mNEXT
69
70 ;https://forth-standard.org/standard/core/TwoOVER
71 ;C 2OVER  x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2
72             FORTHWORD "2OVER"
73             SUB     #4,PSP          ; -- x1 x2 x3 x x x4
74             MOV     TOS,2(PSP)      ; -- x1 x2 x3 x4 x x4
75             MOV     8(PSP),0(PSP)   ; -- x1 x2 x3 x4 x1 x4
76             MOV     6(PSP),TOS      ; -- x1 x2 x3 x4 x1 x2
77             mNEXT