[gforth] / gforth / asm / basic.fs  

gforth: gforth/asm/basic.fs


1 : pazsan 1.1 \ asmbasic.fs basic assebmler definitions
2 :    
3 : anton 1.3 \ Copyright (C) 1998 Free Software Foundation, Inc.
4 :    
5 :     \ This file is part of Gforth.
6 :    
7 :     \ Gforth is free software; you can redistribute it and/or
8 :     \ modify it under the terms of the GNU General Public License
9 :     \ as published by the Free Software Foundation; either version 2
10 :     \ of the License, or (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, write to the Free Software
19 : anton 1.4 \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20 : anton 1.3
21 : pazsan 1.1 [IFUNDEF] assembler Vocabulary assembler [THEN]
22 : pazsan 1.2 require ./target.fs
23 : pazsan 1.1 [IFUNDEF] chained require chains.fs [THEN]
24 :    
25 :     \ ---------- Basic Definitions
26 :    
27 :     \ (code) and (end-code) are used from interpreter or cross-compiler
28 :     \ Between (code) and (end-code) must be finished cpu-instructions
29 :     \ asm[ ... ]asm should or can be used to interrupt assembling
30 :     \ mode while assembling, the words should switch off and on
31 :     \ the assembler vocabulary or a special pasring mode
32 :     \ When using ]asm asm[ a cpu instruction has not to be finished
33 :    
34 :     defer ]asm \ turns on assembler mode
35 :     defer asm[ \ turns off assebmler mode
36 :    
37 :     defer (code) \ starts up a assembler passage
38 :     defer (end-code) \ ends an assembler passage
39 :    
40 :     \ Chains
41 :    
42 :     \ Numref registers in propper8 (to reset some flags) and in
43 :     \ end-code8 (for resolving)
44 :     \ propper should be executed before at assembling start
45 :     \ and when an intstruction is finished.
46 :    
47 :     Variable code8 \ starts assembling
48 :     0 code8 !
49 :    
50 :     Variable end-code8 \ ends assembling
51 :     0 end-code8 !
52 :    
53 :     Variable propper8 \ clean up flags for new cpu instructions
54 :     0 propper8 !
55 :    
56 :     : propper propper8 chainperform ;
57 :    
58 :     : ]asm-1
59 :     also assembler
60 :     get-order >r = ABORT" Assembler is activated!"
61 :     r> 2 - 0 ?DO drop LOOP
62 :     ; ' ]asm-1 IS ]asm
63 :    
64 :     : asm[-1
65 :     also assembler
66 :     get-order >r <> ABORT" Assembler isn't activated!"
67 :     r> 2 - 0 ?DO drop LOOP
68 :     previous previous ; ' asm[-1 IS asm[
69 :    
70 :     : (code)-1
71 :     \ the next input is assebler code witch is stored at dp
72 :     ]asm
73 :     propper
74 :     code8 chainperform
75 :     ; ' (code)-1 IS (code)
76 :    
77 :     : (end-code)-1
78 :     \ the next code are normal forth definitions
79 :     end-code8 chainperform
80 :     asm[ ; ' (end-code)-1 IS (end-code)
81 :    
82 :     \ for test purposes
83 :    
84 :     [IFUNDEF] there
85 :     : code create (code) ;
86 :     : end-code (end-code) ;
87 :     [THEN]
88 :    
89 :     also assembler also definitions forth
90 :    
91 :     variable asm-current
92 :    
93 :     : end-label (end-code) asm-current @ set-current ;
94 :     : end-macros previous previous asm-current @ set-current ;
95 :    
96 :     \ Macros
97 :    
98 :     : : : ;
99 :     : ; postpone ; ; immediate
100 :    
101 :     : label there constant ;
102 :     : equ constant ;
103 :    
104 :     forth definitions
105 :    
106 :     : start-macros get-current asm-current ! also forth also assembler definitions ;
107 :     : label (code) label ;
108 :    
109 :     previous previous

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help