OpenCores
URL https://opencores.org/ocsvn/forth-cpu/forth-cpu/trunk

Subversion Repositories forth-cpu

[/] [forth-cpu/] [trunk/] [nvram.txt] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 howe.r.j.8
\ ==== Boot Block ==============================================
2
-1 loaded !
3
 
4
 
5
 
6
 
7
 
8
 
9
 
10
 
11
 
12
 
13
 
14
 
15
 
16
 
17
; ==== Short Help ==============================================
18
This is a subroutine threaded Forth, based on eForth. The
19
starting base in in hexadecimal. A tutorial, word glossary and
20
extra code is stored in block storage. A short list of commands
21
follows ('#' are numbers):
22
 
23
  words       list all Forth words
24
  see         decompile the next word in the input stream
25
  # #2 index  get descriptive titles for blocks from '#' to '#2'
26
  # list      list block number '#'
27
  # load      execute code in block '#'
28
  # #2 thru   execute code in blocks '#' to '#2'
29
 
30
 
31
 
32
 
33
; ==== Forth Error Messages: 1/4 ===============================
34
  -1 ABORT
35
  -2 ABORT"
36
  -3 stack overflow
37
  -4 stack underflow
38
  -5 return stack overflow
39
  -6 return stack underflow
40
  -7 do-loops nested too deeply during execution
41
  -8 dictionary overflow
42
  -9 invalid memory address
43
 -10 division by zero
44
 -11 result out of range
45
 -12 argument type mismatch
46
 -13 undefined word
47
 -14 interpreting a compile-only word
48
 -15 invalid FORGET
49
; ==== Forth Error Messages: 2/4 ===============================
50
 -16 attempt to use zero-length string as a name
51
 -17 pictured numeric output string overflow
52
 -18 parsed string overflow
53
 -19 definition name too long
54
 -20 write to a read-only location
55
 -21 unsupported operation
56
 -22 control structure mismatch
57
 -23 address alignment exception
58
 -24 invalid numeric argument
59
 -25 return stack imbalance
60
 -26 loop parameters unavailable
61
 -27 invalid recursion
62
 -28 user interrupt
63
 -29 compiler nesting
64
 -30 obsolescent feature
65
; ==== Forth Error Messages: 3/4 ===============================
66
 -31 >BODY used on non-CREATEd definition
67
 -32 invalid name argument (e.g., TO xxx)
68
 -33 block read exception
69
 -34 block write exception
70
 -35 invalid block number
71
 -36 invalid file position
72
 -37 file I/O exception
73
 -38 non-existent file
74
 -39 unexpected end of file
75
 -40 invalid BASE for floating point conversion
76
 -41 loss of precision
77
 -42 floating-point divide by zero
78
 -43 floating-point result out of range
79
 -44 floating-point stack overflow
80
 -45 floating-point stack underflow
81
; ==== Forth Error Messages: 4/4 ===============================
82
 -46 floating-point invalid argument
83
 -47 compilation word list deleted
84
 -48 invalid POSTPONE
85
 -49 search-order overflow
86
 -50 search-order underflow
87
 -51 compilation word list changed
88
 -52 control-flow stack overflow
89
 -53 exception stack overflow
90
 -54 floating-point underflow
91
 -55 floating-point unidentified fault
92
 -56 QUIT
93
 -57 exception in sending or receiving a character
94
 -58 [IF], [ELSE], or [THEN] exception
95
 
96
 
97
; ==== Description of this file ================================
98
The next screens contain extra code that can be loaded into the
99
interpreter if needed. Some of the standard Forth words are
100
placed here instead of in the image to save on space.
101
 
102
The blocks should be loaded in order unless otherwise stated.
103
 
104
This file is first converted by a utility into a fixed width
105
format, which can then be loaded onto the target board with
106
the same utility used to uploaded the bitfile to the FPGA.
107
 
108
Line lengths are limited to 64 characters wide, each block
109
contains 16 lines. The first line should contain a
110
description of the block so that when it is displayed with
111
'index' a glossary can be viewed, allowing quick navigation.
112
 
113
; ==== Scratch Block ===========================================
114
 
115
 
116
 
117
 
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
 
129
\ ==== Block Editor 1/2 ========================================
130
( Block Editor: There is a help section later on )
131
variable editor-voc 0 editor-voc ! forth
132
: editor decimal editor-voc 1 set-order ;
133
get-order editor-voc swap 1+ set-order
134
$40 constant c/l $10 constant l/b
135
: (block) blk @ block ;
136
: (check) dup b/buf c/l / u>= if -24 throw then ;
137
: (line) (check) c/l * (block) + ;
138
: b block drop ;
139
: l blk @ list ;
140
: n  1 +block b l ;
141
: p -1 +block b l ;
142
: d (line) c/l blank ;
143
: x (block) b/buf blank ;
144
: s update save-buffers ;
145
\ ==== Block Editor 2/2 ========================================
146
: q forth save-buffers ;
147
: e forth blk @ load editor ;
148
: ia c/l * + (block) + source drop >in @ +
149
  swap source nip >in @ - cmove [compile] \ ;
150
: i 0 swap ia ;
151
: u update ;
152
: w words ;
153
: yank pad c/l ;
154
: c (line) yank >r swap r> cmove ;
155
: y (line) yank cmove ;
156
: ct swap y c ;
157
: ea (line) c/l evaluate ;
158
: sw 2dup y (line) swap (line) swap c/l cmove c ;
159
forth
160
 
161
\ ==== Assembler word set ======================================
162
variable assembler-voc
163
bl parse rdrop pad pack$ find drop assembler-voc !
164
: assembler assembler-voc 1 set-order ;
165
: ;code assembler ; immediate
166
: code [compile] : assembler ;
167
get-order assembler-voc swap 1+ set-order
168
: end-code forth [compile] ; ; immediate
169
: words words ;
170
: forth forth ;
171
forth
172
 
173
 
174
 
175
 
176
 
177
\ ==== CORDIC 1/2 ==============================================
178
variable lookup -1 cells allot ( 16 values )
179
$3243 , $1DAC , $0FAD , $07F5 , $03FE , $01FF , $00FF , $007F ,
180
$003F , $001F , $000F , $0007 , $0003 , $0001 , $0000 , $0000 ,
181
 
182
: arshift ( n u -- n : arithmetic right shift )
183
  2dup rshift >r swap $8000 and
184
  if $10 swap - -1 swap lshift else drop 0 then r> or ;
185
 
186
$26DD constant cordic_1K $6487 constant pi/2
187
 
188
variable tx 0 tx ! variable ty 0 ty ! variable tz 0 tz !
189
variable x  0  x ! variable y  0  y ! variable z  0  z !
190
variable d  0  d ! variable k  0  k !
191
 
192
 
193
\ ==== CORDIC 2/2 ==============================================
194
( CORDIC: valid in range -pi/2 to pi/2, arguments are in fixed )
195
( point format with 1 = 16384, angle is given in radians.  )
196
: cordic ( angle -- sine cosine )
197
  z ! cordic_1K x ! 0 y ! 0 k !
198
  $10 begin ?dup while
199
    z @ 0< d !
200
    x @ y @ k @ arshift d @ xor d @ - - tx !
201
    y @ x @ k @ arshift d @ xor d @ - + ty !
202
    z @ k @ cells lookup + @ d @ xor d @ - - tz !
203
    tx @ x ! ty @ y ! tz @ z !
204
    k 1+!
205
    1-
206
  repeat y @ x @ ;
207
: sin cordic drop ;
208
: cos cordic nip ;
209
\ ==== Login Code 1/2 ==========================================
210
\ Login and user management system: @todo clear up with vocabs
211
: generate count dup >r crc r> ccitt ; ( b -- u )
212
: .user     ." user>" space ; ( -- )
213
: .password ." password>" space ; ( -- )
214
variable user0 0 user0 !
215
: mk.user ( --; ,  )
216
  here user0 @ , user0 ! here 0 , bl word count 1+ allot align
217
  drop bl word generate swap ! ;
218
: ls.user ( -- : list all users in user database )
219
  cr user0 @
220
  begin dup while dup 2 cells + space count type cr @ repeat
221
  drop cr ;
222
: find.user ( a -- u | 0 : find user in database, return hash )
223
  >r user0 @ begin dup while dup 2 cells + count r@ count
224
  =string if rdrop exit then @ repeat rdrop drop 0 ;
225
\ ==== Login Code 2/2 ==========================================
226
: (password) ( u --,  )
227
  >r begin .password query bl word cr generate
228
  r@ = until rdrop ;
229
: fake .password query bl word drop cr ;
230
: (user)
231
  begin .user query bl word cr find.user ?dup until ;
232
: retry ( xt -- : retry word until it succeeds )
233
  >r begin r@ catch 0= until rdrop ;
234
: user?     ' (user)     retry ;
235
: password? ' (password) retry ;
236
: hide-all 0 1 set-order ;
237
: login hide-all
238
  cr user? cell+ @ conceal password? interactive forth ;
239
mk.user guest guest     mk.user archer dangerzone
240
mk.user lana  sterling  mk.user cyril  figgis
241
\ ==== Extra Code 1/7 ==========================================
242
: 2+ 2 + ;                       ( n -- n )
243
: 2- 2 - ;                       ( n -- n )
244
: >= < invert ;                  ( n n -- f )
245
: simulation? cpu-id $cafe <> ; ( -- f : are we in the matrix? )
246
: 0<= 0> 0= ;                    ( n n -- f )
247
: 0>= 0< 0= ;                    ( n n -- f )
248
: not -1 xor ;                   ( n -- n )
249
: dabs dup 0< if dnegate then ;  ( d -- d )
250
: d+  >r swap >r um+ r> r> + + ; ( d d -- d )
251
: d=  >r swap r> = >r = r> and ; ( d d -- f )
252
: d<> d= 0= ;                    ( d d -- f )
253
: roll  dup 0> if swap >r 1- recurse r> swap else drop then ;
254
: ?exit if rdrop then ;          ( n --, R: n -- n | )
255
: 2rdrop r> rdrop rdrop >r ;     ( R n n -- )
256
: 2. swap . . ;                  ( n n -- )
257
\ ==== Extra Code 2/7 ==========================================
258
: m* 2dup xor 0< >r abs swap abs um* r> if dnegate then ;
259
: */mod  >r m* r> m/mod ;  ( n n n -- r q )
260
: */  */mod nip ;          ( n n n -- q )
261
: s>d dup 0< ;             ( n -- d : single to double )
262
: holds begin dup while 1- 2dup + c@ hold repeat 2drop ;
263
: binary  2 base ! ;                       ( -- )
264
: octal  8 base ! ;                        ( -- )
265
: .base base @ dup decimal base ! ; ( -- )
266
: only -1 set-order ;
267
: also get-order over swap 1+ set-order ;
268
: previous get-order swap drop 1- set-order ;
269
: buffer block ; ( k -- a )
270
: bye [ 0 , ] ;
271
: enum dup constant 1+ ; ( n --,  )
272
: logical 0= 0= ;     ( n -- f )
273
\ ==== Extra Code 3/7 ==========================================
274
: square dup * ;      ( n -- )
275
: limit rot min max ; ( n lo hi -- n )
276
: odd 1 and logical ; ( n -- )
277
: even odd invert ;   ( n -- )
278
: nor or invert ;     ( u u -- u )
279
: nand and invert ;   ( u u -- u )
280
: bell 7 emit ;       ( -- )
281
: under >r dup r> ;   ( n1 n2 -- n1 n1 n2 )
282
: 2nip >r >r 2drop r> r> ; ( n1 n2 n3 n4 -- n3 n4 )
283
( n1 n2 n3 n4 -- n1 n2 n3 n4 n1 n2 )
284
: 2over >r >r 2dup r> swap >r swap r> r> -rot ;
285
: 2swap >r -rot r> -rot ; ( n1 n2 n3 n4 -- n3 n4 n1 n2 )
286
: 2tuck 2swap 2over ; ( n1 n2 n3 n4 -- n3 n4 n1 n2 n3 n4 )
287
: 4drop 2drop 2drop ; ( n1 n2 n3 n4 -- )
288
: trip dup dup ; ( n -- n n n )
289
\ ==== Extra Code 4/7 ==========================================
290
: log  >r 0 swap ( u base -- u )
291
  begin swap 1+ swap r@ / dup 0= until
292
  drop 1- rdrop ;
293
: log2 0 swap ( u -- u )
294
  begin swap 1+ swap   2/ dup 0= until
295
  drop 1- ;
296
: average um+ 2 um/mod nip ; ( u u -- u )
297
: <=> 2dup > if 2drop -1 exit then < ;
298
: bounds over + swap ;
299
: 2, , , ; ( n n -- )
300
: tab 9 emit ; ( -- )
301
: drup drop dup ; ( n1 n2 -- n1 n1 )
302
: lsb $ff and ; ( u -- u )
303
: --> 1 +block load ;
304
: scr blk ;
305
\ ==== Extra Code 5/7 ==========================================
306
: signum ( n -- -1 | 0 | 1 : Signum function )
307
  dup 0> if drop  1 exit then
308
      0< if      -1 exit then
309
 
310
: >< dup 8 rshift swap 8 lshift or ; ( u -- u : swap bytes )
311
: #digits dup 0= if 1+ exit then base @ log 1+ ;
312
: ** ( n u -- n )
313
  ?dup if
314
    over >r
315
    begin
316
      dup 1 >
317
    while
318
      swap r@ * swap 1-
319
    repeat rdrop drop
320
  else logical 1 and then ;
321
\ ==== Extra Code 6/7 ==========================================
322
: b. base @ swap 2 base ! u. base ! ; ( u -- )
323
: h. base @ swap hex u. base ! ;      ( u -- )
324
: o. base @ swap 8 base ! u. base ! ; ( u -- )
325
: d. base @ swap decimal . base ! ;   ( n -- )
326
: @bits swap @ and ;                  ( a u -- u )
327
: ?\ if [compile] \ then ; immediate
328
: ?( if [compile] ( then ; immediate ( )
329
: defined? ( -- pwd -1 | 0,  : is word defined? )
330
  bl word find if -1 else drop 0 then ;
331
: ?if compile dup [compile] if ; immediate
332
: ?dup-if compile ?dup [compile] if ; immediate
333
: >body ( dup @ $4000 or <> if 31 -throw then ) cell+ ;
334
 
335
 
336
 
337
\ ==== Extra Code 7/7 ==========================================
338
: screens ( k1 k2 -- : list blocks k1 to k2 )
339
  over -
340
  for
341
    dup . dup list 1+ nuf? if rdrop drop exit then
342
  next drop ;
343
 
344
 
345
 
346
 
347
 
348
 
349
 
350
 
351
 
352
 
353
\ ==== Roulette ================================================
354
\ Russian Roulette: It would be interesting to do something
355
\ killed the computer when the player dies
356
 
357
: click ."  *click*" cr ;
358
: bang  ."  BANG!" cr ;
359
: roulette random 6 mod if click else bang then ; ( -- )
360
 
361
 
362
 
363
 
364
 
365
 
366
 
367
 
368
 
369
\ ==== Extended ANSI Escape Codes ==============================
370
 
371
red green        + constant yellow
372
    green blue   + constant cyan
373
red       blue   + constant magenta
374
red green blue + + constant white
375
: background $a + ;
376
: color $1e + sgr ;
377
\ : hide-cursor CSI [char] ? emit $19 10u. [char] l emit ;
378
\ : show-cursor CSI [char] ? emit $19 10u. [char] h emit ;
379
: up    [char] A ansi ; ( n -- )
380
: down  [char] B ansi ; ( n -- )
381
: left  [char] C ansi ; ( n -- )
382
: right [char] D ansi ; ( n -- )
383
 
384
 
385
\ ==== Screen Saver ============================================
386
\ An incredibly simple screen saver using ANSI Escape codes
387
\ for placement and coloring of random characters
388
 
389
: screen-saver ( -- )
390
  page
391
  begin
392
    random 80 mod
393
    random 40 mod at-xy
394
    random >char emit
395
    random 8  mod
396
    ( random 1 and if background then )
397
    color
398
  again ;
399
 
400
 
401
; ==== Game: YOU ARE DEAD (HELP) ===============================
402
This is a clone of the one dimensional rogue like game
403
available at . The
404
object is to get to the other side of the screen.
405
 
406
Keys:
407
w  Turn into '.'
408
a  Turn into '~'
409
s  Turn into '>'
410
d  Move right
411
q  Quit
412
 
413
Block number 7 is used to store the game state.
414
 
415
 
416
 
417
\ ==== Game: YOU ARE DEAD 1/6 ==================================
418
forth variable yad-voc get-order yad-voc swap 1+ set-order
419
$40 constant c/l $10 constant l/b
420
: memory 7 block ;
421
: variables memory c/l + ;
422
: score    variables 0 cells + ;
423
: position variables 1 cells + ;
424
: level    variables 2 cells + ;
425
: form     variables 3 cells + ;
426
: continue variables 4 cells + ;
427
: end c/l 1- ;
428
: player form @ ;
429
: .player position @ 1+ 3 at-xy player emit ;
430
: .goal c/l 3 at-xy [char] # emit ;
431
: .score ." SCORE: " score @ 5 u.r ;
432
: .level ." LEVEL: " level @ 5 u.r ;
433
\ ==== Game: YOU ARE DEAD 2/6 ==================================
434
: show
435
  page cr cr space memory c/l type
436
  .player .goal
437
  cr .score space .level cr ;
438
 
439
: select ( n -- c )
440
  dup 0=  if drop [char] <  exit then
441
  dup 1 = if drop [char] ~  exit then
442
  dup 2 = if drop [char] .  exit then
443
  drop bl ;
444
 
445
: die ." YOU ARE DEAD" cr 0 continue ! -56 throw ;
446
: survived ." YOU SURVIVED" cr .score cr ;
447
: forms form c@ position @ memory + c@ ; ( -- c c )
448
 
449
\ ==== Game: YOU ARE DEAD 3/6 ==================================
450
: generate ( -- generate a level )
451
  c/l 1- for
452
    random 5 mod ( 3 = most difficult )
453
    select memory r@ + c!
454
  next
455
  bl memory c! bl memory end + c! ;
456
: normal [char] x ;
457
: setup ( -- )
458
  -1 continue !
459
  memory b/buf 0 fill
460
  normal form c!
461
  generate ;
462
 
463
: +score random 4 mod 1 min score +! ; ( -- )
464
: ?next <> if die else +score then ; ( c c -- )
465
\ ==== Game: YOU ARE DEAD 4/6 ==================================
466
: +level
467
 
468
  random 23 mod 5 min score +!
469
  generate ;
470
 
471
: monster swap >r forms r> = if ?next else 2drop then ;
472
 
473
: command ( -- f )
474
  dup [char] w = if drop [char] . form c! 0 exit then
475
  dup [char] a = if drop [char] ~ form c! 0 exit then
476
  dup [char] d = if drop -1 exit then
477
  dup [char] s = if drop [char] < form c! 0 exit then
478
  dup [char] q = if drop -56 throw then
479
  drop 0 ;
480
 
481
\ ==== Game: YOU ARE DEAD 5/6 ==================================
482
: rules
483
  position @ end = if +level exit then
484
  forms = if exit then
485
  [char] ~ [char] < monster
486
  [char] . [char] ~ monster
487
  [char] < [char] . monster
488
  normal form c!
489
  bl position @ memory + c!
490
  score 1+!
491
  position 1+! ;
492
 
493
 
494
 
495
 
496
 
497
\ ==== Game: YOU ARE DEAD 6/6 ==================================
498
: game
499
  begin
500
  show
501
  key command if rules then
502
  level @ 9 >
503
  until survived ;
504
 
505
 
506
: play setup ' game catch drop ;
507
get-order -rot swap rot set-order
508
: you-are-dead base @ decimal play base ! ;
509
forth
510
\ : resume memory drop ' game catch drop ;
511
 
512
 
513
; ==== Brain F*ck Compiler Help 1/2 ============================
514
Brainfuck is a simple esoteric language with only 8 commands, it
515
is Turing complete which means it can compute any function which
516
can be computed - although it is very difficult to do so. The
517
commands operate on a block of memory 1024 bytes long. A data
518
pointer indexes into the memory. The commands are:
519
 
520
  >  increment the data pointer
521
  <  decrement the data pointer
522
  +  increment value at data pointer
523
  -  decrement value at data pointer
524
  .  output byte at data pointer
525
  ,  accept one byte and store it at data pointer
526
  [  branch forward to ] if byte at data pointer is zero
527
  ]  branch back    to [ if byte at data pointer is non-zero
528
The compiler discards all other input.
529
; ==== Brain F*ck Compiler Help 2/2 ============================
530
The following blocks implement the compiler, it translates each
531
command in a given string into Forth code, compiling it into a
532
new word definition which can then be executed.
533
 
534
Needless to say, it is not a useful language, but it is fun!
535
Some example programs are given after the compiler block.
536
 
537
This Forth brain fuck compiler was derived from the one
538
available Rosetta Code, and so is licensed under the
539
GNU Free Documentation License [v1.2]. See:
540
541
 
542
And for more information see:
543
 
544
 
545
\ ==== Brain F*ck Compiler 1/2 =================================
546
: left over c!  1- dup c@ ;
547
: right over c! 1+ dup c@ ;
548
: erase 0 fill ;
549
: initialize pad b/buf erase pad 0 ;
550
: bf-compile ( c -- )
551
  >r
552
  r@ [char] [ = if [compile] begin
553
                   compile dup [compile] while then
554
  r@ [char] ] = if [compile] repeat            then
555
  r@ [char] + = if compile 1+                  then
556
  r@ [char] - = if compile 1-                  then
557
  r@ [char] < = if compile left                then
558
  r@ [char] > = if compile right               then
559
  r@ [char] , = if compile drop compile key    then
560
  r@ [char] . = if compile dup  compile emit   then rdrop ;
561
\ ==== Brain F*ck Compiler 2/2 =================================
562
: bf ( b u --, : compile brainfuck program into a word )
563
  >r >r
564
  [compile] :
565
  compile initialize
566
  r> r> for aft
567
    dup 1+ >r c@ bf-compile r>
568
  then next
569
  drop
570
  compile swap
571
  compile c@
572
  compile 2drop
573
  [compile] ; ;
574
 
575
\ Example, making a simple echo like program called 'cat':
576
\ : string $" +[,.]" count ; string bf cat
577
; ==== Brain F*ck Example Programs =============================
578
From: http://www.hevanet.com/cristofd/brainfuck/short.b
579
Hello World: ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]
580
>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
581
Clear Screen: ++++++++++[>++++++++++>+<<-]>[>.<-]
582
Beep: +++++++.
583
Copy Input to Output: ,[.[-],]
584
Reverse Input: >,[>,]<[.<]
585
Translate text to brain fuck that prints said Text:
586
+++++[>+++++++++<-],[[>--.++>+<<-]>+.->[<.>-]<<,]
587
 
588
 
589
 
590
 
591
 
592
 
593
; ==== eForth v6.66: Help and Tutorial =========================
594
 
595
This Forth is modeled after eForth, described in a book by
596
C.H. Ting called "eForth Overview", or "The Zen of eForth". It
597
implements most of the eForth model with some changes expected
598
from a more modern Forth system.
599
 
600
The processor targeted is called the H2, a rewrite of the
601
J1 processor ().
602
It has been extended with a few more instructions and with
603
interrupts. The system resides on an FPGA Nexys 3 board from
604
Digilent, with words and peripherals designed for it.
605
 
606
For more see: 
607
 
608
 
609
; ==== Help: Introduction ======================================
610
 
611
Forth is a simple, imperative, stack based language that mixes
612
elements of a high level language with a low level language. It
613
is possible to fit a small Forth system in a few kilobytes of
614
RAM complete with an interactive read-evaluate-print loop, an
615
editor, an assembler and a disassembler.
616
 
617
It is also a language that has fallen out of favor in recent
618
times (after the micro-computer era) as it is not a very safe
619
language, nor is it one that allows the programmer to easily
620
create reusable and maintainable software components.
621
 
622
However it is still suitable for a number of purposes; for
623
assemblers, to bring up hardware and test it, in memory
624
constrained systems, as a boot loader, and for fun.
625
; ==== Help: Philosophy of Forth ===============================
626
Forth itself has its own philosophy, one in which the programmer
627
should have a complete understanding of the system, from the
628
problem that needs to be solved, the algorithms needed to solve
629
it, the hardware and the software. As the latter two, the
630
hardware and software are usually very simple in Forth systems
631
it is possible to optimize the problem across multiple domains,
632
tailoring each to come up with a solution. Forth eschews
633
complexity, preferring one off, bespoke solutions. Another
634
reason it has not seen widespread use.
635
 
636
Advocates of the language are usually quite passionate about
637
it (as with Lisp, and other niche systems) so it is important
638
to be pragmatic about Forth. Forth is simply a tool and when
639
used correctly can be used productively.
640
 
641
; ==== Help: Basics 1/6 ========================================
642
A Forth system contains an interactive interpreter that parses
643
text and either compiles or executes functions, called 'words'
644
in Forth terminology. The system uses Reverse Polish Notation
645
(RPN) and provides the user with two stacks and a 'dictionary'
646
(a big block of memory containing 'words' and other data).
647
 
648
The interpreter reads from an input device, such as a keyboard
649
or a serial port, and writes output to the screen or back over
650
the serial port. Words and number input are space delimited and
651
are either compiled into the dictionary depending on the
652
interpreter mode and whether the word read in is 'immediate'
653
or not.
654
 
655
This tutorial will describe how to use Forth and how the
656
interpreter works internally.
657
; ==== Help: Basics 2/6 ========================================
658
To start with, simple expressions can be entered and the
659
results displayed. A line is evaluated after the carriage
660
return is entered, code will be indented, this can be typed in.
661
 
662
We will start off with a simple expression, adding two numbers
663
together and displaying the result:
664
 
665
  ( Comments appear within brackets )
666
  2 2 + .
667
 
668
This prints out '4' and 'ok'. 'ok' is printed out after every
669
line has been successfully compiled, unless we are in compile
670
mode. '+' obviously does the addition, and '.' pops a value
671
off the stack an prints it. Entering a number pushes it onto
672
the data stack.
673
; ==== Help: Basics 3/6 ========================================
674
The data, or variable, stack is a general purpose stack that
675
the programmer uses to pass data to functions, and to return
676
data from functions. The stacks are an important concept
677
within Forth and stack management will take up a lot of a Forth
678
programmers time.
679
 
680
Numbers are entered in Reverse Polish Notation, this allows
681
Forth interpreter to immediate process a word or a function as
682
it is encountered instead of building up a parse tree.
683
 
684
When '2' is encountered it is pushed onto the variable stack,
685
when the second '2' is input, it is also pushed onto the stack.
686
The Forth word '+' takes two arguments off the stack, adds them
687
together and pushes the result back onto the stack. The word
688
'.' pops a single number off the stack and prints it.
689
; ==== Help: Basics 4/6 ========================================
690
Manipulating the stack will be difficult at first, but gets
691
easier over time. There are standard words for stack
692
manipulation and a standard methodology for describing
693
stack effects called 'stack comments'.
694
 
695
A stack comment is a short comment describing the stack before
696
and after execution of the word, and the type of the arguments
697
it accepts and returns. For example the stack comment for '+'
698
is:
699
 
700
  + ( n n -- n : add two numbers together )
701
 
702
All text between '(' and the ')' is discarded by the Forth
703
system. This comment describes a word that accepts two
704
signed numbers "n n", and returns a signed number "n".
705
; ==== Help: Basics 5/6 ========================================
706
The "--" divides the comment into what the stack looks like
707
before execution of the word (to the left of "--") and what it
708
looks like after (to the right of "--"). A comment on the
709
behavior of the word comes after the semicolon.
710
 
711
Here is a list of some common Forth words and their stack
712
comments:
713
 
714
  dup  ( n -- n n : duplicate first item on the stack )
715
  swap ( n1 n2 -- n2 n1 : swap first two items on stack )
716
  drop ( n -- : drop a value from the stack )
717
 
718
Stack effects are sometimes numbered, which is used to
719
so the effects on specific arguments can be documented if
720
the order of arguments and return values matter.
721
; ==== Help: Basics 6/6 ========================================
722
Some more words with comments:
723
 
724
  @    ( a -- u : load value from memory address )
725
  !    ( u a -- : store 'u' at memory location 'a' )
726
  <    ( n1 n2 -- f : is n1 greater than n2, signed )
727
  u<   ( u1 u2 -- f : is u1 greater than n2, unsigned )
728
 
729
These words have stack comments, some with numbered arguments,
730
but they use different letters. The different letters are used
731
to describe the type of the arguments that the word accepts.
732
 
733
'@', also known as load, takes an address, and '!', takes
734
an address and a value. "<" takes two signed numbers, "u<"
735
takes two unsigned numbers and produces a flag. Type checking
736
is not performed by Forth and is up to the programmer.
737
; ==== Help: Stack Comments ====================================
738
Here is a list of stack type descriptions and what they mean:
739
| Comment  | Meaning                             |
740
|----------|-------------------------------------|
741
| a        | cell address                        |
742
| n        | signed number                       |
743
| u        | unsigned number                     |
744
| b        | string address                      |
745
| c        | single character                    |
746
| d        | double width number (2 Cells)       |
747
| f        | boolean flag (-1 = true, 0 = false) |
748
| k        | block number                        |
749
| cfa      | code field address of a word        |
750
| nfa      | name field address of a word        |
751
| pwd      | previous word address of a word     |
752
|  | a parsing word                      |
753
; ==== Help: Expressions =======================================
754
Let us continue on with some interactive examples before we
755
start to define new words. Before we saw a trivial example
756
of adding two numbers together, we will go over a few more
757
operators first.
758
 
759
  9 2 + . ( Displays 'B', the default base is hexadecimal )
760
  decimal ( Change the input and output base to decimal )
761
  9 2 + . ( Displays '11' )
762
  3 4 dup * swap dup * + . ( Displays 3^2 + 4^2 or 25 )
763
 
764
Negative numbers can be input by prefixing the number with
765
'-':
766
 
767
  -2 4 * . ( Display -8 )
768
 
769
; ==== Help: Numeric Output 1/2 ================================
770
The word '.' pops a value off the stack before displaying it,
771
if we want to examine the stack without popping the value we
772
can print out the entire contents of the stack with '.s':
773
 
774
  1 2 3 .s ( prints "1 2 3 
775
  .        ( prints "3" )
776
  .s       ( prints "1 2 
777
 
778
"
779
stack. Other useful words for debugging include '?' that
780
prints the contents at a memory address and 'dump', which
781
prints a memory dump of a region of memory.
782
 
783
  dump ( a u -- )
784
  ?    ( a -- )
785
; ==== Help: Numeric Output 2/2 ================================
786
Hexadecimal numbers can be entered if the base input and output
787
base is 16, or by prefixing the number with '$'.
788
 
789
  decimal  $aaa . ( Displays 2730 )
790
          -$aaa . ( Displays -2730 )
791
 
792
eForth starts up in base 16, valid bases range anywhere from
793
2 to 36. The base can be changed by either setting a variable
794
'base' to the desired base, or with the words 'hex' to change
795
the base back into hexadecimal, or 'decimal' to change the base
796
to '10'. Variables in Forth are words that leave an address on
797
the stack when they are called. They can be read or set with
798
'@' and '!'. For example, "$10 base !" and "hex" are
799
equivalent, as are "$a base !" and "decimal".
800
 
801
; ==== Help: Word Definitions 1/2 ==============================
802
For the moment we have not covered how words are defined and
803
is a good time to do so, the word ":" is used to create a new
804
word definition and the word ";" is used to terminate one.
805
Words once defined are added to the 'dictionary', which is
806
consists of a linked list of words, hence the name
807
'dictionary'. We can define new words interactively like we can
808
type expressions in, such as:
809
 
810
  : square dup * ; ( n -- n : square a number )
811
 
812
We can then use square like any other word:
813
 
814
  4 square .  ( prints 16 )
815
  -5 square . ( prints 25 )
816
 
817
; ==== Help: Word Definitions 2/2 ==============================
818
'hex' and 'decimal' are defined as:
819
 
820
  : hex $10 base ! ;
821
  : decimal $a base ! ;
822
 
823
And simple Forth words likewise defined:
824
 
825
  : 2- 2 - ;      ( u -- u : decrement a number by 2 )
826
  : 2+ 2 + ;      ( u -- u : increment a number by 2 )
827
  : 2* 1 lshift ; ( u -- u : multiply a number by 2 )
828
  : 1+ 1 + ;      ( u -- u : increment a number by 1 )
829
  : negate invert 1+ ; ( n -- n : negate, twos compliment )
830
 
831
It is best to keep all Forth words as short as possible and
832
reuse code as much as possible.
833
; ==== Help: Interpreter Loop 1/3 ==============================
834
All functions, control structures, defining words such as ":",
835
and simple functions like "square" or "hex" are simply Forth
836
words, which are either defined in terms of other Forth words
837
or in terms of primitive operations supported by the H2 CPU.
838
 
839
Currently this does not explain how compilation happens. When
840
the word ":" is encountered it does multiple things such as
841
compiling a word header into the dictionary, and it does one
842
more thing - it puts the Forth system into compile mode. The
843
system starts out in command mode, in this mode words are
844
executed, and numbers are pushed onto the stack. In compile
845
mode, a call to the word is compiled (or an assembly
846
instruction is inlined) and numbers of turned into literals
847
that push their value when run.
848
 
849
; ==== Help: Interpreter Loop 2/3 ==============================
850
There is a special class of words called "immediate" words, ";"
851
is an immediate word, when it is encountered instead of being
852
compiled into the dictionary it is executed, it compiles an
853
exit instruction to terminate the word definition and it puts
854
the Forth system back into command mode.
855
 
856
Not only are control structures sets of words, like "if",
857
"else", "then", "begin", "until", but so are words like "("
858
and "\" which are used to process comments. When executed
859
they read from the input stream until the they find a ")" or
860
end of line respectively.
861
 
862
Variables, strings, and defining words (defining words are
863
that create new words) are all simply Forth words that are
864
either compiling or immediate, their is no special syntax.
865
; ==== Help: Interpreter Loop 3/3 ==============================
866
The command loop goes like this:
867
Start) Fetch a space delimited word, find it in the dictionary
868
   Found) Is the system in compile mode?
869
          Yes) Is the word immediate?
870
               Yes) Execute It
871
               No)  Compile a call to it / In-line it
872
          No)  Execute the word
873
   Not Found) Is the word a number?
874
          Yes) Is the system in compile mode?
875
               Yes) Compile the number
876
               No)  Push the number onto the stack
877
          No)  Error!
878
This simple loop is invoked by the work 'quit' which uses
879
'query' to fetch and parse the input and 'interpreter' to
880
perform the state dependent action.
881
; ==== Help: Control Structures 1/10 ===========================
882
This will give you some idea what is going on when control
883
structures are covered in the following blocks. Control
884
structures can only be used within a word definition, that
885
is in compile mode, if used in command mode they simply throw
886
an error.
887
 
888
Some of the control structures available to Forth are:
889
 
890
  if ... then
891
  if ... else ... then
892
  for ... next
893
  for ... aft ... then ... next
894
  begin ... until
895
  begin ... again
896
  begin ... while ... repeat
897
; ==== Help: Control Structures 2/10 ===========================
898
Recursion is also available with the 'recurse' word. There
899
are more advance control flow methods available that will be
900
described later (such as 'catch', 'throw' and manipulating the
901
return stack).
902
 
903
"if...then" will be described first. First a simple example,
904
we will define a word called 'abs' that will return the
905
absolute value of a number, that is negative numbers will be
906
turned into positive numbers and positive numbers will stay
907
the same. This will require the word 'negate' which changes
908
the sign of a number and '0<' which tests if a number is
909
negative, their stack effect comments are:
910
 
911
  0<     ( n -- f )
912
  negate ( n -- n )
913
; ==== Help: Control Structures 3/10 ===========================
914
The word 'abs' is then defined as:
915
 
916
  : abs dup 0< if negate then ;
917
 
918
'if' takes an argument off the stack at run time and jumps to
919
after the 'then' if it is false (zero), if it is true (non-
920
zero) the negate is performed. From now if a word is shown in
921
a definition that has not been previously mentioned please
922
refer to the glossary. We can can use the definition of the
923
word 'abs' as soon as we terminate the definition with ";":
924
 
925
  -9 abs . ( displays 9 )
926
   4 abs . ( displays 4 )
927
 
928
This Forth uses two complements to represent negative numbers.
929
; ==== Help: Control Structures 4/10 ===========================
930
A number can be negated in twos compliment form by performing
931
a bitwise not on the number and adding one to it, this is what
932
the word 'negate' does.
933
 
934
"if...else...then" control structures can be created:
935
 
936
  : min 2dup < if drop else nip then ; ( n n -- n )
937
  : max 2dup > if drop else nip then ; ( n n -- n )
938
 
939
These words get the minimum (min) and the maximum (max) of
940
two numbers.
941
 
942
   4 3 min . ( prints 3 )
943
   4 3 max . ( prints 4 )
944
 
945
; ==== Help: Control Structures 5/10 ===========================
946
Whilst control structures can be nested very deeply it is
947
considered very bad practice to do, instead the definition
948
should be refactored so it consists of short (preferably one
949
line) word definitions.
950
 
951
There are two mains ways of looping, either by recursion or
952
with the several looping mechanisms. One of the simplest is
953
"begin...until". This continues looping until a variable popped
954
off the stack when the "until" word is reach is non-zero. Like
955
the "if" control structure this can only be used within a word
956
definition. An example is the definition of "key", which gets
957
a single character from the input device, it blocks until there
958
is input. It uses a word called "key?" which returns a variable
959
number of items on the stack depending on whether there is
960
new input from the user.
961
; ==== Help: Control Structures 6/10 ===========================
962
The stack comments for "key?" and "key" are:
963
 
964
  key? ( -- c -1 | 0 )
965
  key  ( -- c )
966
 
967
Key returns the new character and "-1" (in Forth -1 is true,
968
and 0 is false), or "0" if there is no new input. The pipe
969
system "|" is used to separate the possible return values in
970
the stack comment. We can use "begin...until" to define "key"
971
in terms of "key?" with:
972
 
973
  : key begin key? until ;
974
 
975
This simply loops until there is a new character of input.
976
 
977
; ==== Help: Control Structures 7/10 ===========================
978
Some contrived examples, using the standard metasyntactic
979
variable name "foo":
980
 
981
  : foo begin 1- dup . cr dup 0= until drop ; ( u -- )
982
 
983
  4 foo ( <-- type this ) 3 ( <-- prints '3' )
984
  2  ( <-- then '2' )
985
  1  ( ... )
986
 
987
  ok ( then ok prompt )
988
 
989
If zero is given this will underflow and wrap around to $FFFF
990
and continue the loop 65536 times which is probably not
991
intended.
992
 
993
; ==== Help: Control Structures 8/10 ===========================
994
Indefinite loops can be made with "begin...again", the
995
following word "bar" simply repeatedly prints out "1":
996
 
997
  : bar begin 1 . cr again ;
998
  bar 1 1 1 1 1 1 ( ... ad infinitum ... )
999
 
1000
A looping mechanism that is easier to use is the
1001
"begin...while...repeat" loop, this continues an operation
1002
until a variable is not true:
1003
 
1004
  : foo begin ?dup while dup . cr 1- repeat ;
1005
  3 foo 3 ( <-- prints 3 )
1006
  2       ( <-- then 2 )
1007
  1       ( <-- then 1 )
1008
 
1009
; ==== Help: Control Structures 9/10 ===========================
1010
eForth provides another control structure, the "for...next" loop
1011
which allows the Forth programmer to create counted loops. The
1012
"for" loop takes a single variable, it stores this variable on
1013
the return stack (which will be covered next) and decrements the
1014
variable, until it is zero, at which point it exits (but still
1015
executes for the final zeroth case). The word 'r@' is used to
1016
push a copy of the top of the return stack, where the for loop
1017
keeps the conditional value.
1018
 
1019
  : foobar for r@ . cr next ;
1020
  3 foobar 3 ( <-- prints 3 )
1021
  2
1022
  1
1023
 
1024
 
1025
; ==== Help: Control Structures 10/10 ==========================
1026
The "for...next" construct can be modified with the "aft" and
1027
"then" construct, which is not executed on the first run of the
1028
loop.
1029
 
1030
  : quux for -9 . aft r@ . then -8 . cr then ;
1031
  decimal 3 quux -9 -8 ( for...aft and then...next is run )
1032
  2 -8 ( aft...then and then...next is run )
1033
  1 -8 ( ... )
1034
 
1035
 
1036
This concludes the control structure section, it should be
1037
noted that the control structures are defined words themselves
1038
again, it is possible to redefine and add your own control
1039
structures. How this is done will be covered later.
1040
 
1041
; ==== Help: Return Stack ======================================
1042
All Forth systems have at least two stacks along with main
1043
memory, they can be implemented in hardware like with this Forth
1044
or in software. One stack is used to pass data to functions and
1045
to return their results, the data or variable stack, which we
1046
have already dealt with. The other stack is used for control
1047
flow and as a place for temporarily storing variables.
1048
 
1049
Data can be moved to and from the return stacks, but this must
1050
be done very carefully and only within word definitions,
1051
leaving values on the stack by accident can cause the
1052
interpreter to crash.
1053
 
1054
Some looping constructs use the return stack as well to store
1055
their loop index, and the 'throw/catch' mechanism manipulates
1056
control flow a lot.
1057
; ==== Help: Return Stack ======================================
1058
Some words for manipulating the return stack are as follows,
1059
notice the stack comments describe both stacks here:
1060
 
1061
  >r    ( u --, R: -- u : move variable to return stack )
1062
  r>    ( -- u, R: u -- : move variable from return stack )
1063
  rdrop ( R: u -- : remove topmost variable from return stack )
1064
  r@    ( -- u, R: u -- u : copy topmost return stack item )
1065
 
1066
 
1067
 
1068
 
1069
 
1070
 
1071
 
1072
 
1073
; ==== Help: Control Structures ================================
1074
 
1075
 
1076
 
1077
 
1078
 
1079
 
1080
 
1081
 
1082
 
1083
 
1084
 
1085
 
1086
 
1087
 
1088
 
1089
; ==== Help: TO DO =============================================
1090
 
1091
* Describe the system internals
1092
* eForth primitives
1093
* Make, Doer, Create, Does>
1094
* Do word glossary, with one block per word
1095
* Vocabularies
1096
* Block Word set
1097
* Peripheral access word set
1098
* Throw/Catch
1099
* How Forth is implemented
1100
* Add appendixes for ASCII character set, ANSI terminal
1101
codes supported, the Nexy3 board, twos compliment format,
1102
list of characters supported, etcetera.
1103
* A short dictionary of English words, or a short
1104
encyclopedia could be made and stored in blocks
1105
; ==== Block Editor Help 1/5 ===================================
1106
 
1107
The traditional way to store Forth source code and data is as
1108
Forth blocks, a block is a contiguous array of 1024 characters,
1109
which can be saved to non-volatile storage with the 'block'
1110
word set. On more modern Forth systems, especially hosted ones,
1111
the file access word set is used instead.
1112
 
1113
A Forth that does not have a file system, such as this one,
1114
usually has a primitive block editor. An editor can be defined
1115
in just a handful of (non-standard) words.
1116
 
1117
By default the editor words are not in the Forth search order,
1118
the words in the editor vocabulary would conflict with Forth
1119
words (and with hexadecimal numbers). To load the block editor
1120
execute the 'editor' Forth word. Load initial block with '0 b'.
1121
; ==== Block Editor Help 2/5 ===================================
1122
The block editor is a prime example of Forth simplicity, it
1123
both simplifies the problem of editing text and reuses the
1124
Forth interpreter to define a new command language. Each command
1125
in the block editor simply a Forth word which takes its
1126
arguments off the stack, and a line is a fixed width 64
1127
character array, a block can contain 16 lines of text. An empty
1128
line consists entirely of spaces, which the interpreter will
1129
ignore if it were to evaluate the block.
1130
 
1131
The 'editor' word replaces the current vocabulary with the
1132
editor vocabulary and switches the number base for input and
1133
output to decimal. The commands are terse words, only one or
1134
two characters in length.
1135
 
1136
 
1137
; ==== Block Editor Help 3/5 ===================================
1138
The third element of the block editor is the elegant, if some-
1139
what limited, block word set. It completely abstracts aways the
1140
task of retrieving data from mass storage and saving modified
1141
data back to it. The mass storage is divided into blocks which
1142
can be loaded by their block number. Block numbers in this
1143
system start at 0 and go to $FFFE, $FFFF is an invalid block
1144
number.
1145
 
1146
The block word set is quite small, and the editor uses the
1147
words; 'block', 'update', 'save-buffers', 'list', 'load',
1148
and '+block'. The variable 'blk', which contains the last
1149
block loaded (and listed) is also used. Most editor commands
1150
are minor modifications on the behavior of these words.
1151
 
1152
 
1153
; ==== Block Editor Help 4/5 ===================================
1154
The workhorse of the word set is 'block', it takes a block
1155
number and if that block number is not currently loaded into a
1156
block buffer (this system only has one block buffer available)
1157
it checks to see if the current block is marked as dirty (with
1158
the 'update' word). If it has been it first flushes the dirty
1159
block to mass storage, then loads the desired block from it. It
1160
then returns a pointer to the beginning of the block buffer. It
1161
also updates the 'blk' variable to contain the block number
1162
just loaded.
1163
 
1164
The 'save-buffers' saves all buffers to disk and deallocates
1165
any blocks (by storing $FFFF in 'blk'). 'list' displays the
1166
contents of a block, 'load' evaluates a block and '+block'
1167
moves to a block relative to the currently loaded one.
1168
 
1169
; ==== Block Editor Help 5/5 ===================================
1170
A quick recap of the block words:
1171
 
1172
block        ( k -- u : load block into buffer )
1173
blk          ( -- a : last loaded block )
1174
+block       ( k -- : load block relative to 'blk' )
1175
save-buffers ( -- : flush block to disk, put -1 in 'blk' )
1176
list         ( k -- : display block )
1177
load         ( k -- : evaluate a block )
1178
 
1179
These can be used to define simple editor commands, such as:
1180
 
1181
  : b block drop ;
1182
  : n 1 +block b ;
1183
  : u update ;
1184
 
1185
; ==== Block Editor Commands 1/2 ===============================
1186
 
1187
'#' indicates a numeric argument the command takes:
1188
      n    move to next block
1189
      p    move to previous block
1190
    # d    delete line in current block
1191
      x    erase current block (overwrite with spaces)
1192
      e    evaluate current block
1193
    # i    insert line
1194
 # #2 ia   insert at line #2 at column #
1195
      q    quit editor loop
1196
    # b    load block number
1197
      s    save block and write it out
1198
      u    update block
1199
      w    list editor commands
1200
      q    back to Forth interpreter
1201
; ==== Block Editor Commands 2/2 ===============================
1202
 
1203
 
1204
      l    re-list current block
1205
    # c    paste copy buffer to line #
1206
    # y    yank line # into copy buffer
1207
 # #2 ct   copy line # to line #2
1208
    # ea   evaluate line #
1209
 # #2 sw   swap lines # and #2
1210
 
1211
The editor is simple to use and understand, but for large
1212
documents and programs can quite difficult to use. This block
1213
editor was derived from the Retro Forth block editor, available
1214
at: 
1215
 
1216
 
1217
; ==== TO DO ===================================================
1218
* The eForth primitives should be described.
1219
* Describe the Nexys 3 system, the system on a chip, etc.
1220
* List the instruction set, registers, words defined, eForth
1221
* Make words for databases using blocks
1222
* Add source code for everything to this block file
1223
* Add a program listing, perhaps in the first block, it could
1224
set variables relating to this document
1225
* If a metacompiler based on the embed project is used, it
1226
might be possible to have a self hosting system by storing the
1227
source code in blocks.
1228
 
1229
 
1230
 
1231
 
1232
 
1233
; ==== Empty Block =============================================
1234
 
1235
 
1236
 
1237
 
1238
 
1239
 
1240
 
1241
 
1242
 
1243
 
1244
 
1245
 
1246
 
1247
 
1248
 
1249
; ==== Glossary ================================================
1250
The next section presents the glossary, which contains one
1251
word per screen with examples. The glossary may not necessarily
1252
reflect the exact contents of the dictionary as words are
1253
removed, added and replaced to save space, but the majority
1254
should be documented here.
1255
 
1256
Hexadecimal and decimal numbers are used, and which base is
1257
in operation should be inferred from context.
1258
 
1259
The glossary shows how blocks can be used as a way to
1260
organize information, a concise description (that if needs
1261
be could span multiple blocks) describes each word. The first
1262
line can be used to create a table of contents with 'index'.
1263
This way of organizing blocks maps well onto dictionaries,
1264
encyclopedias, and all alphabetically organizable information.
1265
; ==== <  ( n1 n2 -- f : signed less than ) ====================
1266
Signed less than.
1267
 
1268
 
1269
 
1270
 
1271
 
1272
 
1273
 
1274
 
1275
 
1276
 
1277
 
1278
 
1279
 
1280
 
1281
; ==== <>  ( u1 u2 -- f : not equal ) ==========================
1282
'<>' takes two values off of the values stack and returns
1283
a boolean which is true (-1) if the two value are not equal
1284
and false (0) if they are.
1285
 
1286
 
1287
 
1288
 
1289
 
1290
 
1291
 
1292
 
1293
 
1294
 
1295
 
1296
 
1297
; ==== <#  ( -- : prepare numeric output ) =====================
1298
This is part of the mechanism for pictured numeric output,
1299
which should be used from within a word definition only.
1300
 
1301
 
1302
 
1303
 
1304
 
1305
 
1306
 
1307
 
1308
 
1309
 
1310
 
1311
 
1312
 
1313
; ==== =  ( u1 u2 -- f : equality of two numbers ) =============
1314
This is an assembly instruction for testing whether two numbers
1315
are equal.
1316
 
1317
 
1318
 
1319
 
1320
 
1321
 
1322
 
1323
 
1324
 
1325
 
1326
 
1327
 
1328
 
1329
; ==== >  ( n1 n2 -- f : signed greater than ) =================
1330
Signed greater than, if 'n1' is greater than 'n2' true (-1) is
1331
returned, else false (0) is returned. This operates on signed
1332
numbers stored in twos compliment format.
1333
 
1334
 
1335
 
1336
 
1337
 
1338
 
1339
 
1340
 
1341
 
1342
 
1343
 
1344
 
1345
; ==== -  ( n1 n2 -- n : subtraction ) =========================
1346
This is word performs subtraction of 'n2' from 'n1'.
1347
 
1348
 
1349
 
1350
 
1351
 
1352
 
1353
 
1354
 
1355
 
1356
 
1357
 
1358
 
1359
 
1360
 
1361
; ==== ,  ( u -- : compile value into dictionary ) =============
1362
The word ',' compiles a value at the next available location
1363
in the dictionary, updating the dictionary pointer by the size
1364
of a cell.
1365
 
1366
 
1367
 
1368
 
1369
 
1370
 
1371
 
1372
 
1373
 
1374
 
1375
 
1376
 
1377
; ==== ;  ( -- : terminate a word definition ) =================
1378
This word terminates a word definition, linking the newly formed
1379
word into the dictionary. It is an immediate word and performs
1380
some basic checking to make sure control structures match up. It
1381
writes an 'exit' into the word and switches the state back into
1382
command mode. It has another minor usage, if called within
1383
command it throws -56, for QUIT. This can be used within a block
1384
to stop execution of it, if 'thru' is used to load block, this
1385
error is ignored.
1386
 
1387
Example:
1388
 
1389
   : 2+ 2 + ;
1390
   : count dup 1+ swap c@ ;
1391
   :noname 9 . ; execute ( <-- prints 9 )
1392
 
1393
; ==== :  ( -- ;  : start a word definition ) ==========
1394
':' is a complex word that does many things. It is not an
1395
immediate word, but it is a parsing word that reads in the
1396
next space delimited word and compiles a word header into the
1397
dictionary. It also switches the interpreter state into compile
1398
mode, until switched back non-immediate words will now be
1399
compiled into this word definition and numbers compiled into
1400
it as literals. ':' is how most new words (or functions) are
1401
defined within Forth. The word ';' should also be consulted.
1402
 
1403
Usage
1404
 
1405
  : example 2 + . cr ; ( <- makes a new word called 'example' )
1406
  2 example            ( <- the new word prints '4' )
1407
 
1408
 
1409
; ==== !  ( u a -- : store 'u' at address 'a' ) ================
1410
Store a value in at an address, this is also used to write to
1411
the memory mapped peripheral registers.
1412
 
1413
 
1414
 
1415
 
1416
 
1417
 
1418
 
1419
 
1420
 
1421
 
1422
 
1423
 
1424
 
1425
; ==== ?  ( a -- : print value at address ) ====================
1426
Print a value out from an address, this is effected by the
1427
output radix stored in 'base'. This word uses the area between
1428
PAD area and the end of the dictionary.
1429
 
1430
 
1431
 
1432
 
1433
 
1434
 
1435
 
1436
 
1437
 
1438
 
1439
 
1440
 
1441
; ==== /  ( n1 n2 -- q: divide n1 by n2 ) ======================
1442
Signed and floored division of the second value on the stack by
1443
the first. This will throw and error if the divisor is zero.
1444
This is a particularly slow operation, as the H2 CPU does not
1445
a built in division operation.
1446
 
1447
 
1448
 
1449
 
1450
 
1451
 
1452
 
1453
 
1454
 
1455
 
1456
 
1457
; ==== .  ( n -- : print number out in current base ) ==========
1458
Print a space, then a signed number (if the output radix is ten
1459
then a '-' is printed before the number if it is less than zero,
1460
if the output radix is not ten, then it is just printed out as
1461
an unsigned number). This word uses the area after the
1462
dictionary and before the start of the pad area, it is not a
1463
reentrant function.
1464
 
1465
 
1466
 
1467
 
1468
 
1469
 
1470
 
1471
 
1472
 
1473
; ==== ."  ( -- ;  : compile string into word ) ========
1474
This word is an immediate word that compiles a string into a
1475
word definition (it should only be used from within a word
1476
definition). When the word is run it will print out the string.
1477
 
1478
The string is terminated by a double quote. A version of this
1479
word which does no printing but instead returns a pointer to
1480
a counted string is available, and it is called '$"'.
1481
 
1482
Usage:
1483
 
1484
  : hello cr ." Hello, World! " cr ;
1485
  hello
1486
  Hello, World! ( <- 'Hello, World!' is printed )
1487
 
1488
 
1489
; ==== .(  ( -- ;  : print out line until ')' ) ========
1490
This word prints out a string until the matching ')' is
1491
encountered. It is not an immediate word. It is a parsing
1492
word.
1493
 
1494
 
1495
 
1496
 
1497
 
1498
 
1499
Usage:
1500
 
1501
  .( Hello, World! ) cr
1502
  Hello, World!  ( <- 'Hello, World!' is printed )
1503
 
1504
 
1505
; ==== '  ( -- xt ;  : return a word execution token ) =
1506
This word parses the next word in the input stream and returns
1507
its execution token if the word is found. It is an immediate
1508
word. If the word is not found it throws an exception.
1509
 
1510
 
1511
 
1512
 
1513
 
1514
 
1515
 
1516
 
1517
 
1518
 
1519
 
1520
 
1521
; ==== (  ( -- ;  : comment until ')' ) ================
1522
This is an immediate word used for comments, it discards all
1523
input until the matching ')' is encountered. It can be used
1524
within blocks. This word should not span multiple lines
1525
however.
1526
 
1527
Usage:
1528
 
1529
  2 2 + ( This is a comment ) . ( <- this '.' prints '4' )
1530
 
1531
 
1532
 
1533
 
1534
 
1535
 
1536
 
1537
; ==== )  ( -- : do nothing ) ==================================
1538
This is a word that does nothing. It is an immediate word. It
1539
has no function.
1540
 
1541
 
1542
 
1543
 
1544
 
1545
 
1546
 
1547
 
1548
 
1549
 
1550
 
1551
 
1552
 
1553
; ==== [  ( -- : change compile state to command mode ) ========
1554
An immediate word for changing the state of the interpreter loop
1555
into the command state. It can be used within a word definition.
1556
 
1557
 
1558
 
1559
 
1560
 
1561
 
1562
 
1563
 
1564
 
1565
 
1566
 
1567
 
1568
 
1569
; ==== ]  ( -- : change compile state to compile mode ) ========
1570
A normal, compiling word, which turns the interpreter state into
1571
compile mode. Words and numbers after (apart from immediate
1572
words) are compiled into the dictionary.
1573
 
1574
 
1575
 
1576
 
1577
 
1578
 
1579
 
1580
 
1581
 
1582
 
1583
 
1584
 
1585
; ==== @  ( a -- u : load value from address ) =================
1586
Retrieve a value from memory location 'a'. It can be used to
1587
read from the memory mapped registers as well.
1588
 
1589
 
1590
 
1591
 
1592
 
1593
 
1594
 
1595
 
1596
 
1597
 
1598
 
1599
 
1600
 
1601
; ==== $"  ( -- ;  : compile string into word ) ========
1602
This is an immediate word that can only be used in a word
1603
definition, it compiles a string into the dictionary, when it
1604
runs it pushes the address of the counted string compiled into
1605
the word.
1606
 
1607
 
1608
 
1609
 
1610
 
1611
 
1612
 
1613
 
1614
 
1615
 
1616
 
1617
; ==== *  ( u1 u2 -- u3 : multiple two numbers ) ===============
1618
Multiply two numbers and push the result onto the stack. This is
1619
a slow operation, as there is not a built in multiply operation.
1620
 
1621
 
1622
 
1623
 
1624
 
1625
 
1626
 
1627
 
1628
 
1629
 
1630
 
1631
 
1632
 
1633
; ==== \  ( -- ;  : comment until end of line ) ========
1634
Comment until end of input line, this word works within blocks
1635
as well, where it is a comment until the end of the block line.
1636
It is an immediate word.
1637
 
1638
 
1639
 
1640
 
1641
 
1642
 
1643
 
1644
 
1645
 
1646
 
1647
 
1648
 
1649
; ==== #  ( u -- u : extract numeric character from u ) ========
1650
 
1651
 
1652
 
1653
 
1654
 
1655
 
1656
 
1657
 
1658
 
1659
 
1660
 
1661
 
1662
 
1663
 
1664
 
1665
; ==== #>  ( u -- b u : return converted number string ) =======
1666
 
1667
 
1668
 
1669
 
1670
 
1671
 
1672
 
1673
 
1674
 
1675
 
1676
 
1677
 
1678
 
1679
 
1680
 
1681
; ==== +  ( u1 u2 -- u3 : add two numbers together ) ===========
1682
 
1683
 
1684
 
1685
 
1686
 
1687
 
1688
 
1689
 
1690
 
1691
 
1692
 
1693
 
1694
 
1695
 
1696
 
1697
; ==== +!  ( u a -- : add 'u' to value 'a' ) ===================
1698
 
1699
 
1700
 
1701
 
1702
 
1703
 
1704
 
1705
 
1706
 
1707
 
1708
 
1709
 
1710
 
1711
 
1712
 
1713
; ==== 0<  ( n -- f : 'n' less than zero? ) ====================
1714
'0<' is a test word that operates on a signed value and returns
1715
a boolean value, it returns -1 for true if 'n' is less than
1716
zero and 0 for false if 'n' is greater than zero.
1717
 
1718
 
1719
 
1720
 
1721
 
1722
Usage:
1723
 
1724
 
1725
     9 0< . ( prints '0' )
1726
    -4 0< . ( prints '-1' or 'FFFF' )
1727
  FFFE 0< . ( prints '-1' or 'FFFF', 'FFFE' = -2 )
1728
 
1729
; ==== 0<>  ( n -- f : 'n' not equal to zero? ) ================
1730
This word tests if 'n' is not zero, returning true (-1) if it
1731
is not zero, and false if it is (0).
1732
 
1733
Usage:
1734
 
1735
 
1736
  -7 0<> . ( prints '-1' or 'FFFF' )
1737
   5 0<> . ( prints '-1' or 'FFFF' )
1738
 
1739
 
1740
 
1741
 
1742
 
1743
 
1744
 
1745
; ==== 0=  ( n -- f : 'n' equal to zero? ) =====================
1746
This word tests if 'n' is zero, returning true (-1) if it is,
1747
and false if it is not (0).
1748
 
1749
 
1750
Usage:
1751
 
1752
  : 0<> 0= 0= ;
1753
 
1754
   4 0= .        ( prints '0' )
1755
  -5 0= .        ( also prints '0' )
1756
 
1757
 
1758
 
1759
 
1760
 
1761
; ==== 0>  ( n -- f : 'n' greater than zero? ) =================
1762
 
1763
 
1764
 
1765
 
1766
 
1767
 
1768
 
1769
 
1770
 
1771
 
1772
 
1773
 
1774
 
1775
 
1776
 
1777
; ==== 1-  ( u -- u : decrement u ) ============================
1778
'1-' decrements the top most stack item.
1779
 
1780
 
1781
 
1782
 
1783
 
1784
 
1785
 
1786
 
1787
 
1788
 
1789
 
1790
 
1791
 
1792
 
1793
; ==== 1+  ( u -- u : increment u ) ============================
1794
This is a regular function that increments a value by one.
1795
 
1796
 
1797
 
1798
 
1799
 
1800
 
1801
 
1802
 
1803
 
1804
 
1805
 
1806
 
1807
 
1808
 
1809
; ==== 1+!  ( a -- : increment value at 'a' by one ) ===========
1810
'1+!' increments the value at an address, 'a', by one.
1811
 
1812
 
1813
 
1814
 
1815
 
1816
 
1817
 
1818
 
1819
 
1820
 
1821
 
1822
 
1823
 
1824
 
1825
; ==== 2!  ( u1 u2 a -- : store u1 and u2 at two cells ) =======
1826
 
1827
 
1828
 
1829
 
1830
 
1831
 
1832
 
1833
 
1834
 
1835
 
1836
 
1837
 
1838
 
1839
 
1840
 
1841
; ==== 2/  ( u -- u : divide 'u' by two ) ======================
1842
 
1843
 
1844
 
1845
 
1846
 
1847
 
1848
 
1849
 
1850
 
1851
 
1852
 
1853
 
1854
 
1855
 
1856
 
1857
; ==== 2@  ( a -- u1 u2 : retrieve two cells ) =================
1858
 
1859
 
1860
 
1861
 
1862
 
1863
 
1864
 
1865
 
1866
 
1867
 
1868
 
1869
 
1870
 
1871
 
1872
 
1873
; ==== 2*  ( u -- u : multiply 'u' by two ) ====================
1874
 
1875
 
1876
 
1877
 
1878
 
1879
 
1880
 
1881
 
1882
 
1883
 
1884
 
1885
 
1886
 
1887
 
1888
 
1889
; ==== 2drop  ( u u -- : drop two values from the stack ) ======
1890
A simple word, '2drop' behaves as its stack comment suggests,
1891
it removes the top most two items from the variable stack.
1892
 
1893
Usage:
1894
 
1895
  1 2 3 drop . 1 ( '1' is printed )
1896
 
1897
 
1898
 
1899
 
1900
 
1901
 
1902
 
1903
 
1904
 
1905
; ==== 2dup  ( u1 u2 -- u1 u2 u1 u2 : duplicate two values ) ===
1906
This manipulates two items on the stack, like most words with
1907
a '2' in their name. The stack effect describes the word
1908
perfectly. Words like these, which produce and manipulate lots
1909
of stack items should be avoided if possible.
1910
 
1911
Usage:
1912
         ( -- : empty stack )
1913
   1 2   (  -- 1 2  )
1914
   2dup  ( 1 2 -- 1 2 1 2 )
1915
 
1916
 
1917
 
1918
 
1919
 
1920
 
1921
; ==== abs  ( n -- u : absolute value of a number ) ============
1922
Returns the absolute value of a signed number, positive values
1923
stay the same, negative values become positive. Signed numbers
1924
are stored in twos compliment format, the function fails for
1925
the number $8000, which is unaffected by abs.
1926
 
1927
Usage:
1928
 
1929
  -1 abs .  ( prints '1' )
1930
   4 abs .  ( prints '4' )
1931
 
1932
 
1933
 
1934
 
1935
 
1936
 
1937
; ==== accept  ( b u -- b u : accept a line ) ==================
1938
 
1939
 
1940
 
1941
 
1942
 
1943
 
1944
 
1945
 
1946
 
1947
 
1948
 
1949
 
1950
 
1951
 
1952
 
1953
; ==== aft  ( -- : part of for...aft...then...next ) ===========
1954
 
1955
 
1956
 
1957
 
1958
 
1959
 
1960
 
1961
 
1962
 
1963
 
1964
 
1965
 
1966
 
1967
 
1968
 
1969
; ==== again  ( -- : part of begin...again loop ) ==============
1970
'again' should only be used as part of a 'begin...again' loop,
1971
which is a compile time only wordset. Using an 'again' without
1972
a 'begin' may also be met with an error, as this situtation
1973
should be caught by the compiler security mechanisms. The
1974
'begin...again' looping mechanism forms an indefinite or an
1975
infinite loop, the Forth interpreter/CPU jumps back to the
1976
corresponding 'begin' unconditionally, and excluding any
1977
errors/exceptions will do so forever.
1978
 
1979
Usage:
1980
  : invalid-1 again ; ( <- invalid use, no matching 'begin )
1981
  again        ( <- invalid use, outside a word definition )
1982
  : test begin 1 . cr again ;
1983
  test ( 'test' prints '1' forever )
1984
 
1985
; ==== align  ( -- : align dictionary pointer ) ================
1986
'align' is a word that takes no arguments and returns nothing,
1987
it acts on the dictionary pointer variable (the internal name
1988
for which is usually 'cp', the variable is returned by the
1989
word 'here'). It should be used after allocating a data
1990
structure in the dictionary which is byte aligned and before
1991
defining any new words, the word 'align' reserves space up to
1992
the next cell aligned address by manipulating the dictionary
1993
pointer variable.
1994
 
1995
Usage:
1996
 
1997
   create x 3 allot ( <- dictionary pointer is now unaligned )
1998
   align            ( <- dictionary pointer is now aligned )
1999
 
2000
 
2001
; ==== aligned  ( b -- a : align up an address ) ===============
2002
 
2003
 
2004
 
2005
 
2006
 
2007
 
2008
 
2009
 
2010
 
2011
 
2012
 
2013
 
2014
 
2015
 
2016
 
2017
; ==== allot  ( n -- : allocate 'n' bytes ) ====================
2018
Allocate 'n' bytes of space in the dictionary, 'n' can be
2019
either positive, or negative, negative values deallocate space,
2020
which may break things.
2021
 
2022
 
2023
 
2024
 
2025
 
2026
 
2027
 
2028
 
2029
 
2030
 
2031
 
2032
 
2033
; ==== and  ( u1 u2 -- u3 : bitwise and of two numbers ) =======
2034
This performs a bitwise and on two numbers.
2035
 
2036
 
2037
 
2038
 
2039
 
2040
 
2041
 
2042
 
2043
 
2044
 
2045
 
2046
 
2047
 
2048
 
2049
; ==== ansi ( n c -- : emit an ANSI escape command ) ===========
2050
 
2051
 
2052
 
2053
 
2054
 
2055
 
2056
 
2057
 
2058
 
2059
 
2060
 
2061
 
2062
 
2063
 
2064
 
2065
; ==== at-xy  ( x y -- : place cursor at column 'x', row 'y' ) =
2066
 
2067
 
2068
 
2069
 
2070
 
2071
 
2072
 
2073
 
2074
 
2075
 
2076
 
2077
 
2078
 
2079
 
2080
 
2081
; ==== base  ( -- a : address of base radix ) ==================
2082
Pushes the address of the base variable onto the variable stack,
2083
this can be used to change the input and output radix of numbers
2084
to a base between 2 and 36 inclusive. Characters '0' to '9' are
2085
used for numbers 0 through 9, and letters 'A' to 'Z' are used
2086
for numbers 10 to 35, upper case and lower case letter can be
2087
used, only upper case characters are output.
2088
 
2089
Setting the base to an invalid value can cause exceptions to
2090
be thrown in other words.
2091
 
2092
Example usage:
2093
   $2 base !
2094
   base @
2095
   $8 base !
2096
 
2097
; ==== b/buf  ( -- u : number of bytes in a block ) ============
2098
This pushes the number of bytes in a block onto the stack, which
2099
is 1024 in most Forth implementations, including this one.
2100
 
2101
 
2102
 
2103
 
2104
 
2105
 
2106
 
2107
 
2108
 
2109
 
2110
 
2111
 
2112
 
2113
; ==== begin  ( -- : start begin...until/again loop ) ==========
2114
 
2115
 
2116
 
2117
 
2118
 
2119
 
2120
 
2121
 
2122
 
2123
 
2124
 
2125
 
2126
 
2127
 
2128
 
2129
; ==== bl  ( -- u : value for space character ) ================
2130
This pushes the space character to the stack.
2131
 
2132
 
2133
 
2134
 
2135
 
2136
 
2137
 
2138
 
2139
 
2140
 
2141
 
2142
 
2143
 
2144
 
2145
; ==== blank  ( b u -- : fill array with blanks ) ==============
2146
This word writes the space character to a byte array, one use
2147
is to erase a block before it is displayed with 'list'.
2148
 
2149
 
2150
 
2151
 
2152
 
2153
 
2154
 
2155
 
2156
 
2157
 
2158
 
2159
 
2160
 
2161
; ==== blk  ( -- a : address of last loaded block ) ============
2162
 
2163
 
2164
 
2165
 
2166
 
2167
 
2168
 
2169
 
2170
 
2171
 
2172
 
2173
 
2174
 
2175
 
2176
 
2177
; ==== block  ( u -- a : perform block operation ) =============
2178
 
2179
 
2180
 
2181
 
2182
 
2183
 
2184
 
2185
 
2186
 
2187
 
2188
 
2189
 
2190
 
2191
 
2192
 
2193
; ==== +block ( n -- k : return block number relative to blk ) =
2194
'+block' is a useful common operation which returns the block
2195
number relative to the one currently loaded in 'blk', it can
2196
be thus used to navigate relative to the most recently loaded
2197
block. The number it accepts is signed, the next blocks being
2198
specified with a positive number, the current with zero, and
2199
negative being prior blocks.
2200
 
2201
Usage:
2202
 
2203
  : +block blk @ + ;      ( n -- k )
2204
  : next 1 +block ;       (
2205
  : previous -1 +block ;
2206
  5 block drop next next previous
2207
 
2208
 
2209
; ==== border  ( -- a : variable for list display control ) ====
2210
 
2211
 
2212
 
2213
 
2214
 
2215
 
2216
 
2217
 
2218
 
2219
 
2220
 
2221
 
2222
 
2223
 
2224
 
2225
; ==== c,  ( c -- : compile character into dictionary ) ========
2226
This words takes a character and writes the character in the
2227
next available location in the dictionary, and updates the
2228
dictionary pointer. This word can cause the dictionary number
2229
to be misaligned, 'align' can be used to remedy this.
2230
 
2231
 
2232
 
2233
 
2234
 
2235
 
2236
 
2237
 
2238
 
2239
 
2240
 
2241
; ==== c!  ( c b -- : store 'c' at 'b' ) =======================
2242
'c!' is the byte oriented store word, it stores a byte 'c' at
2243
a potentially unaligned address 'b'. This is not a primitive
2244
operation provided by the processor as it can only do cell
2245
sized loads and stores in a single instruction. The
2246
corresponding word for load a byte is 'c@'. The cell load
2247
and store words are '@' and '!' respectively.
2248
 
2249
 
2250
 
2251
 
2252
 
2253
 
2254
 
2255
 
2256
 
2257
; ==== c@  ( b -- c : retrieve 'c' from 'b' ) ==================
2258
'c@' retrieves a single byte from the address 'b', this address
2259
does not have to be an aligned address. For storing a byte, see
2260
'c!'. This word is the byte oriented version of '@', '@'
2261
operates on Forth cells. On this processor 'c@' is not a
2262
primitive operation, for speed '@' should be used instead, as
2263
loads (and stores) can only be done by cell and not by byte.
2264
 
2265
 
2266
 
2267
 
2268
 
2269
 
2270
 
2271
 
2272
 
2273
; ==== catch  ( xt -- n | 0 : catch possible exception ) =======
2274
'catch' can catch exceptions thrown by 'throw', it is part of
2275
a pair of words that work as a pair like many Forth words, one
2276
cannot exist without the other. 'catch' takes an execution
2277
token, executes it, and returns 0 if nothing was thrown, and
2278
a non-zero value if something was. 'catch' is also used as part
2279
of the interpreter loop as an exception handler of last resort.
2280
The word 'throw' should also be consulted. 'throw' and 'catch'
2281
manipulate the return stack a lot and are fairly complex words
2282
that are hard to implement on a processor with hardware stacks.
2283
 
2284
Usage:
2285
 
2286
  : x 99 throw ;   : y x 66 ;
2287
  ' x catch . ( prints '99' )
2288
 
2289
; ==== ccitt  ( crc c -- crc : compute CRC step ) ==============
2290
 
2291
 
2292
 
2293
 
2294
 
2295
 
2296
 
2297
 
2298
 
2299
 
2300
 
2301
 
2302
 
2303
 
2304
 
2305
; ==== cell-  ( a -- a : decrement address by single cell ) ====
2306
'cell-' is the opposite of 'cell+', it decrements an address
2307
value by a cell. On this 16-bit Forth a cell consists of two
2308
bytes, but on a 32-bit one it would decrement by four. Note
2309
that this word does not ensure the resulting address is
2310
aligned, if an unaligned addressed was passed in and unaligned
2311
address will pop out, and an aligned address will stay so. This
2312
word is needed so Forth code can be written that is portable
2313
across different word size computers.
2314
 
2315
 
2316
 
2317
 
2318
 
2319
 
2320
 
2321
; ==== cell+  ( a -- a : increment address by single cell ) ====
2322
'cell+' increments an address by the size of a cell, see
2323
'cell-' for further description on this.
2324
 
2325
 
2326
 
2327
 
2328
 
2329
 
2330
 
2331
 
2332
 
2333
 
2334
 
2335
 
2336
 
2337
; ==== cells  ( n -- n : convert cell to byte count ) ==========
2338
'cells' is a word that takes a count of the number of cells and
2339
returns the number of bytes that those cells would occupy, on
2340
this 16-bit Forth 'cells' is essentially a multiply by two
2341
operation, but on other Forths it could be a different value,
2342
so this word is used for portability reasons.
2343
 
2344
Usage:
2345
 
2346
 
2347
  1 cells . ( prints '2' )
2348
  2 cells . ( prints '4' )
2349
  create x 4 cells allot ( 'x' created, space for 4 cells )
2350
 
2351
 
2352
 
2353
; ==== >char ( c -- c : convert unprintable character ) ========
2354
'>char' converts a character so that it can be printed by
2355
converting any characters which cannot be printed to the
2356
underscore character ('_'). This is used within words like
2357
'message' and 'list'. Tabs also get converted, as do control
2358
characters, delete and any character outside of the ASCII
2359
range.
2360
 
2361
 
2362
 
2363
 
2364
 
2365
 
2366
 
2367
 
2368
 
2369
; ==== char  ( -- c ;  : parse character ) =============
2370
This word reads in a space delimited word from the input stream
2371
and pushes the first character of that word onto the stack. An
2372
entire word is potentially read in, but only the first
2373
character is used.
2374
 
2375
Usage:
2376
 
2377
  char x .          ( prints '$78' )
2378
  char xylophone .  ( prints '$78', also )
2379
  char 0 .          ( prints '$30' )
2380
 
2381
 
2382
 
2383
 
2384
 
2385
; ==== [char]  ( -- ;  : compile character literal ) ===
2386
This is an immediate word that compiles a character into the
2387
dictionary as a literal value that will be pushed onto the
2388
stack when the word is run. It parses a space delimited word
2389
and compiles the first character of that word. It is a compile
2390
only word. Although an entire word is parsed, only the first
2391
character is used.
2392
 
2393
Usage:
2394
 
2395
  : print-c [char] c emit ;
2396
  print-c c            ( 'c' is printed )
2397
  : push-c [char] c ;
2398
  push-c . 63          ( ASCII 'c' is $63 )
2399
 
2400
 
2401
; ==== cmove  ( b b u -- : move block memory ) =================
2402
'cmove' copies a block of characters from one location to
2403
another.
2404
 
2405
 
2406
 
2407
 
2408
 
2409
 
2410
 
2411
 
2412
 
2413
 
2414
 
2415
 
2416
 
2417
; ==== compile ( -- : compile next word into dictionary ) ======
2418
 
2419
 
2420
 
2421
 
2422
 
2423
 
2424
 
2425
 
2426
 
2427
 
2428
 
2429
 
2430
 
2431
 
2432
 
2433
; ==== [compile]  ( -- xt : compile next immediate word ) ======
2434
 
2435
 
2436
 
2437
 
2438
 
2439
 
2440
 
2441
 
2442
 
2443
 
2444
 
2445
 
2446
 
2447
 
2448
 
2449
; ==== compile,  ( xt -- : compile execution token ) ===========
2450
'compile,' compiles an execution token into the next available
2451
location in the dictionary, taking up a cell of space. This
2452
word must be used when compiling in an execution into a word,
2453
the word ',' will compile an unconditional branch.
2454
 
2455
 
2456
 
2457
 
2458
 
2459
 
2460
 
2461
 
2462
 
2463
 
2464
 
2465
; ==== conceal  ( -- : emit stars instead of characters ) ======
2466
 
2467
 
2468
 
2469
 
2470
 
2471
 
2472
 
2473
 
2474
 
2475
 
2476
 
2477
 
2478
 
2479
 
2480
 
2481
; ==== console  ( -- : UART only mode ) ========================
2482
 
2483
 
2484
 
2485
 
2486
 
2487
 
2488
 
2489
 
2490
 
2491
 
2492
 
2493
 
2494
 
2495
 
2496
 
2497
; ==== constant  ( n -- ;  : create constant ) =========
2498
'constant' is a defining word that creates a new constant, it
2499
takes in a value from the stack, and parses the next word from
2500
the input stream which will become the name of the new
2501
constant. This word uses 'create' and 'does>' internally to
2502
do the work, and is similar to the definition of 'variable'.
2503
At run time the new word when called will leave a copy of
2504
'n' on the stack.
2505
 
2506
Usage:
2507
 
2508
   : constant create , does> @ ;
2509
   4 constant x
2510
   3 constant y
2511
   x y + . ( prints '7' )
2512
 
2513
; ==== count  ( b -- b c : retrieve next character in string ) =
2514
'count' is a very useful word when dealing with strings,
2515
especially counted strings. It retrieves a character from an
2516
address and increments that address by one character. This can
2517
be used to advance through a string, and with counted strings
2518
it can be used to retrieve the string length which is stored
2519
in the first byte of the string.
2520
 
2521
 
2522
 
2523
 
2524
 
2525
 
2526
 
2527
 
2528
 
2529
; ==== cpu-id  ( -- u : return CPU-ID ) ========================
2530
This is an assembly instruction that pushes the CPU-ID of the
2531
CPU onto the stack. It can be used to determine whether the
2532
system is running in a simulation or on the hardware.
2533
 
2534
 
2535
 
2536
 
2537
 
2538
 
2539
 
2540
 
2541
 
2542
 
2543
 
2544
 
2545
; ==== cr  ( -- : emit new line ) ==============================
2546
'cr' emits a new line, which consists of a carriage return
2547
character followed by a linefeed character. This format is used
2548
as communication occurs over a UART (and the VGA output display
2549
behaves like a VT100 video terminal).
2550
 
2551
 
2552
 
2553
 
2554
 
2555
 
2556
 
2557
 
2558
 
2559
 
2560
 
2561
; ==== crc  ( b u -- u : perform CRC over array ) ==============
2562
'crc' performs a Cyclic Redundancy Check (CRC) over an array
2563
specified by an address ('b') and length ('u') pair. It
2564
returns the result in a single cell. There are many different
2565
ways of computing a CRC which depending on starting value,
2566
what operation to perform at the end of the calculation and
2567
what polynomial is used. 'crc' used the word 'ccitt' to do
2568
the actual calculation on each byte, using the CCITT
2569
polynomial, which is a standard polynomial. See 'ccitt' for
2570
more information. CRCs can be used for error detection.
2571
 
2572
Usage:
2573
 
2574
  : s1 $" hello" count ;
2575
  hex x crc . ( prints 'D26E' )
2576
 
2577
; ==== create  ( -- ;  : make 'created' word ) =========
2578
'create' is a very useful word that allows the creation of
2579
new words. It parses the next space delimited string from the
2580
input stream and creates a word which when run returns a
2581
pointer to its code field. It can be used to make words which
2582
create new words, and 'does>' can be used to give those new
2583
words different actions. The 'create'/'does>' combination is
2584
a really important concept in Forth and has been called 'The
2585
Pearl of Forth'.
2586
 
2587
Usage:
2588
 
2589
  create x 2 cells allot
2590
  : constant create , does> @ ;
2591
  4 constant y ( a new constant called 'y' has been made )
2592
 
2593
; ==== decimal  ( -- : switch radix to decimal ) ===============
2594
'decimal' switches the current output radix into decimal as
2595
the name suggests. This can be useful when you are lost and do
2596
not know what the current output radix is, or for performing
2597
calculations like a human instead of a machine! Hexadecimal
2598
values can still be input by prefixing the number with '$'.
2599
Negative numbers will be printed with a leading '-', unlike
2600
in other output bases, when a '.' is used to print the number.
2601
 
2602
 
2603
 
2604
 
2605
 
2606
 
2607
 
2608
 
2609
; ==== dm+  ( a u -- u : print out section of memory ) =========
2610
'dm+' prints out a section of memory in numeric forth, it
2611
prints out the contents starting from address 'a' and advancing
2612
for 'u' bytes, rounded down to the nearest aligned cell
2613
location. It is a factor of 'dump' and is useful as a debugging
2614
tool in itself. It will print out the values in the current
2615
output radix, as stored in the 'base' variable. A crude memory
2616
dump can be performed with '0 here dm+'. No newlines are
2617
printed, but spaces are printed between cell values.
2618
 
2619
Usage:
2620
 
2621
  $40 $200 dm+ ( print $200 bytes starting from address $40 )
2622
 
2623
 
2624
 
2625
; ==== dnegate  ( d -- d : negate a double value ) =============
2626
'dnegate' is the double cell number equivalent of 'negate', it
2627
negates a double cell number. Positive numbers become negative
2628
and vice versa. Double cell numbers take up two items on the
2629
stack as the name suggests.
2630
 
2631
 
2632
 
2633
 
2634
 
2635
 
2636
 
2637
 
2638
 
2639
 
2640
 
2641
; ==== doer  ( -- ;  : create a 'doer' word ) ==========
2642
 
2643
 
2644
 
2645
 
2646
 
2647
 
2648
 
2649
 
2650
 
2651
 
2652
 
2653
 
2654
 
2655
 
2656
 
2657
; ==== does>  ( -- : start 'does' section of word ) ============
2658
 
2659
 
2660
 
2661
 
2662
 
2663
 
2664
 
2665
 
2666
 
2667
 
2668
 
2669
 
2670
 
2671
 
2672
 
2673
; ==== drop  ( u -- : drop a value ) ===========================
2674
'drop' simply pops off and discards the topmost value on the
2675
variable stack.  'rdrop' is the return stack equivalent.
2676
 
2677
 
2678
 
2679
 
2680
 
2681
 
2682
 
2683
 
2684
 
2685
 
2686
 
2687
 
2688
 
2689
; ==== dump  ( a u -- : dump a section of memory ) =============
2690
'dump' is a debugging tool that dumps a section of memory
2691
starting at the address 'a' and proceeds for at least 'u'
2692
characters. It dumps the memory contents in whatever the
2693
current output base it, as well as displaying the memory
2694
contents as characters when the characters are printable.
2695
 
2696
Example:
2697
 
2698
 
2699
Example Output (condensed to fit on the screen):
2700
 0:  104C 0 0 0 0 0 E9B 0                     L_______________
2701
 10: 8000 6403 7075 6081 601C 8010 6F04 6576  ___dup_`_`___ove
2702
 20: 72 6181 601C 801A 6906 766E 7265 74      r__a_`___invert_
2703
 30: 6600 601C 8026 2B01 6203 601C 8034 7304  _f_`&__+_b_`4__s
2704
 ( and so on...)
2705
; ==== dup  ( n -- n n : duplicate a value ) ===================
2706
The stack comment explains this word completely, it simply
2707
duplicates the topmost item on the variable stack. This is a
2708
common Forth word that should be memorized - you should not
2709
need to look it up here! Other common stack manipulation words
2710
include 'swap', 'over', 'nip', 'tuck', '2dup', 'drop', and
2711
'2drop' amongst others. If you find keeping track of the stack
2712
difficult, try to rethink and refactor your code, stack
2713
juggling gets easier over time but nothing beats out removing
2714
complex combinations of 'dup', 'swap', 'over' and the like.
2715
 
2716
Usage:
2717
 
2718
  5 dup ( 5 -- 5 5 )
2719
 
2720
 
2721
; ==== ?dup  ( n -- n n | 0 : duplicate value if not zero ) ====
2722
This word duplicates a number if that number is non zero, it
2723
returns just a single zero if the input number was zero. It
2724
finds a lot of use in 'begin...while...repeat' loop constructs,
2725
as well as in other looping constructs.
2726
 
2727
Usage:
2728
 
2729
  : ?dup dup if dup then ;
2730
 
2731
  3 ?dup .s ( 3 -- 3 3 )
2732
 
2733
 
2734
 
2735
 
2736
 
2737
; ==== else  ( -- : if...else...then ) =========================
2738
'else' is a word which forms part of the 'if...else...then'
2739
clause, it can only be used from within a Forth word
2740
definition and should always be used with the matching 'if'
2741
and 'then'.
2742
 
2743
Usage:
2744
 
2745
  : example cr if ." Hello!" else ." Goodbye!" then cr ;
2746
  1 example ( prints 'Hello!' )
2747
 
2748
 
2749
 
2750
 
2751
 
2752
 
2753
; ==== emit  ( c -- : emit a character ) =======================
2754
'emit' emits a single character to the output device, this
2755
device is by default both the UART and the VT100 terminal
2756
emulator can be displayed on a VGA capable display. The board
2757
used has VGA output. The output of this word can be redirected
2758
by words like 'io!', 'stars', 'conceal', 'file', 'console' and
2759
'interactive'.
2760
 
2761
 
2762
 
2763
Usage:
2764
 
2765
  $6b emit ( prints 'k' )
2766
 
2767
 
2768
 
2769
; ==== empty-buffers  ( -- : deallocate block buffer ) =========
2770
'empty-buffers' deallocates any currently loaded block buffers,
2771
and stores and invalid block number in 'blk'. It can be used
2772
to discard any changes made to any currently loaded blocks.
2773
 
2774
 
2775
 
2776
 
2777
 
2778
 
2779
 
2780
 
2781
 
2782
 
2783
 
2784
 
2785
; ==== evaluate  ( a u -- : evaluate block of memory ) =========
2786
'evaluate' takes a string specified by an address 'a' and a
2787
length 'u' and evaluates it as if it were typed in by the
2788
user. 'source-id' is set to '-1' for the duration of this
2789
so code can work out it is being evaluated and not typed in.
2790
 
2791
Usage:
2792
 
2793
  : s1 $" 2 2 + . cr " count ;
2794
  s1 evaluate ( prints '4' )
2795
 
2796
 
2797
 
2798
 
2799
 
2800
 
2801
; ==== execute  ( xt -- : execute an execution token ) =========
2802
'execute' takes an execution token, which represents a callable
2803
function, and it executes that function. Execution tokens are
2804
returned by words like "'" (quote), or by ":noname".
2805
 
2806
 
2807
 
2808
 
2809
 
2810
 
2811
 
2812
 
2813
 
2814
 
2815
 
2816
 
2817
; ==== @execute  ( a -- : execute token at 'a' if non-zero ) ===
2818
'@execute' expects an address of a value containing an
2819
execution token to execute, it retrieves this token from the
2820
address and executes it if the token is a non-zero value. This
2821
is primarily uses for vectored word execution.
2822
 
2823
 
2824
 
2825
 
2826
 
2827
 
2828
 
2829
 
2830
 
2831
 
2832
 
2833
; ==== exit  ( -- : exit from word ) ===========================
2834
This word is an assembly instruction that will be inlined into
2835
a word when it is executed, it will run but have no effect when
2836
executed in command mode, when compiled into a word it will
2837
exit that word definition when it is run by returning from that
2838
word. It is compiled into the end of a word definition by
2839
the ';' word, which terminates a word.
2840
 
2841
 
2842
 
2843
 
2844
Example:
2845
   : foo if $f00f . exit then $1337 . ;
2846
 
2847
   1 foo $1337 ( <-- prints $1337 only )
2848
 
2849
; ==== expect  ( b u -- : accept, but store 'u' in span ) ======
2850
 
2851
 
2852
 
2853
 
2854
 
2855
 
2856
 
2857
 
2858
 
2859
 
2860
 
2861
 
2862
 
2863
 
2864
 
2865
; ==== file  ( -- : file transfer mode ) =======================
2866
 
2867
 
2868
 
2869
 
2870
 
2871
 
2872
 
2873
 
2874
 
2875
 
2876
 
2877
 
2878
 
2879
 
2880
 
2881
; ==== fill  ( b u c -- : fill area of memory with 'c' ) =======
2882
 
2883
 
2884
 
2885
 
2886
 
2887
 
2888
 
2889
 
2890
 
2891
 
2892
 
2893
 
2894
 
2895
 
2896
 
2897
; ==== find  ( a -- pwd 1 | pwd -1 | a 0 : find word ) =========
2898
 
2899
 
2900
 
2901
 
2902
 
2903
 
2904
 
2905
 
2906
 
2907
 
2908
 
2909
 
2910
 
2911
 
2912
 
2913
; ==== flash  ( -- : add flash words to search order ) =========
2914
The flash related word set requires its own glossary and
2915
description. It is for manipulating the onboard memory, not
2916
just the Flash chip on the Nexys3 but the SRAM as well (as
2917
both devices share data, address and most control lines).
2918
 
2919
The startup sequences loads blocks from Flash to SRAM, the
2920
SRAM can be modified freely, but committing data to Flash is
2921
a manual process as erasing and writing to Flash too many times
2922
can cause it to wear out.
2923
 
2924
The source code should be consulted for a list of the memory
2925
related words, their usage and other such information.
2926
 
2927
 
2928
 
2929
; ==== flush  ( -- : write dirty blocks, empty-buffers also ) ==
2930
 
2931
 
2932
 
2933
 
2934
 
2935
 
2936
 
2937
 
2938
 
2939
 
2940
 
2941
 
2942
 
2943
 
2944
 
2945
; ==== for  ( -- : part of for...next loop ) ===================
2946
 
2947
 
2948
 
2949
 
2950
 
2951
 
2952
 
2953
 
2954
 
2955
 
2956
 
2957
 
2958
 
2959
 
2960
 
2961
; ==== forth  ( -- : set search order to the default ) =========
2962
 
2963
 
2964
 
2965
 
2966
 
2967
 
2968
 
2969
 
2970
 
2971
 
2972
 
2973
 
2974
 
2975
 
2976
 
2977
; ==== forth-wordlist  ( -- voc : return Forth vocabulary ) ====
2978
 
2979
 
2980
 
2981
 
2982
 
2983
 
2984
 
2985
 
2986
 
2987
 
2988
 
2989
 
2990
 
2991
 
2992
 
2993
; ==== get-order  ( -- vn...v0 u : get search order ) ==========
2994
'get-order' is the counter part to 'set-order', it takes a
2995
variable number of arguments off of the stack, denoted by 'u',
2996
which each represent a word list. It used for inspecting the
2997
current search order in use by the interpreter.
2998
 
2999
 
3000
 
3001
 
3002
 
3003
 
3004
 
3005
 
3006
 
3007
 
3008
 
3009
; ==== here  ( -- a : return dictionary address ) ==============
3010
'here' returns the current address of where the dictionary
3011
pointer is, new words will be compiled at this address. The
3012
dictionary pointer is updated by compiling words and numbers
3013
into the dictionary, words like ',' and 'compile,'.
3014
 
3015
 
3016
 
3017
 
3018
 
3019
 
3020
 
3021
 
3022
 
3023
 
3024
 
3025
; ==== hex  ( -- : set numeric radix to hexadecimal ) ==========
3026
This sets the current input output radix to hexadecimal, which
3027
is the default radix for numbers in this Forth. If operating
3028
in other bases, or to make it clear which base you mean, a
3029
number can be prefixed with '$' to force the input base to
3030
hex for that number. This affects all number conversions
3031
globally as it sets the 'base' variable to '$10'. It is
3032
equivalent to '$10 base !'.
3033
 
3034
Usage:
3035
 
3036
  hex 9999 1111 + .     ( prints 'AAAA' )
3037
  decimal 9999 1111 + . ( prints '11110' )
3038
 
3039
 
3040
 
3041
; ==== hi  ( -- : initialize and login to system ) =============
3042
'hi' initializes the system and calls the routine that prints
3043
the login prompt.
3044
 
3045
 
3046
 
3047
 
3048
 
3049
 
3050
 
3051
 
3052
 
3053
 
3054
 
3055
 
3056
 
3057
; ==== hld ( -- a : hold count for pictured numeric output ) ===
3058
'hld' is a variable which contains the current hold count for
3059
the pictured numeric output. As characters are added to the
3060
output buffer with the word 'hold', this value is increment. It
3061
is reset by '<#'. The value for 'hld' may actually be a count
3062
or a pointer.
3063
 
3064
 
3065
 
3066
 
3067
 
3068
 
3069
 
3070
 
3071
 
3072
 
3073
; ==== hold  ( c -- : put byte into numeric output string ) ====
3074
'hold' puts a byte into the hold buffer, which is used by the
3075
Pictured Numeric Output (PNO) routines as a temporary buffer to
3076
create a string that represents the number to be output. The
3077
PNO related routines include; 'hold', 'hld', '<#', '#', '#s',
3078
and '#>'. They are used by words like '.' and 'u.'. The
3079
hold buffer is not that large, at has a minimum size of eighty
3080
characters, so should not be used for large strings.
3081
 
3082
Usage:
3083
 
3084
  : (u.u) <# # # [char] . hold # # #> ;
3085
  : u.u base @ >r hex (u.u) type r> base ! ;
3086
  $1234 u.u ( prints '12.34' )
3087
 
3088
 
3089
; ==== ien  ( f -- f : set interrupt flag ) ====================
3090
 
3091
 
3092
 
3093
 
3094
 
3095
 
3096
 
3097
 
3098
 
3099
 
3100
 
3101
 
3102
 
3103
 
3104
 
3105
; ==== ien?  ( -- f : are interrupts enabled? ) ================
3106
 
3107
 
3108
 
3109
 
3110
 
3111
 
3112
 
3113
 
3114
 
3115
 
3116
 
3117
 
3118
 
3119
 
3120
 
3121
; ==== if  ( -- : part of if...then/if...else...then) ==========
3122
'if' is an immediate word that should only be used within a
3123
word definition. It is used to form 'if...then' and
3124
'if...else...then' clauses for conditional execution of
3125
words. The words 'else' and 'then' should also be consulted.
3126
'if' has differing behavior at compile time and run time,
3127
which is covered in the documentation for the system internals,
3128
however 'if' is just an ordinary Forth word. When run, it
3129
takes a value from the variable stack and jumps to the
3130
corresponding 'else' or 'then' if it is zero, if it is non
3131
zero it continues execution after the 'else'.
3132
 
3133
  : example cr if $" Hello" else $" Bye" then count type cr ;
3134
 
3135
  1 example ( prints 'Bye' )
3136
 
3137
; ==== immediate  ( -- : make last defined word immediate ) ====
3138
'immediate' is an important word that makes the most recently
3139
defined word 'immediate', that is it will be executed even
3140
when in compile mode. All control structure words are
3141
immediate words such as 'if', and 'for'.
3142
 
3143
 
3144
 
3145
 
3146
 
3147
 
3148
 
3149
 
3150
 
3151
 
3152
 
3153
; ==== >in  ( -- a : index into parse input at address ) =======
3154
 
3155
 
3156
 
3157
 
3158
 
3159
 
3160
 
3161
 
3162
 
3163
 
3164
 
3165
 
3166
 
3167
 
3168
 
3169
; ==== index  ( k1 k2 -- : print first line of block range ) ===
3170
'index' displays the first line in a range of blocks, if the
3171
blocks are formatted correctly with the first line containing a
3172
description of the block contents then this works to display an
3173
index of the blocks.
3174
 
3175
 
3176
 
3177
 
3178
 
3179
 
3180
 
3181
 
3182
 
3183
 
3184
 
3185
; ==== interactive  ( -- : interactive I/O mode ) ==============
3186
 
3187
 
3188
 
3189
 
3190
 
3191
 
3192
 
3193
 
3194
 
3195
 
3196
 
3197
 
3198
 
3199
 
3200
 
3201
; ==== interpret  ( ??? a -- ??? : interpret word/number ) =====
3202
 
3203
 
3204
 
3205
 
3206
 
3207
 
3208
 
3209
 
3210
 
3211
 
3212
 
3213
 
3214
 
3215
 
3216
 
3217
; ==== invert  ( u -- u : bitwise invert ) =====================
3218
'invert' performs a bitwise invert on a number. For a
3219
twos compliment negation see 'negate'.
3220
 
3221
 
3222
Usage:
3223
 
3224
  hex
3225
 
3226
     4 invert . ( prints 'FFFB' )
3227
  FFFF invert . ( prints '0' )
3228
  AAAA invert . ( prints '5555' )
3229
 
3230
 
3231
 
3232
 
3233
; ==== io!  ( -- : initialize IO channels ) ====================
3234
'io!' initializes the I/O devices and sets the input and output
3235
devices to their default values (read from UART and PS/2
3236
keyboard, write to the VT100 display, and to UART - both at
3237
the same time). It also disables the interrupts, and sets the
3238
timer to a count but not generate interrupts.
3239
 
3240
 
3241
 
3242
 
3243
 
3244
Example usage:
3245
 
3246
   io! ( ...that's not a very good demonstration... )
3247
 
3248
 
3249
; ==== key  ( -- c : block until character read in ) ===========
3250
This word blocks until a character has been read in from the
3251
current input device (or devices). The input devices can be
3252
either be the UART or the PS/2 Keyboard. The input devices can
3253
be changed with the 'io!', 'console', 'conceal', 'interactive'
3254
and 'file' words.
3255
 
3256
 
3257
 
3258
 
3259
 
3260
 
3261
 
3262
 
3263
 
3264
 
3265
; ==== key?  ( -- c -1 | 0 : non-blocking character read ) =====
3266
This is a non-blocking version of 'key', it returns a
3267
character and true (-1) if a new character has come through
3268
from input devices, and only 0 if there is no new character.
3269
The input devices can be either a UART or a PS/2 keyboard, and
3270
this can be changed with the 'io!', 'console', 'conceal', 'file'
3271
and 'interactive' words.
3272
 
3273
 
3274
 
3275
 
3276
 
3277
 
3278
 
3279
 
3280
 
3281
; ==== last  ( -- pwd : last defined word ) ====================
3282
 
3283
 
3284
 
3285
 
3286
 
3287
 
3288
 
3289
 
3290
 
3291
 
3292
 
3293
 
3294
 
3295
 
3296
 
3297
; ==== led!  ( u -- : write value to LEDs ) ====================
3298
'led!' sets the LEDs on the board next to the switches. There
3299
are eight switches, and the lowest eight bits of the input value
3300
are used to set the switches, 1 is on, 0 is off.
3301
 
3302
 
3303
 
3304
 
3305
 
3306
 
3307
 
3308
 
3309
 
3310
 
3311
 
3312
 
3313
; ==== list  ( k -- : list block ) =============================
3314
The word list loads block 'k' from disk and display the contents
3315
of this block on the screen. It displays the block as 16 lines
3316
with a column width of 64. The display format is controlled by
3317
the 'border' variable, if true it 'list' displays the line
3318
number and a border around the block, if false, then it just
3319
display the block line by line without formatting. It is true
3320
by default. 'list' will also call 'page' before it displays
3321
the block if 'border' contains a non-zero value.
3322
 
3323
Usage:
3324
 
3325
   1 list
3326
   2 list
3327
   ( ..ad infinitum )
3328
 
3329
; ==== literal  ( n -- : compile literal into dictionary ) =====
3330
This is an immediate word that compiles a number into the
3331
dictionary. A number takes up between one and two cells in the
3332
dictionary (negative numbers take up two space, positive only
3333
one). It is a compile only word.
3334
 
3335
Usage:
3336
 
3337
  : example [ 2 2 + ] literal ;
3338
  example . ( prints '4' )
3339
 
3340
 
3341
 
3342
 
3343
 
3344
 
3345
; ==== load  ( k -- : load and execute block ) =================
3346
'load' retrieves a block using 'block', and evaluates that
3347
block, executing whatever is in that block as Forth code,
3348
'source-id' will return -1 for the duration of this evaluation,
3349
the input source will be returned to whatever it was before
3350
the evaluation took place, such as keyboard or UART input,
3351
once the evaluation has finished. 'load' is used in the
3352
word 'thru' to do the evaluation of successive blocks off
3353
mass storage.
3354
 
3355
 
3356
 
3357
 
3358
 
3359
 
3360
 
3361
; ==== loaded  ( -- a : variable, true if boot block loaded ) ==
3362
This is a variable which can be set by the user if the loading
3363
of the boot block was successful, and if the error messages
3364
exists on disk. The error handling words in QUIT inspect this
3365
variable to work out if it can lookup error messages and print
3366
them, or if it should just print out the error number.
3367
 
3368
 
3369
 
3370
 
3371
 
3372
 
3373
 
3374
 
3375
 
3376
 
3377
; ==== lshift  ( u1 u2 -- u3: logical left shift u1 by u2 ) ====
3378
This performs a logical left shift on 'u1' by 'u2'.
3379
 
3380
 
3381
 
3382
 
3383
 
3384
 
3385
 
3386
 
3387
 
3388
 
3389
 
3390
 
3391
 
3392
 
3393
; ==== make  ( -- : make part of make/doer words ) =============
3394
'make' is a state aware word that operates on words made with
3395
'doer', it should not be used with other words.
3396
 
3397
 
3398
 
3399
 
3400
 
3401
 
3402
 
3403
 
3404
 
3405
 
3406
 
3407
 
3408
 
3409
; ==== max  ( n1 n2 -- n3: maximum of two numbers ) ============
3410
This returns the maximum of two signed numbers. This is a
3411
signed operation! Some Forths define an unsigned version
3412
called 'umax'. See 'min' for the minimum of two signed
3413
numbers.
3414
 
3415
 
3416
 
3417
 
3418
 
3419
 
3420
 
3421
 
3422
 
3423
 
3424
 
3425
; ==== message  ( u -- : type line from block ) ================
3426
'message' prints a line from a block, a block is 1024 bytes
3427
long, and there are 16 lines of 64 bytes per block. 'u'
3428
specifies a line number, starting at block 0, which contains
3429
lines 0-15, block 1 has lines 16-31 and so on. Lines are
3430
printing omitting any trailing spaces and non-ASCII characters
3431
are replaced with another character (an underscore, '_').
3432
 
3433
This word is useful in printing error messages, the interpreter
3434
maps error codes into line numbers. The error messages start
3435
in block 2 and end in block 5, with one message per line.
3436
 
3437
Usage:
3438
 
3439
  $21 message ( print line 33, or the second line in block 3 )
3440
 
3441
; ==== min  ( n1 n2 -- n3: minimum of two numbers ) ============
3442
This returns the minimum of two signed numbers. 'umin' is not
3443
defined but it is enough to create, it provides an analogue
3444
for unsigned numbers. The word is simple enough to use.
3445
 
3446
  :  min 2dup  < if drop else nip then ; ( n n -- n )
3447
  : umin 2dup u< if drop else nip then ; ( n n -- n )
3448
 
3449
Usage:
3450
 
3451
   3 4 min .    ( prints 3 )
3452
  -3 4 min .    ( prints -3 )
3453
  65533 4 min . ( prints -3, 65533 is -3 on a 16-bit system )
3454
  65533 4 umin . ( prints 4 )
3455
 
3456
 
3457
; ==== m/mod  ( d n -- r q : signed divide / modulo ) ==========
3458
 
3459
 
3460
 
3461
 
3462
 
3463
 
3464
 
3465
 
3466
 
3467
 
3468
 
3469
 
3470
 
3471
 
3472
 
3473
; ==== mod  ( n1 n2 -- r : remainder of n1 divided by n2 ) =====
3474
 
3475
 
3476
 
3477
 
3478
 
3479
 
3480
 
3481
 
3482
 
3483
 
3484
 
3485
 
3486
 
3487
 
3488
 
3489
; ==== /mod  ( n1 n2 -- r q : remainder/quotient ) =============
3490
'/mod' divides 'n1' by 'n2' and returns the remainder ('r')
3491
and the quotient ('q') of that operation. Given '/mod', the
3492
definitions of 'mod' and '/' naturally follow. They are
3493
actually all implemented in the far more useful 'um/mod' word.
3494
 
3495
 
3496
 
3497
 
3498
 
3499
 
3500
 
3501
 
3502
 
3503
 
3504
 
3505
; ==== ms  ( u -- : wait for 'u' milliseconds ) ================
3506
'ms' waits for 'u' milliseconds with a busy loop. It is
3507
predicated on the system running at 100MHz and will need to be
3508
modified if the system frequency changes.
3509
 
3510
 
3511
 
3512
 
3513
 
3514
 
3515
Usage:
3516
   : 1s 1000 ms ; ( -- : wait for a second )
3517
   : toggle-leds 0 begin invert dup led! 1s again ; ( -- )
3518
 
3519
 
3520
 
3521
; ==== negate  ( n -- n : negate a number ) ====================
3522
'negate' performs the negation of a number into twos compliment
3523
format, positive numbers become negative and negative numbers
3524
become positive (with the exclusion of $8000, which stays the
3525
same).
3526
 
3527
 
3528
 
3529
Usage:
3530
 
3531
  decimal
3532
   1 negate . ( '-1' )
3533
 
3534
  -4 negate . ( '4' )
3535
 
3536
 
3537
; ==== next  ( -- : part of for...next loop ) ==================
3538
 
3539
 
3540
 
3541
 
3542
 
3543
 
3544
 
3545
 
3546
 
3547
 
3548
 
3549
 
3550
 
3551
 
3552
 
3553
; ==== nip  ( n1 n2 -- n1 : remove second value on stack ) =====
3554
The stack comment describes this word perfectly, 'nip' removes
3555
the secondmost item on the stack, leaving the topmost intact.
3556
 
3557
 
3558
 
3559
 
3560
 
3561
 
3562
 
3563
 
3564
 
3565
 
3566
 
3567
 
3568
 
3569
; ==== :noname  ( -- xt : start anonymous function ) ===========
3570
The ':noname' word is an immediate word that allows the
3571
creation of words that do not have names, or an anonymous
3572
function. The word can be executed with the 'execute' function.
3573
 
3574
 
3575
 
3576
Usage:
3577
 
3578
  :noname 2 2 + ; execute . ( prints '4' )
3579
  : (;) ' rdrop compile, 0 state ! ;
3580
  : compose >r >r :noname r> compile, r> compile, (;) ;
3581
  : x 2 2 ;
3582
  : y + . ;
3583
  ' x ' y compose execute ( prints '4' )
3584
 
3585
; ==== nuf?  ( -- f : true if 'cr' character pressed ) =========
3586
'nuf?' is a non blocking input word that returns true if a
3587
carriage return was input. It can be used to determine if a
3588
word should continue execution or not.
3589
 
3590
 
3591
 
3592
 
3593
 
3594
 
3595
 
3596
 
3597
 
3598
 
3599
 
3600
 
3601
; ==== number?  ( b u -- n f : is string a number ) ============
3602
 
3603
 
3604
 
3605
 
3606
 
3607
 
3608
 
3609
 
3610
 
3611
 
3612
 
3613
 
3614
 
3615
 
3616
 
3617
; ==== .ok  ( -- : print okay prompt ) =========================
3618
'.ok' prints out 'ok' after the successful execution of an
3619
input line when the Forth interpreter is in the command mode,
3620
the prompt is suppressed when in compile mode.
3621
 
3622
 
3623
 
3624
 
3625
 
3626
 
3627
 
3628
 
3629
 
3630
 
3631
 
3632
 
3633
; ==== or  ( u1 u2 -- u3: bitwise or of two numbers ) ==========
3634
'or' performs the bitwise 'or' of two numbers.
3635
 
3636
 
3637
 
3638
 
3639
 
3640
 
3641
 
3642
 
3643
 
3644
 
3645
 
3646
 
3647
 
3648
 
3649
; ==== over  ( n1 n2 -- n1 n2 n1 : duplicate over ) ============
3650
'over' duplicates the second most item on the variable stack.
3651
Its stack comment describes its workings completely.
3652
 
3653
 
3654
 
3655
 
3656
 
3657
 
3658
 
3659
Usage:
3660
 
3661
  1 2 over .s
3662
  1 2 1
3663
 
3664
 
3665
; ==== pack$  ( b u a -- a : pack string into address ) ========
3666
'pack$' is a useful word when dealing with short Forth
3667
strings, it is used by the interpreter for packing the word
3668
name into the words header. It takes a string specified by
3669
'b u', 'b' being an address of a string, and 'u' beings its
3670
length, and copies the string starting at address 'a', the
3671
first byte of the new string is the length of the string, so
3672
it requires an extra byte be available at 'a'. It then returns
3673
a pointer to this newly packed, counted string.
3674
 
3675
 
3676
 
3677
 
3678
 
3679
 
3680
 
3681
; ==== pad  ( -- a : return address into pad area ) ============
3682
'pad' returns a pointer into the pad area, which begins at
3683
least 80 bytes after the end of the dictionary. The 'pad'
3684
pointer moves when the dictionary pointer moves. It is a useful
3685
area for temporary storage, but should not be used too much.
3686
Some words, such as the Pictured Numeric Output (PNO) words,
3687
use the area just before the pad area.
3688
 
3689
Usage:
3690
 
3691
  3 pad !
3692
  4 pad cell+ !
3693
  pad @ pad cell+ @ + . ( prints '7' )
3694
 
3695
 
3696
 
3697
; ==== page  ( -- : clear page ) ===============================
3698
'page' clears the screen, it does this by emitting the ANSI
3699
terminal escape sequence codes for erasing the display and
3700
moving the cursor position to the top left most cell.
3701
 
3702
 
3703
 
3704
 
3705
 
3706
 
3707
Usage:
3708
 
3709
  page ( <- That's about it, not much to see )
3710
 
3711
 
3712
 
3713
; ==== parse  ( b u c -- b u delta : parse string out ) ========
3714
 
3715
 
3716
 
3717
 
3718
 
3719
 
3720
 
3721
 
3722
 
3723
 
3724
 
3725
 
3726
 
3727
 
3728
 
3729
; ==== pick  ( un...u0 u -- un...u0 u : pick value ) ===========
3730
'pick' selects an item on the stack at an arbitrary depth 'u'
3731
and pushes a copy onto the variable stack. This word should be
3732
used sparingly and it would be better if it was not used at
3733
all due to the way it is implemented and the limited stack size
3734
available to the H2 processor (32-64 cells deep on both stacks,
3735
plus one for the variable stack). The implementation shuffles
3736
data from the variable stack to the return stack, so it is
3737
quite easy to overflow the return stack for valid but high
3738
values of 'u'.
3739
 
3740
Usage:
3741
 
3742
  22 33 44 0 pick . ( prints '44' )
3743
  22 33 44 1 pick . ( prints '33' )
3744
  22 33 44 2 pick . ( prints '22' )
3745
; ==== query  ( -- : get line of input ) =======================
3746
'query' gets a new line of input from the current input device,
3747
and places that line in the Terminal Input Buffer, which can
3748
be accessed by 'source'.
3749
 
3750
 
3751
 
3752
 
3753
 
3754
 
3755
 
3756
 
3757
 
3758
 
3759
 
3760
 
3761
; ==== quit  ( -- : interpreter loop ) =========================
3762
For some reason the interpreter loop is evoked by the word
3763
'quit', which is what it is traditionally called. This is not
3764
a good name, but nonetheless is the standard name for it. The
3765
interpreter loop fetches a line of input, parses a word,
3766
evaluates it, catches/displays any errors and flushes the
3767
current line if there are any, and continues to do this until
3768
the current line contains no new space delimited words/numbers,
3769
whereupon it fetches a new line and repeats the process again.
3770
 
3771
Usage:
3772
 
3773
  quit ( <- invokes another interpreter loop... )
3774
 
3775
 
3776
 
3777
; ==== >r  ( u --, R: -- u : move value to return stack ) ======
3778
'>r', also known as 'to r' moves a variable from the variable
3779
stack to the return stack, its inverse is 'r>'. This word,
3780
along with all return stack words, should be used carefully as
3781
it is possible to trash the return stack with incorrect use.
3782
The word should also be used only from within a word
3783
definition. The stack comment describes the action of this
3784
word completely.
3785
 
3786
Usage:
3787
 
3788
  : rot >r swap r> swap ;    ( n1 n2 n3 -- n2 n3 n1 )
3789
  : -rot swap >r swap r> ;   ( n1 n2 n3 -- n3 n1 n2 )
3790
 
3791
 
3792
 
3793
; ==== r>  ( -- u, R: u --: move value from return stack ) =====
3794
'r>' also known as 'from r', moves a cell sized value from the
3795
return stack to the variable stack. It should only be used from
3796
within a word definition, and only by those that know what they
3797
are doing. It is possible to crash the interpreter by trashing
3798
the return stack with this word. The stack comment for this
3799
word perfectly describes this word.
3800
 
3801
Usage:
3802
 
3803
  : rot >r swap r> swap ;   ( n1 n2 n3 -- n2 n3 n1 )
3804
  : -rot swap >r swap r> ;  ( n1 n2 n3 -- n3 n1 n2 )
3805
 
3806
 
3807
 
3808
 
3809
; ==== r@  ( -- u : R: u -- u: copy top of return stack ) ======
3810
'r@' is a useful word that copies the topmost value on the
3811
return stack, leaving that value in place, and pushes it to
3812
the variable stack.  This word is useful when juggling
3813
variables on the stack, it is also used to access the loop
3814
counter in a "for...next" or "for...aft...then...next"
3815
construct.
3816
 
3817
 
3818
 
3819
 
3820
 
3821
 
3822
 
3823
 
3824
 
3825
; ==== random  ( -- u : random number ) ========================
3826
'random' returns a Pseudo Random Number, it uses a CRC algorithm
3827
and the system timer to generate the value.
3828
 
3829
 
3830
 
3831
 
3832
 
3833
 
3834
 
3835
 
3836
 
3837
 
3838
 
3839
 
3840
 
3841
; ==== rdrop  ( --, R: u -- : drop a value from return stack ) =
3842
'rdrop' is the return stack equivalent of 'drop', it discards
3843
a single value from the return stack.
3844
 
3845
Care should be taken when manipulating the return stack
3846
as it can trash it rendering the system inoperable until it
3847
is restarted.
3848
 
3849
 
3850
 
3851
 
3852
 
3853
 
3854
 
3855
 
3856
 
3857
; ==== recurse  ( -- : recursively call current word ) =========
3858
'recurse' is a word that when used within a word definition it
3859
will recursively call the current word. This is not a tail
3860
call, if this word is used incorrectly it will blow up the
3861
return stack. Some Forths use the construct 'recurse exit'
3862
to implement tail calls, reliant on a peephole optimizer
3863
built into 'exit' to change the call into a branch, this Forth
3864
does not do this. This word is necessary as the word currently
3865
being defined has not been linked into the dictionary yet, to
3866
permit previous versions of the word to be used in the new
3867
definition. This word is a compile only word.
3868
 
3869
Usage:
3870
 
3871
  : pick ?dup if swap >r 1- recurse r> swap exit then dup ;
3872
 
3873
; ==== repeat  ( -- : part of begin...while...repeat ) =========
3874
'repeat' terminates a 'begin...while...repeat' loop. It is a
3875
word that should only be used as part of a
3876
'begin...while...repeat' clause, and should only be used
3877
from within a word definition. It is an immediate word. The
3878
words 'begin' and 'while' should also be consulted. 'repeat'
3879
unconditionally jumps back to the 'begin', it is 'while' that
3880
does the test and potentially jumps past this 'repeat' if the
3881
value it pops from variable stack is zero.
3882
 
3883
 
3884
 
3885
 
3886
 
3887
 
3888
 
3889
; ==== rot  ( n1 n2 n3 -- n2 n3 n1 : rotate three items ) ======
3890
Rotate the first three elements on the variable stack. The
3891
stack comment describes the word completely. If you find your
3892
self using this word too much, you need to rethink and refactor
3893
your Forth. 'rot' is a useful word, but it should be used
3894
sparingly. '-rot' reverses the 'rot' operation.
3895
 
3896
 
3897
 
3898
 
3899
 
3900
 
3901
 
3902
 
3903
 
3904
 
3905
; ==== -rot  ( n1 n2 n3 -- n3 n1 n2 : rotate three items ) =====
3906
Rotate the first three elements on the variable stack in the
3907
opposite direction as 'rot'. If you find yourself using this
3908
word too much it might be best to refactor your code.
3909
 
3910
 
3911
 
3912
 
3913
 
3914
 
3915
 
3916
 
3917
 
3918
 
3919
 
3920
 
3921
; ==== rp@  ( -- u : return stack depth ) ======================
3922
'rp@' push the return stack depth onto the variable stack, it
3923
is an assembly instruction.
3924
 
3925
 
3926
 
3927
 
3928
 
3929
 
3930
 
3931
 
3932
 
3933
 
3934
 
3935
 
3936
 
3937
; ==== rpick  ( u -- u, R: un...u0 : pick return stack value ) =
3938
'rpick' picks a value at an arbitrary depth on the return stack
3939
based on the argument given.
3940
 
3941
 
3942
 
3943
 
3944
 
3945
 
3946
 
3947
 
3948
 
3949
 
3950
 
3951
 
3952
 
3953
; ==== rshift  ( u1 u2 -- u3 : logical right shift u1 by u2 ) ==
3954
'rshift' performs a logical right shift of 'u1' by 'u2' places,
3955
it is equivalent to unsigned division by 2 raised to the power
3956
of 'u2'.
3957
 
3958
 
3959
 
3960
 
3961
 
3962
 
3963
 
3964
 
3965
 
3966
 
3967
 
3968
 
3969
; ==== .s  ( -- : print out variable stack ) ===================
3970
This word is used for debugging, it prints out the entire
3971
variable stack up to the current variable stack depth. It uses
3972
the area between the end of the dictionary and the start of the
3973
PAD area. It is not a reentrant function.
3974
 
3975
 
3976
 
3977
 
3978
 
3979
 
3980
 
3981
 
3982
 
3983
 
3984
 
3985
; ==== #s  ( u -- 0 : repeat '#' until 0 ) =====================
3986
This word repeatedly calls '#' on a number until it is zero, it
3987
should only be used within a pictured numeric output construct
3988
and uses the area between the end of the dictionary and the
3989
beginning of the pad area. Characters are held starting from
3990
the pad area working downwards towards the end of the dictionary
3991
space.
3992
 
3993
 
3994
 
3995
 
3996
 
3997
Example:
3998
  : print-number <# #s #> type ;
3999
  1234 print-number ( <-- prints '1234' )
4000
 
4001
; ==== save-buffers  ( -- : save dirty blocks ) ================
4002
'save-buffers' saves any dirty buffers, if there are any, to
4003
disk and sets the block dirty bit to clean (so subsequent calls
4004
to 'save-buffers' will not save blocks to mass storage unless
4005
they have been 'update'd again). You can make a block dirty
4006
by calling 'update' after the block has been loaded, and before
4007
any other blocks have been loaded.
4008
 
4009
Usage:
4010
 
4011
  5 block drop      ( load block 5, do nothing with it )
4012
  save-buffers      ( nothing happens, block 5 is not dirty )
4013
  4 block 99 swap ! ( store '99' in first element of block 4 )
4014
  update            ( mark block 4 as dirty )
4015
  save-buffers      ( block 4 written back to disk )
4016
 
4017
; ==== see  ( -- ;  : decompile word ) =================
4018
'see' is a complex word that can decompile a Forth word, it is
4019
liable to be buggy. 'see' parses the next space delimited word
4020
in the dictionary, and if found attempts to disassemble the
4021
word into instructions and function calls. If not found 'see'
4022
will throw an exception. The results of 'see' are
4023
implementation dependent. Given a very good implementation
4024
of 'see' it would be possible to dispense with the source
4025
code entirely in text form, the binary could be disassembled,
4026
the code modified, and then it could be reintegrated into
4027
dictionary - the idea is purely speculative, comments would
4028
be missing and this version of 'see' is not good enough.
4029
Not many languages have a disassembler built-in!
4030
Usage:
4031
 
4032
  see word
4033
; ==== segments!  ( u -- : display 'u' on LED displays ) =======
4034
Segments writes a single 16-bit value to the four seven segment
4035
displays on the board. This can be used to display a single
4036
cell as a hexadecimal value.
4037
 
4038
 
4039
 
4040
 
4041
 
4042
 
4043
Usage:
4044
 
4045
  $cafe segments!
4046
  $d1ed segments!
4047
  $0001 segments!
4048
 
4049
; ==== set-order  ( vn...v0 n -- : set search order ) ==========
4050
This word sets the search order for the dictionary search. It
4051
accepts a variable number of items off of the stack, 'n' is
4052
the number of those item. A special case for the value of 'n'
4053
exists, when it is '-1' it sets the order to the minimal
4054
search order.
4055
 
4056
 
4057
 
4058
 
4059
 
4060
 
4061
 
4062
 
4063
 
4064
 
4065
; ==== sgr  ( u -- : set ANSI terminal SGR attribute ) =========
4066
'sgr' takes a number and emits it as a 'Select Graphic
4067
Rendition' command, which is a standard ANSI Escape sequence
4068
used for terminal control. SGR commands relate to colors and
4069
how the text is presents, for example numbers $1E to $25 are
4070
used to set the foreground color, $28 to $2F the background
4071
color. $0 is used to reset all of the attributes, $8 is used
4072
to conceal character output, $7 for reverse video. Not all
4073
SGR commands are processed by the VT100 hardware, and if
4074
talking to the device over the UART it depends on the terminal
4075
emulator you are using.
4076
 
4077
Examples:
4078
 
4079
   $1f sgr  ( set foreground color to red )
4080
   $2a sgr  ( set background color to green )
4081
; ==== sign  ( n -- : hold '-' if n negative ) =================
4082
'sign' is a word used in conjunction with the pictured numeric
4083
output routines ('<#', '#s' and '#>'), it holds a '-' is the
4084
signed number it is given is negative.
4085
 
4086
 
4087
 
4088
 
4089
 
4090
 
4091
 
4092
 
4093
 
4094
 
4095
 
4096
 
4097
; ==== source  ( -- a u : get source string ) ==================
4098
'source' retrieves the address and length of the current
4099
Terminal Input Buffer (TIB). This contains the current line
4100
that is being processed, this is the line that is retrieved
4101
by the word 'query'.
4102
 
4103
 
4104
 
4105
 
4106
 
4107
 
4108
 
4109
Usage:
4110
 
4111
  source type ( a simple quine )
4112
 
4113
; ==== source-id  ( -- 0 | -1 : identify input source ) ========
4114
'source-id' is used to identify the input source, whether
4115
the interpreter is reading input from the user (0) or evaluating
4116
text within a string (-1)
4117
 
4118
Example usage:
4119
 
4120
  : test $" source-id . cr " count evaluate ;
4121
  test        ( prints FFFF or -1 )
4122
  source-id . ( prints '0')
4123
 
4124
When a block is evaluated with 'load' -1 is returned by
4125
'source-id' as it is evaluating the block as a string.
4126
 
4127
 
4128
 
4129
; ==== sp@  ( -- u : variable stack depth ) ====================
4130
'sp@' is an assembly instruction which returns the current
4131
depth of the variable stack.
4132
 
4133
 
4134
 
4135
 
4136
 
4137
 
4138
 
4139
 
4140
 
4141
 
4142
 
4143
 
4144
 
4145
; ==== space  ( -- : emit space character ) ====================
4146
'space' emits a single space character to the current output
4147
device. That is all.
4148
 
4149
 
4150
 
4151
 
4152
 
4153
 
4154
 
4155
 
4156
 
4157
 
4158
 
4159
 
4160
 
4161
; ==== spaces  ( n -- : emit 'n' spaces ) ======================
4162
'spaces' emits 'n' number of spaces, if 'n' is greater than
4163
zero. This is a useful word for formatting.
4164
 
4165
 
4166
 
4167
 
4168
Usage:
4169
 
4170
 
4171
  1 spaces  ok
4172
  2 spaces   ok
4173
 -1 spaces ok
4174
 
4175
 
4176
 
4177
; ==== span  ( -- a : character count from expect, variable ) ==
4178
'span' is a variable which contains the latest character count
4179
from 'expect'. Consult 'expect' for more information.
4180
 
4181
 
4182
 
4183
 
4184
 
4185
 
4186
Usage:
4187
 
4188
   4000 20 expect
4189
   span @
4190
 
4191
 
4192
 
4193
; ==== state  ( -- a : state variable ) ========================
4194
'state' is a variable that contains the global state of the
4195
Forth interpreter loop, which can be in either compile or
4196
command mode. 'state' contains -1 for command mode, 0 for
4197
compile mode. It can be set directly to change the interpreter
4198
state, or read to make words change their behavior based on
4199
the state (which is generally not the best thing to do). The
4200
words '[' and ']' can be used to switch the state as well.
4201
 
4202
Usage:
4203
 
4204
  : ] -1 state ! ;
4205
  : [  0 state ! ; immediate
4206
  : example [ 2 2 + ] literal ;
4207
  example . ( prints '4' )
4208
 
4209
; ==== =string  ( b1 u1 b2 u2 -- f : string equality ) =========
4210
This word implement a test for string equality, it compares
4211
two strings specified by two address-length pairs and returns
4212
a boolean that determined whether the strings are equal or
4213
not (-1 for true/equal, 0 for false/not-equal). The word is
4214
unusual as it accepts four parameters on the stack, which is
4215
bad practice for Forth words which is most circumstances should
4216
only accept three parameters. This word is used internally for
4217
doing the dictionary search.
4218
 
4219
Usage:
4220
  : s1 $" Hello " count ;
4221
  : s2 $" Bye! " count ;
4222
  s1 s2 =string . ( prints '0' )
4223
  s1 s1 =string . ( prints '-1', or 'FFFF' )
4224
 
4225
; ==== /string  ( b u1 u2 -- b u : advance string by u2 ) ======
4226
'/string' advances a string 'b u1' by 'u2' characters, if there
4227
are enough characters left to advance the string by. This is
4228
obviously a word that is useful when dealing with strings,
4229
strings in Forth commonly come in two type: counted strings
4230
and address-length based strings. This word deals with the
4231
latter type of string.
4232
 
4233
 
4234
 
4235
 
4236
 
4237
 
4238
 
4239
 
4240
 
4241
; ==== swap  ( u1 u2 -- u2 u1 : swap two variables ) ===========
4242
It swaps two variables on the stack, its stack effect describes
4243
the word perfectly. This is a simple word that will be used
4244
quite a lot, memorize it quickly!
4245
 
4246
 
4247
 
4248
 
4249
 
4250
 
4251
Usage:
4252
   1 2   (     -- 1 2 )
4253
   swap  ( 1 2 -- 2 1 )
4254
 
4255
 
4256
 
4257
; ==== switches  ( -- u : get state of switches ) ==============
4258
'switches' retrieves the state of the two state switches on
4259
the board, the values are already debounced. There are eight
4260
switches which each have a single LED next to them (which can
4261
be controlled with 'led!'). The lowest eight bits are used
4262
for the switch states, 1 for on, 0 for off.
4263
 
4264
Example usage:
4265
   : select 1 swap lshift switches swap and 0= 0= ;
4266
   : sw0 0 select ; : sw1 1 select ; : sw2 2 select ;
4267
   : sw3 3 select ; : sw4 4 select ; : sw5 5 select ;
4268
   : sw6 6 select ; : sw7 7 select ;
4269
   : switches->leds switches led! ;
4270
 
4271
 
4272
 
4273
; ==== then  ( -- : part of if...then or if...else...then ) ====
4274
'then' should only be used inside a word definition and as
4275
part of an 'if...else...then' or 'if...then' sequence, it is
4276
used to terminate both sequences with execution continuing
4277
after 'then'. The words 'if' and 'else' should also be
4278
consulted. An exception may be thrown if this word is used
4279
outside a word definition, or if there is not a corresponding
4280
if. It is an immediate word.
4281
 
4282
Usage:
4283
   : invalid then ; ( <- invalid usage, no matching 'if' )
4284
   then      ( <- invalid usage, outside word definition )
4285
   : example dup if 1+ then ; ( 0 | x -- 0 | x+1 )
4286
   4 example . ( prints '5' )
4287
 
4288
 
4289
; ==== throw  ( ? n -- ?, R: ? -- ? : throw exception ) ========
4290
'throw' along with 'catch' are the Forth exception handling
4291
routines, 'throw' throws an exception if the number provided to
4292
it is non-zero. An exception unwinds the return stack until
4293
a 'catch' is encountered, the word 'quit' contains the exception
4294
handler of last resort. Numbers from -255 to 0 are reserved for
4295
standard Forth errors.
4296
 
4297
 
4298
Usage:
4299
 
4300
   : fail $1000 throw ;
4301
   : partially-executed cr ." Hello " fail ." World!" cr ;
4302
   : catches-throw ' partially-executed catch u. ;
4303
   catches-throw ( prints only 'Hello' then '1000' )
4304
 
4305
; ==== thru  ( k1 k2 -- : load from k1 to k2 ) =================
4306
'thru' calls 'load' on a range of blocks from 'k1' to 'k2'
4307
inclusively. It is used to evaluate a range of blocks and as
4308
a convenient way to load software off of mass storage.
4309
Code and data is stored in Forth blocks, 'thru' is used to load
4310
that data. The word 'index' can be used to give an overview
4311
of blocks, as the convention is to have the first line of the
4312
block as a description.
4313
 
4314
 
4315
 
4316
 
4317
Usage:
4318
 
4319
   8 9 thru ( evaluate blocks 8 and 9 )
4320
 
4321
; ==== timer  ( -- u : get value of timer ) ====================
4322
'timer' retrieves the current value of the hardware time in the
4323
FPGA, this peripheral can be controlled with the 'timer!' word,
4324
which is used to control the timer.
4325
 
4326
 
4327
 
4328
 
4329
 
4330
 
4331
 
4332
 
4333
 
4334
 
4335
 
4336
 
4337
; ==== timer!  ( -- : set timer ) ==============================
4338
'timer!' sets the hardware timer control register, allowing the
4339
timer to be enabled/stopped/reset and setting up the value at
4340
which the timer wraps around at (or triggers an interrupt). The
4341
layout of the timer control register is as follows:
4342
 
4343
  BIT  - MEANING
4344
  15   - Enable Timer (1 = enabled)
4345
  14   - Reset Timer
4346
  13   - Enable Interrupts
4347
  12-0 - Timer Compare Value
4348
 
4349
The word 'timer' can be used to read in the current value of
4350
the timer.
4351
 
4352
 
4353
; ==== tuck  ( n1 n2 -- n2 n1 n2 : tuck value ) ================
4354
'tuck' is a simple word that manipulates the stack, its stack
4355
comment describes what it does. It tucks a variable behind
4356
the second most item on the stack.
4357
 
4358
 
4359
 
4360
 
4361
 
4362
 
4363
Usage:
4364
   5 7  ( -- 5 7 : two example numbers are entered )
4365
   tuck ( 5 7 -- 7 5 7 : tuck does its job )
4366
 
4367
 
4368
 
4369
; ==== type  ( b u -- : print out a string ) ===================
4370
'type' prints out a string, specified by an address 'b' and
4371
a length 'u'. The output goes to the same place as 'emit'
4372
does, which is usually an output device viewable by the
4373
programmer.
4374
 
4375
The examples use the words '$"' and 'count' which should be
4376
consulted as well. '$"' compiles a string literal into the
4377
dictionary as a counted string, 'count' converts this to
4378
an Address-Length pair needed by type.
4379
 
4380
Usage:
4381
   : hello cr $" Hello, World!" count type cr ;
4382
   hello          ( execute newly defined word )
4383
   Hello, World!  ( it prints 'Hello, World! )
4384
 
4385
; ==== u<  ( u1 u2 -- f: unsigned less than ) ==================
4386
Unsigned less than of two numbers.
4387
 
4388
 
4389
 
4390
 
4391
 
4392
 
4393
 
4394
 
4395
 
4396
 
4397
 
4398
 
4399
 
4400
 
4401
; ==== u>  ( u1 u2 -- f: unsigned greater than ) ===============
4402
Unsigned greater than, this is not an assembly instruction.
4403
 
4404
 
4405
 
4406
 
4407
 
4408
 
4409
 
4410
 
4411
 
4412
 
4413
 
4414
 
4415
 
4416
 
4417
; ==== u>=  ( u1 u2 -- f: unsigned greater or equal to ) =======
4418
Is 'u1' greater than or equal to 'u2', this is an unsigned
4419
operation.
4420
 
4421
 
4422
 
4423
 
4424
 
4425
 
4426
 
4427
 
4428
 
4429
 
4430
 
4431
 
4432
 
4433
; ==== u.  ( u -- : print out number in current base ) =========
4434
'u.' prints out an unsigned number in the current output base,
4435
this number uses the area at the end of the dictionary and
4436
the beginning of the PAD area as temporary storage.
4437
 
4438
 
4439
 
4440
 
4441
 
4442
 
4443
 
4444
 
4445
 
4446
 
4447
 
4448
 
4449
; ==== um*  ( u u -- ud : unsigned multiply ) ==================
4450
Unsigned multiply, it takes two single cell numbers and returns
4451
an unsigned double cell number.
4452
 
4453
 
4454
 
4455
 
4456
 
4457
 
4458
 
4459
 
4460
 
4461
 
4462
 
4463
 
4464
 
4465
; ==== um+  ( u u -- u carry : unsigned add with carry ) =======
4466
Unsigned addition with carry, this word is used to implement
4467
the some of the arithmetic operations, although it is not
4468
very useful directly. 'um+' is used directly to implement 'um*'
4469
which in turn is used to implement '*'.
4470
 
4471
 
4472
 
4473
 
4474
 
4475
 
4476
 
4477
 
4478
 
4479
 
4480
 
4481
; ==== um/mod  ( ud u -- ur uq : unsigned modulo divide ) ======
4482
Unsigned division of an unsigned double cell number by a single
4483
cell number and leaves the remainder, 'ur' and the quotient,
4484
'uq'. This is a slow operation as it is not implemented as an
4485
instruction within the H2 CPU. It will throw and exception if
4486
the divisor is zero. The word is used to implement the other
4487
division and modulus operations.
4488
 
4489
 
4490
 
4491
 
4492
 
4493
 
4494
 
4495
 
4496
 
4497
; ==== until  ( -- : begin...until loop ) ======================
4498
'until' is a compile only word that should be used as part of
4499
a 'begin...until' loop within a word definition. It is a
4500
conditional looping mechanism that pops and tests a value at
4501
run time, and jumps back to the corresponding 'begin' if the
4502
value is zero, otherwise execution continues after the 'until'.
4503
 
4504
Usage:
4505
  : invalid until ; ( <- invalid usage, no matching 'begin' )
4506
  until  ( <- invalid usage, used outside a word definition )
4507
  : test begin 1- dup . ?dup 0= until cr ." done " cr ;
4508
  3 test 2 1 0 ( '3 test' prints '2 1 0' )
4509
  done         ( and also prints 'done' )
4510
 
4511
 
4512
 
4513
; ==== update  ( -- : mark last loaded block as dirty ) ========
4514
Marks the last loaded block as being dirty (the last loaded
4515
block block number is stored in the variable 'blk'). A dirty
4516
block will be written to disk on when 'flush', 'save-buffers',
4517
or another block is loaded from disk.
4518
 
4519
Usage:
4520
   5 block      ( block '5' loaded, block address returned )
4521
   swap 99 !    ( store '99' in block buffer )
4522
   update       ( mark block as dirty )
4523
   save-buffers ( write out block buffer back to block '5' )
4524
   ( block '5' now contains '99' in its first byte, which has )
4525
   ( been saved to disk )
4526
 
4527
 
4528
 
4529
; ==== u.r  ( u +n -- : print u right justified by +n ) ========
4530
'u.r' is a general purpose numeric formatting word, it prints
4531
out the number 'u' as an unsigned number in the current output
4532
radix, preceded by '+n' spaces, minus the number of spaces
4533
needed to display 'u' in the current output radix, or right
4534
aligned. This function uses the area between the end of the
4535
dictionary and the beginning of the PAD area as temporary
4536
storage.
4537
 
4538
Usage:
4539
 
4540
  Typed   | <- Result -> |
4541
  4 6 u.r     4 ok
4542
  99 6 u.r    99 ok
4543
  99 5 u.r   99 ok
4544
 
4545
; ==== variable  ( -- ;  : create a new variable ) =====
4546
'variable' parses the next space delimited string from the
4547
input string and makes a new named variable. The variable will
4548
be initialized with zero, although this is not guaranteed to be
4549
the case with all Forths. Variables are just normal words that
4550
push a location onto the dictionary of where the variable is
4551
stored, it can be accessed with the '!' and '@' words, only
4552
one cell of storage space is reserved. The created word is
4553
not an immediate word.
4554
 
4555
 
4556
 
4557
 
4558
 
4559
 
4560
 
4561
; ==== ver  ( -- u : push version information ) ================
4562
Pushes the version number of the eForth implementation. The
4563
format of the version is the major version is stored in the
4564
upper byte and the minor version information is stored in the
4565
lower byte.
4566
 
4567
The minor version number changes on minor updates, the major
4568
version changes when there are major updates in how the
4569
interpreter works that could potentially break code.
4570
 
4571
 
4572
 
4573
 
4574
 
4575
 
4576
 
4577
; ==== while  ( -- : begin...while...repeat loop ) =============
4578
 
4579
 
4580
 
4581
 
4582
 
4583
 
4584
 
4585
 
4586
 
4587
 
4588
 
4589
 
4590
 
4591
 
4592
 
4593
; ==== within  ( u hi lo -- f : is u within a range? ) =========
4594
'within' is used to test with a value is within a range
4595
specified with a maximum and minimum value.
4596
 
4597
 
4598
 
4599
 
4600
 
4601
 
4602
 
4603
 
4604
 
4605
 
4606
 
4607
 
4608
 
4609
; ==== word  ( c -- a;  : parse a word ) ===============
4610
'word' parses the next word in the input stream and returns an
4611
address to a counted string. 'counted strings' have their first
4612
byte as their string length, which can be extracted with the
4613
word 'count'. The delimiter is given as 'c', a special case
4614
exists when 'c' is a space, as all characters up to the ASCII
4615
space are treated as delimiters.
4616
 
4617
 
4618
 
4619
 
4620
 
4621
 
4622
 
4623
 
4624
 
4625
; ==== words  ( -- : list all words in dictionary ) ============
4626
This lists all of the words in the dictionary that are on the
4627
current search order. Each vocabulary is listed with the address
4628
of that vocabulary as a prefix.
4629
 
4630
 
4631
 
4632
 
4633
 
4634
 
4635
 
4636
 
4637
 
4638
 
4639
 
4640
 
4641
; ==== xor  ( u1 u2 -- u : bit wise exclusive or ) =============
4642
Bitwise exclusive or of two numbers, there is nothing more
4643
to this function than that.
4644
 
4645
 
4646
 
4647
 
4648
 
4649
 
4650
 
4651
 
4652
 
4653
 
4654
 
4655
 
4656
 
4657
; ==============================================================
4658
 
4659
 
4660
 
4661
 
4662
 
4663
 
4664
 
4665
 
4666
 
4667
 
4668
 
4669
 
4670
 
4671
 
4672
 
4673
; ==== ASCII Character Table ===================================
4674
The following section presents a database of all of the ASCII
4675
characters, from 0 through to 127 inclusive. The format of the
4676
database is; decimal, octal, hex then binary value, character
4677
(or name) and finally a column with a short description.
4678
Columns are separated by spaces. There is one entry per line,
4679
with the first line of each block containing an index entry
4680
instead of an ASCII character description.
4681
 
4682
 
4683
 
4684
 
4685
 
4686
 
4687
 
4688
 
4689
; ==== ASCII: NUL (0) to SO (14) ===============================
4690
 
4691
  1 001 01 00000001 SOH    Start of Heading
4692
  2 002 02 00000010 STX    Start of Text
4693
  3 003 03 00000011 ETX    End of Text
4694
  4 004 04 00000100 EOT    End of Transmission
4695
  5 005 05 00000101 ENQ    Enquiry
4696
  6 006 06 00000110 ACK    Acknowledgment
4697
  7 007 07 00000111 BEL    Bell
4698
  8 010 08 00001000 BS     Back Space
4699
  9 011 09 00001001 HT     Horizontal Tab
4700
 10 012 0A 00001010 LF     Line Feed
4701
 11 013 0B 00001011 VT     Vertical Tab
4702
 12 014 0C 00001100 FF     Form Feed
4703
 13 015 0D 00001101 CR     Carriage Return
4704
 14 016 0E 00001110 SO     Shift Out / X-On
4705
; ==== ASCII: SI (15) to GS (29) ===============================
4706
 15 017 0F 00001111 SI     Shift In / X-Off
4707
 16 020 10 00010000 DLE    Data Line Escape
4708
 17 021 11 00010001 DC1    Device Control 1 (oft. XON)
4709
 18 022 12 00010010 DC2    Device Control 2
4710
 19 023 13 00010011 DC3    Device Control 3 (oft. XOFF)
4711
 20 024 14 00010100 DC4    Device Control 4
4712
 21 025 15 00010101 NAK    Negative Acknowledgement
4713
 22 026 16 00010110 SYN    Synchronous Idle
4714
 23 027 17 00010111 ETB    End of Transmit Block
4715
 24 030 18 00011000 CAN    Cancel
4716
 25 031 19 00011001 EM     End of Medium
4717
 26 032 1A 00011010 SUB    Substitute
4718
 27 033 1B 00011011 ESC    Escape
4719
 28 034 1C 00011100 FS     File Separator
4720
 29 035 1D 00011101 GS     Group Separator
4721
; ==== ASCII: RS (30) to Comma (44) ============================
4722
 30 036 1E 00011110 RS     Record Separator
4723
 31 037 1F 00011111 US     Unit Separator
4724
 32 040 20 00100000 SPACE  Space
4725
 33 041 21 00100001 !      Exclamation mark
4726
 34 042 22 00100010 "      Double quotes (or speech marks)
4727
 35 043 23 00100011 #      Number
4728
 36 044 24 00100100 $      Dollar
4729
 37 045 25 00100101 %      Procenttecken
4730
 38 046 26 00100110 &      Ampersand
4731
 39 047 27 00100111 '      Single quote
4732
 40 050 28 00101000 (      Open parenthesis (or open bracket)
4733
 41 051 29 00101001 )      Close parenthesis (or close bracket)
4734
 42 052 2A 00101010 *      Asterisk
4735
 43 053 2B 00101011 +      Plus
4736
 44 054 2C 00101100 ,      Comma
4737
; ==== ASCII: Hyphen (45) to Semicolon (59) ====================
4738
 45 055 2D 00101101 -      Hyphen
4739
 46 056 2E 00101110 .      Period, dot or full stop
4740
 47 057 2F 00101111 /      Slash or divide
4741
 48 060 30 00110000 0      Zero
4742
 49 061 31 00110001 1      One
4743
 50 062 32 00110010 2      Two
4744
 51 063 33 00110011 3      Three
4745
 52 064 34 00110100 4      Four
4746
 53 065 35 00110101 5      Five
4747
 54 066 36 00110110 6      Six
4748
 55 067 37 00110111 7      Seven
4749
 56 070 38 00111000 8      Eight
4750
 57 071 39 00111001 9      Nine
4751
 58 072 3A 00111010 :      Colon
4752
 59 073 3B 00111011 ;      Semicolon
4753
; ==== ASCII: Less than (60) to Uppercase J (74) ===============
4754
 60 074 3C 00111100 <      Less than
4755
 61 075 3D 00111101 =      Equals
4756
 62 076 3E 00111110 >      Greater than
4757
 63 077 3F 00111111 ?      Question mark
4758
 64 100 40 01000000 @      At symbol
4759
 65 101 41 01000001 A      Uppercase A
4760
 66 102 42 01000010 B      Uppercase B
4761
 67 103 43 01000011 C      Uppercase C
4762
 68 104 44 01000100 D      Uppercase D
4763
 69 105 45 01000101 E      Uppercase E
4764
 70 106 46 01000110 F      Uppercase F
4765
 71 107 47 01000111 G      Uppercase G
4766
 72 110 48 01001000 H      Uppercase H
4767
 73 111 49 01001001 I      Uppercase I
4768
 74 112 4A 01001010 J      Uppercase J
4769
; ==== ASCII: Uppercase K (75) to Uppercase Y (89) =============
4770
 75 113 4B 01001011 K      Uppercase K
4771
 76 114 4C 01001100 L      Uppercase L
4772
 77 115 4D 01001101 M      Uppercase M
4773
 78 116 4E 01001110 N      Uppercase N
4774
 79 117 4F 01001111 O      Uppercase O
4775
 80 120 50 01010000 P      Uppercase P
4776
 81 121 51 01010001 Q      Uppercase Q
4777
 82 122 52 01010010 R      Uppercase R
4778
 83 123 53 01010011 S      Uppercase S
4779
 84 124 54 01010100 T      Uppercase T
4780
 85 125 55 01010101 U      Uppercase U
4781
 86 126 56 01010110 V      Uppercase V
4782
 87 127 57 01010111 W      Uppercase W
4783
 88 130 58 01011000 X      Uppercase X
4784
 89 131 59 01011001 Y      Uppercase Y
4785
; ==== ASCII: Uppercase Z (90) to Lowercase h (104) ============
4786
 90 132 5A 01011010 Z      Uppercase Z
4787
 91 133 5B 01011011 [      Opening bracket
4788
 92 134 5C 01011100 \      Backslash
4789
 93 135 5D 01011101 ]      Closing bracket
4790
 94 136 5E 01011110 ^      Caret - circumflex
4791
 95 137 5F 01011111 _      Underscore
4792
 96 140 60 01100000 `      Grave accent
4793
 97 141 61 01100001 a      Lowercase a
4794
 98 142 62 01100010 b      Lowercase b
4795
 99 143 63 01100011 c      Lowercase c
4796
100 144 64 01100100 d      Lowercase d
4797
101 145 65 01100101 e      Lowercase e
4798
102 146 66 01100110 f      Lowercase f
4799
103 147 67 01100111 g      Lowercase g
4800
104 150 68 01101000 h      Lowercase h
4801
; ==== ASCII: Lowercase i (105) to Lowercase w (119) ===========
4802
105 151 69 01101001 i      Lowercase i
4803
106 152 6A 01101010 j      Lowercase j
4804
107 153 6B 01101011 k      Lowercase k
4805
108 154 6C 01101100 l      Lowercase l
4806
109 155 6D 01101101 m      Lowercase m
4807
110 156 6E 01101110 n      Lowercase n
4808
111 157 6F 01101111 o      Lowercase o
4809
112 160 70 01110000 p      Lowercase p
4810
113 161 71 01110001 q      Lowercase q
4811
114 162 72 01110010 r      Lowercase r
4812
115 163 73 01110011 s      Lowercase s
4813
116 164 74 01110100 t      Lowercase t
4814
117 165 75 01110101 u      Lowercase u
4815
118 166 76 01110110 v      Lowercase v
4816
119 167 77 01110111 w      Lowercase w
4817
; ==== ASCII: Lowercase x (120) to DEL (127) ===================
4818
120 170 78 01111000 x      Lowercase x
4819
121 171 79 01111001 y      Lowercase y
4820
122 172 7A 01111010 z      Lowercase z
4821
123 173 7B 01111011 {      Opening brace
4822
124 174 7C 01111100 |      Vertical bar
4823
125 175 7D 01111101 }      Closing brace
4824
126 176 7E 01111110 ~      Equivalency sign - tilde
4825
127 177 7F 01111111 DEL    Delete
4826
 
4827
 
4828
 
4829
 
4830
 
4831
 
4832
 
4833
; ==============================================================
4834
 
4835
 
4836
 
4837
 
4838
 
4839
 
4840
 
4841
 
4842
 
4843
 
4844
 
4845
 
4846
 
4847
 
4848
 

powered by: WebSVN 2.1.0

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