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

Subversion Repositories 1664

[/] [1664/] [trunk/] [c/] [cpu_1664/] [documentos/] [1664.tex] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mrdmkg
\documentclass[a4paper,11pt]{article}
2
 
3
\begin{document}
4
\title{1664}
5
\author{public domain}
6
\date{\today}
7
\maketitle
8
\tableofcontents
9
\pagebreak
10
 
11
\part{Architecture}
12
This document briefly outlines the working of the '1664' processor, the assembler and the simulator/debugger.
13
 
14
\section{Instruction set}
15
 
16
\subsection{Opcode encoding}
17
All instructions are conditional with the exception of \bf ajusta \rm.\\
18
All instructions are encoded with 16 bits. With the exception of \bf ajusta \rm the least significant 8 bits determine the operation and the condition. The most significant 8 bits, the parameter(s). \\
19
 
20
[0..4] opcode bits \\
21
 
22
[5..7] condition bits \\
23
 
24
[8..15] parameter bits (the specific decoding depends on the instruction). \\
25
 
26
(*) \bf ajusta \rm opcode: \\
27
 
28
[0..4] opcode bits. \\
29
 
30
[5..8] destination opcode (+ 0x10).\\
31
 
32
[9..15] opcode to be mapped from complete instruction set. \\
33
 
34
\subsection{Condition bits}
35
There are 8 condition bits, 'condition 7' is always read as 1, the others are modifiable using the condition manipulation instructions: ldb, stb, cmp, dep. \\
36
The \bf rev opera\_rev\_depende\_influe \rm instruction allows other instructions to affect the condition bits. In this mode, the first four bits have a determined meaning. \\
37
Condition 0 indicates a zero result. \\
38
Condition 1 is the inverse of bit condition 0. \\
39
Condition 2 indicates a carry. \\
40
Condition 3 indicates an underflow. \\
41
 
42
\subsection{Fixed instructions}
43
 
44
\subsubsection{ajusta : configure opcode}
45
 Parameter range : $<$0x10..0x1f$>$ $<$0x00..0x7f$>$
46
 
47
 After execution of \bf ajusta \rm the opcode specified by the second parameter is mapped to the opcode specified by the first parameter. \\
48
 The 16 configurable opcodes allow access to all 128 instructions.\\
49
 The first 16 non-configurable instructions can be duplicated in the 16 configurable slots providing a means of code obfuscation on a system where the translation table is not visible.\\
50
 The ajusta instruction is optionally a protected instruction. Protect via \bf rev \rm instruction.\\
51
 See assembler directives \sl .opera \rm and \sl .ajusta \rm
52
 
53
\begin{verbatim}
54
ajusta 0x10 and ; opcode '0x10' interpreted
55
                ; as 'and' instruction
56
 
57
;equivalent of '7 and 1 3'
58
.d1 {0x10 7 5 <<} {1 3 2 <<}
59
 
60
;fictional instruction 'new <0..3> <0..63>'
61
.opera new 2r6r  ; declare instruction name and parameter interpretation as '2r6r'
62
ajusta 0x11 new  ; opcode '0x11' interpreted as 'new' instruction
63
.ajusta 0x11 new ; inform assembler of change to opcode value.
64
 
65
\end{verbatim}
66
 
67
\subsubsection{ldi : load 8b constant}
68
 Parameter format: $<$0..255$>$
69
 Least significant 8 bits of register 0 is replaced with parameter. Remaining bits are unaffected.
70
 
71
\begin{verbatim}
72
eor 0 0   ; 0 == '0x0000'
73
ldi 0x12  ; 0 == '0x0012'
74
ldi 0x34  ; 0 == '0x0034'
75
\end{verbatim}
76
 
77
\subsubsection{ldis : load 8b constant with post 8b shift}
78
 Parameter format : $<$0..255$>$\\
79
 Least significant 8 bits of register 0 is replaced with parameter and register is shifted left 8 bits.\\
80
 Together with \bf ldi \rm instruction, a 64 bit value can be loaded using 128 bits of code.\\
81
 See memory load instruction \bf ldm \rm for an alternative to loading register 0 with a constant.\\
82
 
83
\begin{verbatim}
84
eor 0 0   ; 0 == '0x0000'
85
ldis 0x12 ; 0 == '0x1200'
86
ldi 0x34  ; 0 == '0x1234'
87
\end{verbatim}
88
 
89
\subsubsection{ldm : memory load}
90
 Parameter format : $<$[(+-)0..7(+-)]$>$ ($<$size$>$)\\
91
 $<$size$>$ 1, 2 or an even multiple of 2 to size of register. (optional) Defaults to size of register.\\
92
 + increment (optional)\\
93
 - decrement (optional)\\
94
 (+-) before the register modifies the register by $<$size$>$ before.\\
95
 (+-) after the register modifies the register by $<$size$>$ after.\\
96
 
97
 Register 0 is loaded register with $<$size$>$ element from memory pointed to by A.\\
98
 
99
 If the specified register is 7 (\sl sIP\rm) then the offset is calculated adding (unsigned) register 0.\\
100
 
101
\begin{verbatim}
102
ldm [sIP+] 4
103
.d4 0x12345678
104
;execution continues here. 0 == '0x12345678'
105
 
106
ldm [6+] ;register 0 is loaded from stack.
107
         ;The size of the element loaded is
108
         ;the size of the register
109
         ;(the default when the <size> is omitted).
110
\end{verbatim}
111
 
112
\subsubsection{stm : memory store}
113
 store complement to \bf ldm \rm instruction.
114
 
115
\begin{verbatim}
116
ldi 0x12
117
stm [-6] 1 ;stack register is pre decremented by '1'
118
           ;and 0x12 is stored to
119
           ;location pointed by register 6.
120
\end{verbatim}
121
 
122
\subsubsection{ldr : register load}
123
 Parameter format: $<$A0..3$>$ $<$B0..63$>$\\
124
 Load register A with B
125
 
126
\subsubsection{str : register store}
127
 Parameter format: $<$A0..3$>$ $<$B0..63$>$\\
128
 Store register A to B
129
 
130
\subsubsection{cam : register swap}
131
 Parameter format: $<$A0..3$>$ $<$B0..63$>$\\
132
 Swap registers A, B
133
 
134
\subsubsection{yli : relative branch by signed 8b constant}
135
 Parameter format: $<$-127..128$>$\\
136
 return register (\sl sREVENI \rm) is loaded with address after \bf yli\rm\\
137
 branch instruction pointer + 8b constant shifted left by 1.\\
138
 Assembler parameter format: $<$label$>$\\
139
 The assembler will calculate the relative offset from the instruction, which must be a multiple of 2.\\
140
 
141
\subsubsection{ylr : absolute branch via register or relative via sIP}
142
 Return register (\sl sREVENI \rm) is loaded with address after \bf ylr\rm
143
 A any register\\
144
 
145
 Parameter format: $<$[A0..63]$>$\\
146
  Branch to address pointed to by address in register A\\
147
 
148
 Parameter format: $<$[+A0..63]$>$\\
149
  Branch to (address pointed to by address in register A) relative to \sl sIP \rm\\
150
 
151
 Parameter format: $<$A0..63$>$\\
152
  Branch to address in register A\\
153
 
154
 Parameter format: $<$+A0..63$>$\\
155
  Branch to (address in register A) relative to \sl sIP \rm\\
156
 
157
 
158
\subsubsection{ldb : bit load}
159
 Parameter format: $<$A0..3$>$ $<$B0..63$>$\\
160
 Copy bit B of register A to z (condition bit 0)
161
 
162
\subsubsection{stb : bit store}
163
 Parameter format: $<$A0..3$>$ $<$B0..63$>$\\
164
 Copy bit z (condition bit 0) to bit B of register A
165
 
166
\subsubsection{cmp : register compare}
167
 Parameter format: $<$A0..3$>$ $<$B0..63$>$ ; set condition bits\\
168
 condition bit 0 (alias z) = $A==B$\\
169
 condition bit 1 (alias n) = $A\neg B$
170
 condition bit 2 (alias c) = $A>B$
171
 condition bit 3 (alias o) = $A<B$
172
 
173
\subsubsection{dep : condition bit logic}
174
 Parameter format: $<$A0..7$>$ $<$B0..7$>$ $<$C0..3$>$\\
175
 
176
 The function performed on condition bits A, B are determined by the value of C:\\
177
 0: $A = A \oplus B$\\
178
 1: $A = A \wedge B$\\
179
 2: $A = A \vee B$\\
180
 3: A swapped with B\\
181
 
182
Macro alias: \sl dep\_eor,dep\_and,dep\_or,dep\_cam \rm\\
183
 clear bit : beor c c\\
184
 set bit : bor c 7
185
 
186
\subsubsection{bit : register bit statistics}
187
 Parameter format: $<$A0..63$>$ $<$CODE0..3$>$\\
188
 Result is stored in register 0.\\
189
 CODE 0: count of clear bits in register A before first set bit counting from most significant bit\\
190
      1: count of clear bits in register A before first set bit counting from least significant bit\\
191
      2: count of set bits in register A\\
192
      3: count of clear bits in register A\\
193
 
194
 Macro aliases: \sl msb, lsb, ones, zeros \rm\\
195
 
196
\subsubsection{rev : multiple functions specified by 8b constant}
197
 Parameter format: $<$0..255$>$\\
198
 The function performed by rev is determined by the parameter.
199
 
200
\paragraph{opera\_rev\_reveni}
201
  \sl sIP=sREVENI \rm
202
 
203
\paragraph{opera\_rev\_eseta}
204
  If executed while in protected mode, execution returns to user mode and the user instruction pointer is loaded from \sl sREVENI\_ESETA\rm.\\
205
  From user mode, protected \sl sREVENI\_ESETA \rm is loaded with user instruction pointer and a user exception is executed. Register 0 contains the exception offset. See example source code.
206
 
207
\paragraph{opera\_rev\_ajusta\_reinisia}
208
  Operation translations set by \bf ajusta \rm are set to defaults: 16,17,..,31\\
209
 
210
\paragraph{opera\_rev\_ajusta\_protejeda}
211
  Protected mode instruction. Prevents user code from configuring opcodes.
212
 
213
\paragraph{opera\_rev\_ajusta\_permete}
214
  Protected mode instruction. Allows user code to configure opcodes.
215
 
216
\paragraph{opera\_rev\_depende\_influe}
217
  Allows instructions to influence condition bits.
218
 
219
\paragraph{opera\_rev\_depende\_inoria}
220
  Prevents instructions (apart from bit instruction) from changing condition bits
221
 
222
\paragraph{opera\_rev\_sicle\_intercambia}
223
  Protected mode instruction. Register 0 and CPU cycle counter are swapped
224
 
225
\paragraph{opera\_rev\_sicle\_usor\_limite\_intercambia}
226
  Protected mode instruction. Register 0 and user cycle limit are swapped\\
227
  The user cycle limit, limits user code cycle usage before an exception returns control to protected mode code.
228
 
229
\paragraph{opera\_rev\_sicle\_usor\_intercambia}
230
  From protected mode, register 0 and user cycle counter are swapped.\\
231
  From user code, register 0 is loaded with user cycle counter.
232
 
233
\paragraph{opera\_rev\_state\_reteni\_usor}
234
  Protected mode instruction. Save user state to memory pointed by register 0.\\
235
  64 registers; 128 opcode translation (presently, stored as 8 bit per opcode), 4 byte CPU flags and conditions, a register size for user cycle counter and cycle limit, each.
236
 
237
\paragraph{opera\_rev\_state\_restora\_usor}
238
  Protected mode instruction. Load user state to memory pointed by register 0.
239
 
240
\paragraph{opera\_rev\_bp}
241
  Break point exception. Protected and user mode are distinguished
242
 
243
\paragraph{opera\_rev\_entra}
244
  Save \sl RETENI \rm (\sl sR0..31 \rm) registers to (decrease before write) stack
245
 
246
\paragraph{opera\_rev\_departi}
247
  Load \sl RETENI \rm (\sl sR0..31 \rm) registers from (increase after read) stack
248
 
249
\subsection{Configurable instructions}
250
Logic and arithmetic functions that operate on registers only.
251
 
252
\subsubsection{and : register logical and}
253
 Parameter format : $<$A0..3$>$ $<$B0..63$>$\\
254
 condition bits : z,n
255
\subsubsection{or : register logical or}
256
 Parameter format : $<$A0..3$>$ $<$B0..63$>$\\
257
 condition bits: z,n
258
\subsubsection{eor : register logical exclusive or}
259
 Parameter format : $<$A0..3$>$ $<$B0..63$>$\\
260
 condition bits : z,n
261
\subsubsection{shl : register logical shift left}
262
 Parameter format : $<$A0..3$>$ $<$B0..63$>$\\
263
 condition bits : z,n, c=last bit shifted
264
\subsubsection{shr : register logical shift right}
265
 Parameter format : $<$A0..3$>$ $<$B0..63$>$\\
266
 condition bits : z,n, c=last bit shifted
267
\subsubsection{sar : register arithmetic shift right}
268
 Parameter format : $<$A0..3$>$ $<$B0..63$>$\\
269
 condition bits : z,n, c=last bit shifted
270
 
271
\subsubsection{plu : register addition}
272
 Parameter format : $<$A0..3$>$ $<$B0..63$>$\\
273
 $A = A + B$
274
 
275
\subsubsection{sut : register subtraction}
276
 Parameter format : $<$A0..3$>$ $<$B0..63$>$ \\
277
 $A = A - B$
278
 
279
\subsubsection{sutr : register reverse subtraction}
280
 Parameter format : $<$A0..3$>$ $<$B0..63$>$ \\
281
 $A = B - A$
282
 
283
\subsubsection{mul : register multiply (integer/floating point)}
284
 Parameter format: $<$A0..3$>$ $<$B0..63$>$\\
285
 Register 0 contains the most significant bits of product with adjustment. \\
286
  Adjusted so the most significant bit of product (\sl sMASIMA \rm) occupies the most significant bit of register 0.\\
287
  Least significant bits shift from \sl sMINIMA \rm.\\
288
 \sl sDESLOCA \rm contains the number of bits register 0 need to be shifted to produce correct result\\
289
  if value is unsigned, ($A*B$) = (register\_0)$<<$\sl sDESLOCA \rm\\
290
  if value is signed (two's complement), ($A*B$) = (register\_0)$>>$\sl sDESLOCA \rm\\
291
 \sl sMASIMA \rm contains most significant bits of product\\
292
 \sl sMINIMA \rm contains least significant bits of product\\
293
 
294
 \bf mul \rm and \bf div \rm operations are cumulative on \sl sDESLOCA \rm. See software FPU implementation (f2) for an example.
295
 
296
\subsubsection{div : register divide (integer/floating point)}
297
 Parameter format: $<$A0..3$>$ $<$B0..63$>$\\
298
 Register 0 contains the most significant bits of division with adjustment.\\
299
  Adjusted so the most significant bit of product (\sl sMASIMA \rm) occupies the most significant bit of register 0.\\
300
 \sl sDESLOCA \rm contains the number of bits register 0 need to be shifted to produce correct result\\
301
  if value is unsigned, ($A*B$) = (register\_0)$<<$\sl sDESLOCA \rm\\
302
  if value is signed (two's complement), ($A*B$) = (register\_0)$>>$\sl sDESLOCA \rm\\
303
 \sl sMINIMA \rm = $A/B$\\
304
 
305
 \bf mul \rm and \bf div \rm operations are cumulative on \sl sDESLOCA\rm. See software FPU implementation (f2) for an example.\\
306
 
307
\subsection{Registers}
308
The processor may be configured with up to 64 registers.
309
 
310
\subsubsection{6 stack pointer}
311
Register 6 \sl sPILA \rm is used as the the stack pointer by the example code.
312
 
313
\subsubsection{7 instruction pointer}
314
Register 7 \sl sIP \rm the instruction pointer. When read it points to the instruction's address+2.
315
 
316
\subsubsection{59 }
317
Register 59 \sl sDESLOCA \rm See arithmetic instructions \bf mul\rm, \bf div\rm.
318
 
319
\subsubsection{60}
320
Register 60 \sl sMINIMA \rm See arithmetic instructions \bf mul\rm, \bf div\rm.
321
 
322
\subsubsection{61}
323
Register 61 \sl sMASIMA \rm See arithmetic instructions \bf mul\rm, \bf div\rm.
324
 
325
\subsubsection{62 exception return pointer}
326
Register 62 \sl sREVENI\_ESETA \rm contains the address, following the instruction, that caused and exception.\\
327
It is used as the return address for the instruction \bf rev opera\_rev\_eseta \rm when executed as a 'privileged' instruction. See instruction \bf rev\rm.
328
 
329
\subsubsection{63 branch return pointer}
330
Register 63 \sl sREVENI \rm contains the link address. See branch instructions \bf yli, ylr\rm. \\
331
The instruction \bf rev opera\_rev\_reveni \rm assigns the value of \sl sREVENI \rm to the instruction pointer.
332
 
333
\pagebreak
334
\section{Memory mapped peripherals (simulator)}
335
Peripheral configuration registers are mapped to a reserved memory block that are accessible from system code or user code provided the register address are mapped to the user code memory space. See memory management unit.
336
 
337
\subsection{Memory management unit}
338
A simple MMU is included in the simulator that provides configurable access rights per mapped area of memory. The MMU translates the requested address via a translation table with the following format (1664 assembler syntax):\\
339
 
340
\begin{verbatim}
341
.ds {SIZE PERMISSION |} ;least significant bits determine access.
342
.ds VIRTUAL_OFFSET
343
.ds REAL_OFFSET
344
 
345
;... further entries
346
 
347
.ds 0 ;end
348
\end{verbatim}
349
 
350
Permission bits are as follows:\\
351
 
352
1 : write operation allowed when set to 1\\
353
2 : execute operation allowed when set to 1\\
354
 
355
The first word contains the size of the mapped area (most significant bits) and 3 access permission bits (least significant bits). As a consequence \sl SIZE \rm is 8 bytes aligned.\\
356
 
357
\pagebreak
358
\part{Assembler}
359
The assembler requires, at the minimum, a file with an instruction declaration. (See directive \sl .opera \rm). \\
360
 
361
\section{Syntax}
362
 
363
\subsection{Instructions}
364
(condition) instruction\_name (parameter\_1) (parameter\_2) (..)
365
The condition does not need to be specified as it is assumed to be 7 (always true) if left out.\\
366
All instructions are conditional, with the exception of the instruction \bf ajusta\rm.
367
Example of using conditional instructions:\\
368
\begin{verbatim}
369
eor 1 1
370
eor 0 0
371
ldi 1 ;register 0 == 1
372
cmp 0 1
373
z ldi 2 ;register 0 == 1
374
n ldi 3 ;register 0 == 3
375
c ldi 4 ;register 0 == 4
376
o ldi 5 ;register 0 == 4
377
\end{verbatim}
378
 
379
\subsection{Labels}
380
Labels are declared simply by placing the name on a new line.\\
381
To create a local label, the label declaration must begin with a \sl : \rm. The local label is then preceded with an \sl @ \rm. And is referenced by the name of the \sl :\rm label concatinated with the local label.\\
382
Example of a loop and local label:\\
383
\begin{verbatim}
384
rev 5 ;instructions afect condition bits.
385
label0
386
eor 0 0
387
ldi 2
388
eor 1 1
389
ldi 1
390
:label1
391
label2
392
@local
393
sut 0 1
394
n yli label1@local
395
yli label2
396
\end{verbatim}
397
 
398
\pagebreak
399
\section{Directives}
400
 
401
\subsection{.inclui $<$file name$>$}
402
 Include \sl filename\rm and assemble immediately.
403
 
404
\subsection{.opera $<$instruction name$>$ $<$parameter function name$>$}
405
 Before an instruction can be identified and assembled the name must be declared and the parameter format specified from hard-coded functions. The opcode is inferred from the order which the instructions are declared.\\
406
 See \sl base.opera.1664 \rm.
407
 
408
\begin{verbatim}
409
.opera instruction_name parameter_function
410
;instruction_name is given opcode 0x01 (ajusta is always 0x00)
411
;subsequent .opera .. are given + 1 from the previous
412
\end{verbatim}
413
 
414
\subsection{.ajusta $<$instruction opcode 0x10..0x1f$>$ $<$instruction name$>$}
415
 Interpret \bf instruction name \rm as having the specified opcode.\\
416
 Used to inform assembler that the \bf ajusta \rm instruction has changed the decoding.\\
417
 See the instruction \bf ajusta \rm.
418
 
419
\subsection{.defina $<$tag$>$ $<$value$>$}
420
 Assign a value to a tag. Undefined tags evaluate as 0.
421
 
422
\subsection{.nodefina $<$tag$>$}
423
 Undefine a tag. Undefined tags evaluate as 0.
424
 
425
\subsection{.d1 $<$value0$>$ ($<$value1$>$) (...)}
426
 Interpret values as 8 bit and output directly to image.
427
 
428
\subsection{.d2 $<$value0$>$ ($<$value1$>$) (...)}
429
Interpret values as 16 bit and output directly to image.\\
430
 \sl .do, .d2 \rm are equivalent in current implementation
431
 
432
\subsection{.do $<$value0$>$ ($<$value1$>$) (...)}
433
Interpret values as instruction word (16 bit) values\\
434
 \sl .do, .d2 \rm are equivalent in current implementation.
435
 
436
\subsection{.d4 $<$value0$>$ ($<$value1$>$) (...)}
437
Interpret values as 32 bit and output directly to image\\
438
 (\sl .ds, .d4 \rm are equivalent when the CPU is configured with 32 bit registers)
439
 
440
\subsection{.ds $<$value0$>$ ($<$value1$>$) (...)}
441
Interpret values as register (up to 64bit) size and output directly to image.
442
 
443
\pagebreak
444
\section{Arithmetic}
445
Equations (including directives) are evaluated using reverse polish notation (RPN) method enclosed between \{\}.Nested \{\}\ evaluated.\\
446
Values are treated as 64 bit unsigned integer. Each value is added to a 'last in first out' stack.
447
 
448
example
449
\begin{verbatim}
450
.defina a {100 1 +} ;tag 'a' defined as 101
451
.defina b {a 2 -} ;tag 'b' defined as 99.
452
\end{verbatim}
453
 
454
\subsection{RPN Directives}
455
 
456
\subsubsection{.x}
457
 Exchange last two values on stack
458
 
459
\subsubsection{.d}
460
 Duplicate value on RPN stack indexed by last value (not included in count)
461
 
462
\subsubsection{.$<$}
463
 Drop n values from stack, n is determined by last value and is dropped additionally.
464
 
465
\subsubsection{.-}
466
 Unary function: twos compliment
467
 
468
\subsubsection{.+}
469
 Unary function: absolute value
470
 
471
\subsubsection{./}
472
 Unary function: $1/x$\\
473
 Arithmetic performed as 64 bit integers.\\
474
 
475
\subsection{RPN functions}
476
$-$ ;subtract\\
477
$+$ ;add\\
478
$*$ ;multiply\\
479
$/$ ;divide\\
480
$>>$ ;shift right second last value by last value\\
481
$<<$ ;shift left second last value by last value\\
482
\& ;logic: and\\
483
$|$ ;logic: or\\
484
\^  ;logic: exclusive or\\
485
 
486
Boolean functions evaluate 1 if true otherwise 0. Last two values are replaced with result.\\
487
$>$ ;boolean: compare last two values: greater than\\
488
$<$ ;boolean: compare last two values: less than\\
489
$>=$ ;boolean: compare last two values: greater than or equal\\
490
$<=$ ;boolean: compare last two values: less than or equal\\
491
$=$ ;boolean: compare last two values: equal\\
492
!= ;boolean: compare last two values: not equal\\
493
$||$ ;boolean: (or) values and compare with 0\\
494
\&\& ;boolean: (and) values and compare with 0\\
495
^^ ;boolean: (exclusive or) values and compare with 0\\
496
 
497
\pagebreak
498
\section{Examples}
499
 
500
\subsection{Loading constants}
501
 
502
\begin{verbatim}
503
;24bits 0xaabbcc to register sT0
504
 
505
;using ldis and ldi 8 bytes
506
eor 0 0 ;0x0000000000000000
507
ldis 0xaa ;0x000000000000aa00
508
ldis 0xbb ;0x0000000000aabb00
509
ldi 0xcc  ;0x0000000000aabbcc
510
 
511
;using ldm 6 bytes
512
ldm [sIP+] 4
513
.d4 0x00aabbcc
514
;execution continues
515
\end{verbatim}
516
 
517
\subsection{Configuring instruction}
518
 
519
\begin{verbatim}
520
ajusta 0x1f and ;configure 'and' in to last slot
521
.ajusta 0x1f and ;inform assembler to interpret 'and' as 0x1f
522
 
523
rev opera\_rev\_ajusta\_reinisia ;return to default configuration
524
.implicada ;inform assembler operations has default encoding
525
 
526
\end{verbatim}
527
 
528
\pagebreak
529
\section{Macros}
530
 
531
\subsection{Macro definition}
532
.model $<$tag$>$ \{\} parameter0 parameter1 ... ;Named macro. Output when invoked by name.\\
533
\{\} ;Single line macros are evaluated in place.
534
 
535
\subsection{Macro functions}
536
Use within a macro definition \{\}.
537
 
538
\subsubsection{\%0..9}
539
 Substituted with corresponding macro parameter.
540
 
541
\subsubsection{\%\{\}}
542
 Substituted with corresponding macro parameter indexed as evaluated between \{\}.
543
 
544
\subsubsection{\%I"$<$text$>$"}
545
 Macro information $<$text$>$ printed to console.
546
 
547
\subsubsection{\%!\{\}"$<$text$>$"}
548
 Assembler error flagged and $<$text$>$ printed to console if \{\} evaluates !=0.
549
 
550
\subsubsection{\%.\{\}}
551
 Macro expansion will stop at this evaluation if \{\} evaluates !=0.
552
 
553
\subsubsection{\%+\{\} $<$line$>$}
554
 Include $<$line$>$ (the remaining text) if \{\} evaluates !=0
555
 
556
\subsubsection{\%-\{\} $<$line$>$}
557
 Remove $<$line$>$ (the remaining text) line if \{\} evaluates !=0
558
 
559
\subsubsection{\%$>$\{\} $<$c$>$}
560
 Skip character $<$c$>$ (advance one character) if \{\} evaluates !=0
561
 
562
\subsubsection{\%@}
563
 Replace with current instruction pointer
564
 
565
\subsubsection{\%c}
566
 Replace with parameter count
567
 
568
\subsection{Macro examples}
569
\begin{verbatim}
570
;Single line macro. Output 0
571
;(size of register) if instruction pointer
572
; evaluates greater or equal to 1001
573
{%+{%@ %0 >=}.ds 0} 1001
574
\end{verbatim}
575
 
576
\subsubsection{Named macro}
577
\begin{verbatim}
578
.model named {
579
%+{%@ %0 >=}.ds 0
580
}
581
;code
582
named 1001 ;Output 0 (size of register) if instruction pointer
583
           ;evaluates greater or equal to 1001
584
\end{verbatim}
585
 
586
\subsubsection{Recursive macro}
587
'something' repeated \%0 (10) times.\\
588
 Each evaluation the parameter is decreased by 1 and passed to the named macro \sl reveni \rm after executing 'something'.\\
589
 After 10 passes \%+ evaluates false and the next iteration is skipped.\\
590
 
591
\begin{verbatim}
592
.model revinente {
593
.defina contador {%0 1 -}
594
something
595
%+{contador 0 !=} revinente contador
596
}
597
;code
598
reveni 10
599
 
600
\end{verbatim}
601
 
602
\pagebreak
603
\part{Simulator}
604
Parameters intended for the simulated 1664 (See the instruction \bf imita\rm) are distinguished by starting with a \bf + \rm character (convention).\\
605
 
606
\section{Command line}
607
\subsection{-v : verbose}
608
\subsection{-d : start in debugger (execute)}
609
\subsection{-e : execute after assemble}
610
\subsection{-f : assemble file}
611
\subsection{-I : search path}
612
\subsection{-m : memory allocate in MB to CPU}
613
\subsection{-b : write binary image}
614
\subsection{-B : read binary image}
615
 
616
\pagebreak
617
\section{Debugger}
618
Fo the debugger to display the correct instruction names and decode the parameters correctly, the instruction delcarations that where used to assemble the file need to be supplied. (See assembler directive \sl .opera\rm).\\
619
\subsection{Key commands}
620
\subsubsection{c : run}
621
\subsubsection{n : step in}
622
\subsubsection{N : step over}
623
\subsubsection{m : break after}
624
 
625
\pagebreak
626
\section{Additional instruction}
627
To provide a way for the simulator to be used as an interpreter for 1664 code/binaries an additional instruction is included that provides an interface with some system calls (presently limited to GNU/Linux).\\
628
The example code uses \bf imita \rm at the 'operating system' level. The user code invokes the function by using the native user exception mechanism \bf rev opera\_rev\_eseta \rm.\\
629
 
630
\subsection{imita : simulate operating system call}
631
 Parameter format: $<$0..255$>$\\
632
 See \sl imita.inclui.1664 \rm for specific definition\\
633
 See \sl imita.0.1664 \rm for code example.\\
634
\end{document}

powered by: WebSVN 2.1.0

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