OpenCores
URL https://opencores.org/ocsvn/vtach/vtach/trunk

Subversion Repositories vtach

[/] [vtach/] [trunk/] [asm/] [soloasm.inc] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wd5gnr
/**********************************************************************
2
axasm Copyright 2006, 2007, 2008, 2009
3
by Al Williams (alw@al-williams.com).
4
 
5
 
6
This file is part of axasm.
7
 
8
axasm is free software: you can redistribute it and/or modify it
9
under the terms of the GNU General Public Licenses as published
10
by the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12
 
13
axasm is distributed in the hope that it will be useful, but
14
WITHOUT ANY WARRANTY: without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with axasm (see LICENSE.TXT).
20
If not, see http://www.gnu.org/licenses/.
21
 
22
If a non-GPL license is desired, contact the author.
23
 
24
This is the One-Der definition file
25
 
26
***********************************************************************/
27
#ifndef __SOLO_ASM_INC
28
#define __SOLO_ASM_INC
29
#include   // needed for XSYM
30
#include 
31
#include 
32
 
33
/* Define _SOLO_XSYM to get symbol xref dumped to stderr */
34
 
35
// Define this to override to a different memory size (in words, not bytes!)
36
#ifndef MAXMEM
37
#define MAXMEM 0xFFFF
38
#endif
39
 
40
static void __setary(unsigned int a, unsigned int v)
41
  {
42
  if (a>=MAXMEM)
43
     {
44
     fprintf(stderr,"Memory overflow, program too large.\n");
45
     _solo_info.err=1;
46
     }
47
  else _solo_info.ary[a]=v;
48
  }
49
 
50
 
51
// note ORG is only for first address, use REORG to start over
52
#define ORG(n) unsigned int genasm(int _solo_pass) { \
53
   unsigned _solo_add=n;\
54
   _solo_info.psize=32; \
55
   _solo_info.begin=n; \
56
   _solo_info.end=n; \
57
   _solo_info.memsize=MAXMEM; \
58
   _solo_info.ary=malloc(_solo_info.memsize); \
59
   _solo_info.err=(_solo_info.ary==NULL)
60
 
61
#define REORG(n) _solo_info.end=((_solo_add)-1)>_solo_info.end?((_solo_add)-1):_solo_info.end; _solo_add=n; _solo_info.begin=(n)<_solo_info.begin?(n):_solo_info.begin
62
// Assume end is at the highest address
63
#define END _solo_info.end=_solo_info.end<_solo_add-1?_solo_add-1:_solo_info.end; return _solo_info.end; }
64
// Note this requires a compiler like gcc that supports var
65
// declarations inthe middle of a block
66
#define DEFLABEL(l) static unsigned l
67
#ifdef _SOLO_XSYM
68
#define LABEL(l) l=_solo_add; if (_solo_pass==2) fprintf(stderr,"%-32s:\t%08X\n",#l,_solo_add)
69
#else
70
#define LABEL(l) l=_solo_add
71
#endif
72
 
73
 
74
// Note: This looks wrong but solo asm adjusts the top bit
75
#define R(n) ((n)+0x1000)
76
#define F(unit,sub) ((sub)<<8|(unit))
77
 
78
 
79
///////////////////////////// Old style definitions
80
//// Note these are no longer maintained
81
#ifdef OLDSTYLE
82
#include "soloasm-old.inc"
83
 
84
/////////////////////// New style definitions (preferred)
85
#else
86
 
87
#define FPC 1
88
#define FPC_VALUE F(FPC,0)
89
// RW
90
#define FPC_PLUS1 F(FPC,1)
91
#define FPC_PLUS2 F(FPC,2)
92
#define FPC_PGMRDADD F(FPC,4)
93
#define FPC_INTVECTOR F(FPC,7)
94
#define FPC_RETINT F(FPC,0xB)
95
#define FPC_RETINTX F(FPC,0xC)
96
#define FPC_WADD F(FPC,9)
97
#define FPC_WDATA F(FPC,10)
98
#define FPC_WRITE F(FPC,13)
99
#define FPC_IMMVAL F(FPC,14)
100
// Writes
101
#define FPC_ADD F(FPC,1)
102
#define FPC_SKIP2 F(FPC,3)
103
#define FPC_PGMRD F(FPC,5)
104
#define FPC_CLEAR F(FPC,6)
105
#define FPC_IMM F(FPC,15)
106
#define FPC_CALL F(FPC,8)
107
// Reads
108
#define FPC_PLUS1 F(FPC,1)
109
// aliases
110
#define FIMMV 0xE01
111
#define FIMM 0xF01
112
#define INTENABLE MOV(FPC_RETINT,FZERO)
113
#define INTDISABLE MOV(FPC_RETINTX,FZERO)
114
#define RETI MOV(FPC_RETINT,FPC)
115
#define RETIX MOV(FPC_RETINTX,FPC)
116
 
117
 
118
#define MOVI(n) MOV(FZERO,FIMM); DATA(n)
119
#define LDI(n) MOVI(n)
120
#define LDIQ(d) __setary(_solo_add++,0x10000000|(d&0xFFFFFFF))
121
#define MOVIQ LDIQ
122
#define LDRIQ(d,dest) LDIQ((d)); MOV(FIMMV,(dest))
123
#define LDRI(d,dest) MOVI(d); MOV(FIMMV,(dest))
124
 
125
#define JMP(n) MOVI(n); MOV(FIMMV,FPC)
126
#define JMPQ(n) LDIQ(n); MOV(FIMMV,FPC)
127
#define CALL(n) MOVI(n); MOV(FIMMV,FPC_CALL)
128
#define CALLR(n) MOV(R(n),FPC_CALL)
129
#define JMPR(n) MOV(R(n),FPC)
130
#define CALLQ(n) LDIQ(n); MOV(FIMMV,FPC_CALL)
131
 
132
#define FCON 0
133
#define FCON_0 F(FCON,0)
134
#define FCON_1 F(FCON,1)
135
#define FCON_2 F(FCON,2)
136
#define FCON_80000000 F(FCON,3)
137
#define FCON_4 F(FCON,4)
138
#define FCON_ff F(FCON,5)
139
#define FCON_ff00 F(FCON,6)
140
#define FCON_ff0000 F(FCON,7)
141
#define FCON_ff000000 F(FCON,8)
142
#define FCON_10 F(FCON,9)
143
#define FCON_a F(FCON,10)
144
#define FCON_f F(FCON,11)
145
#define FCON_f0 F(FCON,12)
146
#define FCON_80 F(FCON,13)
147
#define FCON_aaaaaaaa F(FCON,14)
148
#define FCON_ffffffff F(FCON,15)
149
#define FCON_neg1 F(FCON,15)
150
// aliases
151
#define FZERO 0x000
152
#define FONE 0x100
153
#define ZERO(r) MOV(FZERO,r)
154
 
155
#define FACC 2
156
#define FACC_VALUE F(FACC,0)
157
#define FACC_ADD F(FACC,1)
158
#define FACC_SUB F(FACC,2)
159
#define FACC_SHL F(FACC,3)
160
#define FACC_SHR F(FACC,4)
161
#define FACC_RAL F(FACC,5)
162
#define FACC_RAR F(FACC,6)
163
#define FACC_OR F(FACC,7)
164
#define FACC_AND F(FACC,8)
165
#define FACC_XOR F(FACC,9)
166
#define FACC_ADC F(FACC,10)
167
#define FACC_FLAGS F(FACC,15)  // Read only
168
 
169
 
170
#define FMEM 3
171
#define FMEM_MP0 F(FMEM,0)
172
#define FMEM_SIZE0 F(FMEM,1)
173
#define FMEM_VALUE0 F(FMEM,2)
174
#define FMEM_VALUE0POST F(FMEM,3)
175
#define FMEM_VALUE0PRE F(FMEM,4)
176
#define FMEM_OFFSET0 F(FMEM,5)
177
#define FMEM_VALUE0OFFSET F(FMEM,6)
178
#define FMEM_MP0ADD F(FMEM,7)
179
#define FMEM_MP1 F(FMEM,8)
180
#define FMEM_SIZE1 F(FMEM,9)
181
#define FMEM_VALUE1 F(FMEM,10)
182
#define FMEM_VALUE1POST F(FMEM,11)
183
#define FMEM_VALUE1PRE F(FMEM,12)
184
#define FMEM_OFFSET1 F(FMEM,13)
185
#define FMEM_VALUE1OFFSET F(FMEM,14)
186
#define FMEM_MP1ADD F(FMEM,15)
187
 
188
 
189
#define FSTK 4
190
#define FSTK_PUSH F(FSTK,3)
191
#define FSTK_POP F(FSTK,4)
192
#define FSTK_SP F(FSTK,0)
193
#define FSTK_TOS F(FSTK,2)
194
#define FSTK_OFFSET F(FSTK,5)
195
#define FSTK_ATOFFSET F(FSTK,6)
196
#define FSTK_SPADD F(FSTK,7)
197
#define FSTK_LOCAL1 F(FSTK,9)
198
#define FSTK_LOCAL2 F(FSTK,10)
199
#define FSTK_LOCAL3 F(FSTK,11)
200
#define FSTK_LOCAL4 F(FSTK,12)
201
#define FSTK_LOCAL5 F(FSTK,13)
202
#define FSTK_LOCAL6 F(FSTK,14)
203
#define FSTK_LOCAL7 F(FSTK,15)
204
#define FSTK_LOCAL(n) F(FSTK,(8+(n))&0xF)
205
 
206
#define PUSH(r) MOV(r,FSTK_PUSH)
207
#define POP(r) MOV(FSTK_POP,r)
208
 
209
#define FCMP 5
210
#define FCMP_X F(FCMP,0)
211
#define FCMP_TARGET F(FCMP,4)
212
#define FCMP_EQ F(FCMP,1)
213
#define FCMP_EQ2 F(FCMP,5)
214
#define FCMP_NE F(FCMP,9)
215
#define FCMP_NE2 F(FCMP,0xD)
216
#define FCMP_LT F(FCMP,2)
217
#define FCMP_LT2 F(FCMP,6)
218
#define FCMP_GT F(FCMP,3)
219
#define FCMP_GT2 F(FCMP,7)
220
#define FCMP_LE F(FCMP,11)
221
#define FCMP_LE2 F(FCMP,15)
222
#define FCMP_GE F(FCMP,10)
223
#define FCMP_GE2 F(FCMP,14)
224
 
225
#define FBYTE 6
226
#define FBYTE_0 F(FBYTE,0)
227
#define FBYTE_1 F(FBYTE,1)
228
#define FBYTE_2 F(FBYTE,2)
229
#define FBYTE_3 F(FBYTE,3)
230
#define FBYTE_W0 F(FBYTE,4)
231
#define FBYTE_W1 F(FBYTE,5)
232
#define FBYTE_SWAP16 F(FBYTE,6)
233
#define FBYTE_BLEFT F(FBYTE,7)
234
#define FBYTE_BRIGHT F(FBYTE,8)
235
 
236
#define FLOOP 7
237
#define FLOOP_I F(FLOOP,0)     // loop variable (set to init)
238
#define FLOOP_IINC F(FLOOP,1)  // loop increment (can be negative)
239
#define FLOOP_IEND F(FLOOP,2)  // loop end
240
#define FLOOP_IADD F(FLOOP,3)  // address to send if loop not ended or pc+1
241
#define FLOOP_J F(FLOOP,4)     // loop variable (set to init)
242
#define FLOOP_JINC F(FLOOP,5)  // loop increment (can be negative)
243
#define FLOOP_JEND F(FLOOP,6)  // loop end
244
#define FLOOP_JADD F(FLOOP,7)  // address to send if loop not ended or pc+1
245
#define FLOOP_IADDR F(FLOOP,8) // relative address (returns 0 if loop ends)
246
#define FLOOP_JADDR F(FLOOP,9) // relative address (returns 0 if loop ends)
247
#define I FLOOP_I
248
#define J FLOOP_J
249
 
250
#define FACC2 8
251
#define FACC2_VALUE F(FACC2,0)
252
#define FACC2_ADD F(FACC2,1)
253
#define FACC2_SUB F(FACC2,2)
254
#define FACC2_SHL F(FACC2,3)
255
#define FACC2_SHR F(FACC2,4)
256
#define FACC2_RAL F(FACC2,5)
257
#define FACC2_RAR F(FACC2,6)
258
#define FACC2_OR F(FACC2,7)
259
#define FACC2_AND F(FACC2,8)
260
#define FACC2_XOR F(FACC2,9)
261
#define FACC2_ADC F(FACC2,10)
262
#define FACC2_FLAGS F(FACC2,15)  // Read only
263
// note flags don't work in FACC2
264
 
265
#define FDSTK 9
266
#define FDSTK_PUSH F(FDSTK,3)
267
#define FDSTK_POP F(FDSTK,4)
268
#define FDSTK_SP F(FDSTK,0)
269
#define FDSTK_TOS F(FDSTK,2)
270
#define FDSTK_OFFSET F(FDSTK,5)
271
#define FDSTK_ATOFFSET F(FDSTK,6)
272
#define FDSTK_SPADD F(FDSTK,7)
273
#define FDSTK_LOCAL1 F(FDSTK,9)
274
#define FDSTK_LOCAL2 F(FDSTK,10)
275
#define FDSTK_LOCAL3 F(FDSTK,11)
276
#define FDSTK_LOCAL4 F(FDSTK,12)
277
#define FDSTK_LOCAL5 F(FDSTK,13)
278
#define FDSTK_LOCAL6 F(FDSTK,14)
279
#define FDSTK_LOCAL7 F(FDSTK,15)
280
#define FDSTK_LOCAL(n) F(FDSTK,(8+(n))&0xF)
281
 
282
#define PUSHD(r) MOV(r,FDSTK_PUSH)
283
#define POPD(r) MOV(FDSTK_POP,r)
284
 
285
 
286
 
287
#define FDEBUG 0xFD
288
#define FDEBUG_SOURCE F(FDEBUG,0)
289
#define FDEBUG_MASK F(FDEBUG,1)
290
#define FDEBUG_PC F(FDEBUG 2)
291
#define FDEBUG_SRC F(FDEBUG,3)
292
#define FDEBUG_DST F(FDEBUG,4)
293
 
294
#define FDEBUG_PCINT 0
295
#define FDEBUG_SRCINT 1
296
#define FDEBUG_SRCDST 2
297
#define FDEBUG_STEP 8
298
 
299
 
300
 
301
#define FIO  0xFE
302
#define FIO_LED F(FIO,0)
303
#define FIO_SW F(FIO,0)
304
#define FIO_DISP F(FIO,1)
305
#define FIO_DPS F(FIO,2)
306
#define FIO_UART F(FIO,3)
307
#define FIO_UART_DR F(FIO,4)
308
#define FIO_UART_TBE F(FIO,5)
309
#define FIO_UART_TSE F(FIO,6)
310
#define FIO_INP F(FIO,7)
311
#define FIO_OUT F(FIO,8)
312
#define FIO_INTFLAG F(FIO,9)
313
#define FIO_INTMASK F(FIO,10)
314
#define FIO_TIMER F(FIO,11)
315
#define FIO_SWI F(FIO,0xE)
316
#define FIO_DELAY F(FIO,0xF)
317
 
318
#define FIO_INTSWI 0
319
#define FIO_INTTIMER 1
320
#define FIO_INTPB 2
321
#define FIO_INTUARTRX 4
322
#define FIO_INTUARTTX 8
323
#define FIO_INTUARTERR 16
324
#define FIO_INTB0RISE 32
325
#define FIO_DEBUG 63
326
 
327
 
328
 
329
#define RET MOV(FSTK_POP,FPC)
330
#define RETURN RET
331
 
332
#endif
333
 
334
 
335
 
336
#define DATA(d) __setary(_solo_add++,(d))
337
// DATA4 is requird for STRINGPACK
338
#define DATA4(a,b,c,d) DATA(((a)<<24)|((b)<<16)|((c)<<8)|(d))
339
// 28-bit sign extended immediate load
340
 
341
#define soloASM(mask,cond,src,dst) __setary(_solo_add++,((mask)<<29)|((cond)<<26)|((src)&0x1000)<<13|((dst)&0x1000)<<12 | ((src) & 0xFFF)<<12 | ((dst & 0xFFF)))
342
 
343
// note: these look "wrong" but soloasm does the right shifts
344
#define Z 4
345
#define C 2
346
#define S 1
347
 
348
 
349
#define MOV(src,dst) soloASM(0,0,src,dst)
350
#define MOVIF(mask,cond,src,dst) soloASM(mask,cond,src,dst)
351
#define MOVZ(src,dst) soloASM(Z,Z,src,dst)
352
#define MOVNZ(src,dst) soloASM(Z,0,src,dst)
353
#define MOVC(src,dst) soloASM(C,C,src,dst)
354
#define MOVNC(src,dst) soloASM(C,0,src,dst)
355
#define MOVP(src,dst) soloASM(S,0,src,dst)
356
#define MOVN(src,dst) soloASM(S,S,src,dst)
357
 
358
// could define combos (16 total) but MOVIF takes care of it
359
 
360
 
361
// Other condtional things
362
#define RETZ MOVZ(FSTK_POP,FPC)
363
#define RETNZ MOVNZ(FSTK_POP,FPC)
364
#define RETC MOVC(FSTK_POP,FPC)
365
#define RETNC MOVNC(FSTK_POP,FPC)
366
#define RETP MOVP(FSTK_POP,FPC)
367
#define RETN MOVN(FSTK_POP,FPC)
368
 
369
#define JMPZ(lbl) MOVI(lbl); MOVZ(FIMMV,FPC)
370
#define JMPZQ(lbl) MOVIQ(lbl); MOVZ(FIMMV,FPC)
371
#define JMPNZ(lbl) MOVI(lbl); MOVNZ(FIMMV,FPC)
372
#define JMPNZQ(lbl) MOVIQ(lbl); MOVNZ(FIMMV,FPC)
373
#define JMPC(lbl) MOVI(lbl); MOVC(FIMMV,FPC)
374
#define JMPCQ(lbl) MOVIQ(lbl); MOVC(FIMMV,FPC)
375
#define JMPNC(lbl) MOVI(lbl); MOVNC(FIMMV,FPC)
376
#define JMPNCQ(lbl) MOVIQ(lbl); MOVNC(FIMMV,FPC)
377
#define JMPP(lbl) MOVI(lbl); MOVP(FIMMV,FPC)
378
#define JMPPQ(lbl) MOVIQ(lbl); MOVP(FIMMV,FPC)
379
#define JMPN(lbl) MOVI(lbl); MOVN(FIMMV,FPC)
380
#define JMPNQ(lbl) MOVIQ(lbl); MOVN(FIMMV,FPC)
381
 
382
#define HALT MOV(FCON_0,FPC_ADD)
383
#define NOP MOV(FZERO,FZERO)
384
 
385
#define SWI MOV(FZERO,FIO_SWI)
386
#define SWIN(n) LDRIQ(n,FIO_SWI)
387
 
388
#define INC MOV(FONE,FACC_ADD)
389
#define INC2 MOV(FONE,FACC2_ADD)
390
 
391
 
392
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.