OSDN Git Service

V161
[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/TwoFetch
22 ;C 2@    a-addr -- x1 x2    fetch 2 cells ; the lower address will appear on top of stack
23             FORTHWORD "2@"
24             SUB     #2, PSP
25             MOV     2(TOS),0(PSP)
26             MOV     @TOS,TOS
27             mNEXT
28
29 ;https://forth-standard.org/standard/core/TwoStore
30 ;C 2!    x1 x2 a-addr --    store 2 cells ; the top of stack is stored at the lower adr
31             FORTHWORD "2!"
32             MOV     @PSP+,0(TOS)
33             MOV     @PSP+,2(TOS)
34             MOV     @PSP+,TOS
35             mNEXT
36
37 ;https://forth-standard.org/standard/core/TwoDUP
38 ;C 2DUP   x1 x2 -- x1 x2 x1 x2   dup top 2 cells
39             FORTHWORD "2DUP"
40             SUB     #4,PSP          ; -- x1 x x x2
41             MOV     TOS,2(PSP)      ; -- x1 x2 x x2
42             MOV     4(PSP),0(PSP)   ; -- x1 x2 x1 x2
43             mNEXT
44
45 ;https://forth-standard.org/standard/core/TwoDROP
46 ;C 2DROP  x1 x2 --          drop 2 cells
47             FORTHWORD "2DROP"
48             ADD     #2,PSP
49             MOV     @PSP+,TOS
50             mNEXT
51
52 ;https://forth-standard.org/standard/core/TwoSWAP
53 ;C 2SWAP  x1 x2 x3 x4 -- x3 x4 x1 x2
54             FORTHWORD "2SWAP"
55             MOV     @PSP,W          ; -- x1 x2 x3 x4    W=x3
56             MOV     4(PSP),0(PSP)   ; -- x1 x2 x1 x4
57             MOV     W,4(PSP)        ; -- x3 x2 x1 x4
58             MOV     TOS,W           ; -- x3 x2 x1 x4    W=x4
59             MOV     2(PSP),TOS      ; -- x3 x2 x1 x2    W=x4
60             MOV     W,2(PSP)        ; -- x3 x4 x1 x2
61             mNEXT
62
63 ;https://forth-standard.org/standard/core/TwoOVER
64 ;C 2OVER  x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2
65             FORTHWORD "2OVER"
66             SUB     #4,PSP          ; -- x1 x2 x3 x x x4
67             MOV     TOS,2(PSP)      ; -- x1 x2 x3 x4 x x4
68             MOV     8(PSP),0(PSP)   ; -- x1 x2 x3 x4 x1 x4
69             MOV     6(PSP),TOS      ; -- x1 x2 x3 x4 x1 x2
70             mNEXT