-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathforth.help.html
More file actions
1781 lines (1143 loc) · 40 KB
/
forth.help.html
File metadata and controls
1781 lines (1143 loc) · 40 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<title>ESP32Forth</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h2></h2>
<h2>Block File system</h2>
<h2>block</h2>
( n -- a ) Get a 1024 character block
<h2>block-fid</h2>
( – n ) "value
<h2>block-id</h2>
( -- n ) "value
<h2>buffer</h2>
( n -- a ) Get a 1024 byte block without regard to old contents
<h2>copy</h2>
( from to -- ) Copy contents of block 'from' to block 'to'
<h2>default-use</h2>
"deferred word
<h2>empty-buffers</h2>
( -- ) Empty all buffers
<h2>flush</h2>
( -- ) Save and empty all buffers
<h2>list</h2>
( n -- ) List block n of 1024 characters to the display
<h2>load</h2>
( n -- ) Evaluate block n of 1024 characters as the input stream
<h2>open-blocks</h2>
( a n -- ) Open a file as the block file
<h2>save-buffers</h2>
( -- ) Save all buffers
<h2>scr</h2>
( -- adr ) Pointer to last listed block
<h2>thru</h2>
( a b -- ) Load blocks a thru b
<h2>update</h2>
( -- ) Mark the last block modified
<h2>use</h2>
"( ""name"" -- )" "Use ""name"" as the blockfile
<h2>Block File Editor</h2>
<h2>a</h2>
"( n ""text"" -- )" "Add (insert) a line in the current block with the words that follow in the input stream
<h2>d</h2>
( n -- ) Delete a line in the current block
<h2>e</h2>
( n -- ) Clear a line in the current block
<h2>l</h2>
( – ) List the current 1024 character block
<h2>n</h2>
( – ) Move to the next 1024 character block
<h2>p</h2>
( – ) Move to the previous 1024 character block
<h2>r</h2>
"( n ""text"" -- )" "Replace a line in the current block with the words that follow in the input stream
<h2>wipe</h2>
( -- ) Erase the 1024 character block
<h2>editor</h2>
( -- ) vocabulary name of the block file editor
<h2>Branching</h2>
<h2>[ELSE]</h2>
( – ) Interpret time ELSE
<h2>[IF]</h2>
( f – ) "Interpret time IF ( conditional interpretation of words that follow
<h2>[THEN]</h2>
(–) Interpret time THEN
<h1>forth</h1>
<h1>forth</h1>
<h2>DEFINED?</h2>
"( ""name"" -- xt | 0 )" "If the name that follows in the input stream is found in the dictionary
<h1>forth</h1>
<h1>forth</h1>
<h2>if</h2>
( flag – ) "Conditional structure
<h1>forth</h1>
<h1>forth</h1>
<h2>Character I/O</h2>
<h2>"."""</h2>
( “string” – ) display the string that follows in the input stream until a terminating “
<h2>accept</h2>
( b u1 -- b u2 ) accepts u1 characters to b. u2 returned is the actual count of characters received
<h2>char</h2>
"( ""character"" -- c )" Convert the non-space char that follows in the input stream and place it's value tos e.g. char 0 places 48 on top of the stack
<h2>cr</h2>
( -- ) "send carriage return
<h2>emit</h2>
( c – ) display the ascii character c
<h2>key</h2>
( – chr ) deferred word - reads the next character in the input stream - defaults to word serial-key
<h2>key?</h2>
( -- cnt ) "deferred word - returns cnt
<h2>ok</h2>
( -- ) display the string ok
<h2>page</h2>
( -- ) Emit 30 CR characters to the display
<h2>PARSE</h2>
"( c ""wordtoparse"" -- addr cnt )" "Parse the next word in the input stream
<h2>prompt</h2>
send ok and <cr> to the display
<h2>space</h2>
( -- ) Emit a space character to the display
<h2>tib</h2>
( -- addr ) returns the address of the the terminal input buffer where input text string is held
<h2>type</h2>
( addr n -- ) "deferred word - display an n long character string
<h2>ip.</h2>
( n -- ) print n in IP address format e.g. 192.168.1.2
<h2>ip#</h2>
( n1 -- n2 ) print one section of an ip address
<h2>Comment</h2>
<h2>(</h2>
"( ""string""-- )" "Start of a 1 line comment
<h2>\</h2>
"Start of a 1 line comment
<h2>Comparison</h2>
<h2><</h2>
( n1 n2 -- f ) "f=true of n1 less than n2
<h2><=</h2>
( n1 n2 -- f ) "f=true if n1 less than or equal n2
<h2><></h2>
( n1 n2 -- f ) "f=true if n1 not equal n2
<h2>=</h2>
( n1 n2 -- f ) "f=true if n1 equals n2
<h2>></h2>
( n1 n2 -- f ) "f=true if n1 greater than n2
<h2>>=</h2>
( n1 n2 -- f ) "f=true if n1 greater than or equal n2
<h2>0<</h2>
( n -- f ) "f=true if n less than zero
<h2>0<></h2>
( n -- f ) "f=true if n not equal zero
<h2>0=</h2>
( n -- f ) "f=true if n equals zero
<h2>Debug</h2>
<h2>.s</h2>
( – ) display the data stack depth and data stack on one line of the display
<h2>dump</h2>
( addr n – ) "display memory starting at addr
<h2>dump-file</h2>
( a n a n -- )
<h2>order</h2>
( – ) Print the vocabulary search order
<h2>see</h2>
"( ""text"" -- )" Attempt to decompile the word which follows in the input stream
<h2>vlist</h2>
( -- ) List the words in the context vocabulary (not chains) e.g. vlist WiFi only lists words in the Wifi vocabulary
<h2>words</h2>
( -- ) List the words in the context vocabulary (including chains)
<h2>Dictionary</h2>
<h2>>body</h2>
( xt -- addr ) addr is the data-field address corresponding to execution token xt
<h2>>link</h2>
( xt -- addr ) addr is the link-field address corresponding to execution token xt
<h2>>link&</h2>
( xt -- addr ) used internally by >link
<h2>>name</h2>
( xt -- addr n | 0 ) "convert execution token xt to a name located at addr with n characters
<h2>FIND</h2>
( addr n -- xt | 0 ) "using the counted string at addr with n characters
<h2>forget</h2>
"( ""name"" -- )" "find the word that follows in the input stream; if it exists in the current dictionary
<h2>here</h2>
( -- addr ) "returns the address of the first free location above the code dictionary
<h2>only</h2>
( -- ) "Reset context stack to one item
<h2>transfer</h2>
"( ""name"" -- )" "Move a word from its current dictionary to the current vocabulary. Useful for ""hiding"" helper words that aren't useful in normal programming"
<h2>transfer{</h2>
( -- ) Move all the words that follow in the input stream up until a terminating } to the current vocabulary. All the words must have been defined beforehand
<h2>Exceptions</h2>
<h2>assert</h2>
( f -- ) "if flag f=true
<h2>catch</h2>
( ca -- err# | 0 ) sets up a local error frame on the return stack and executes the word referenced by the execution word ca. It returns a non-zero error code or a zero if no error occurred
<h2>handler</h2>
( -- addr ) holds the return stack pointer for error handling - zero if no error occurred.
<h2>throw</h2>
( err# -- err# ) throws the system back to 'catch' so that the error condition can be processed. 'Catch' is backtracked by restoring the return stack from the pointer stored in 'handler' and popping the old handler and SP off the error frame on the return stack.
<h2>Files</h2>
<h2>BIN</h2>
( fam1 -- fam2 ) "Modify the implementation-defined file access method fam1 to additionally select a ""binary""
<h2>CLOSE-FILE</h2>
( fh -- ior ) ior= Input Output Result Close the file identified by fileid. ior is the implementation-defined I/O result code.
<h2>CREATE-FILE</h2>
( a n mode -- fh ior ) ( c-addr u fam -- fileid ior ) "Create the file named in the character string specified by c-addr and u
<h2>DELETE-FILE</h2>
( a n -- ior ) ( c-addr u -- ior ) Delete the file named in the character string specified by c-addr u. ior is the implementation-defined I/O result code.
<h2>FILE-POSITION</h2>
( fh -- n ior ) ( fileid -- ud ior ) ud is the current file position for the file identified by fileid. ior is the implementation-defined I/O result code. ud is undefined if ior is non-zero.
<h2>FILE-SIZE</h2>
( fh -- n ior ) ( fileid -- ud ior ) "ud is the size
<h2>FLUSH-FILE</h2>
( fileid -- ior ) "Attempt to force any buffered information written to the file referred to by fileid to be written to mass storage
<h2>include</h2>
"( ""name"" -- )" "Using the next word in the input stream
<h2>INCLUDED</h2>
"( a n -- ) ( i * x c-addr u -- j * x ) Typical use: ... S"" filename"" INCLUDED ... " "Remove c-addr u from the stack. Save the current input source specification
<h2>R/O</h2>
( -- mode ) read only mode - used with OPEN-FILE
<h2>R/W</h2>
( -- mode ) read write mode - used with OPEN-FILE
<h1> ior is zero and u2 is equal to u1.</h1>
<h1> ior is zero and u2 is the number of characters actually read.</h1>
<h1> ior is zero and u2 is zero.</h1>
<h2>remember</h2>
( -- ) Save a snapshot to the default file (./myforth or /spiffs/myforth on ESP32)
<h2>reset</h2>
( -- ) Reset removes the custom message
<h2>RESET </h2>
( -- ) Delete the default filename.
<h1> the portion of the file added as a result of the operation might not have been written.</h1>
<h2>restore</h2>
"( ""name"" -- )" Restore a snapshot from a file
<h2>revive</h2>
( -- ) Restore the default filename
<h2>save</h2>
"( ""name"" -- )" Saves a snapshot of the current dictionary to a file
<h2>startup:</h2>
"( ""name"" -- )" "Save a snapshot to the default file arranging for ""name"" to be run on startup SEE EXAMPLE B743"
<h2>W/O</h2>
( -- mode ) write only mode - used with OPEN-FILE
<h2>Input / Output</h2>
<h2>adc</h2>
( pin# -- n ) alias for analogRead - see example below
<h2>analogRead</h2>
( pin -- n ) Analog read from 0-4095
<h2>dacWrite</h2>
( pin 0-255 -- ) "Write to DAC (pin 25
<h2>digitalRead</h2>
( pin -- value ) Read GPIO state - see example below
<h2>digitalWrite</h2>
( pin value -- ) Set GPIO pin state
<h1>forth</h1>
<h1>forth</h1>
<h2>pulseIn</h2>
( pin value usec -- usec/0 ) Wait for a pulse
<h2>tone</h2>
( channel freq ) Write tone frequency
<h2>Interrupts</h2>
<h2>timer_isr_register</h2>
( group timer xt arg ret -- 0/err )
<h2>esp_intr_alloc</h2>
( source flags xt args handle* -- 0/err )
<h2>ESP_INTR_FLAG_DEFAULT</h2>
( -- 0 ) Default handler allows per pin routing
<h2>ESP_INTR_FLAG_EDGE</h2>
( -- 512 ) gpio_install_isr_service flag
<h2>ESP_INTR_FLAG_INTRDISABLED</h2>
( -- 2048 ) gpio_install_isr_service flag
<h2>ESP_INTR_FLAG_IRAM</h2>
( -- 1024 ) gpio_install_isr_service flag
<h2>ESP_INTR_FLAG_LEVELn</h2>
( n1 -- n2 ) "n2 = 2 to the power n1
<h2>ESP_INTR_FLAG_NMI</h2>
( -- 128 ) gpio_install_isr_service flag
<h2>ESP_INTR_FLAG_SHARED</h2>
( -- 256 ) gpio_install_isr_service flag
<h2>esp_intr_alloc</h2>
<h2>esp_intr_free</h2>
( handle -- 0/err )
<h2>gpio_config</h2>
( gpio_config_t* -- 0/err ) "GPIO common configuration. Configure GPIO’s Mode
<h2>gpio_deep_sleep_hold_dis</h2>
( -- ) Disable all digital gpio pad hold function during Deep-sleep
<h2>gpio_deep_sleep_hold_en</h2>
( -- ) "Enable all digital gpio pad hold function during Deep-sleep. When the chip is in Deep-sleep mode
<h2>gpio_get_drive_capability</h2>
( pin cap* -- 0/err )
<h2>gpio_get_level</h2>
( pin -- level ) GPIO get input level of 'pin'
<h2>gpio_hold_dis</h2>
( pin -- 0/err )
<h2>gpio_hold_en</h2>
( pin -- 0/err )
<h2>gpio_install_isr_service</h2>
( a -- ) "a = combination of gpio_install_isr_service flags - Install the driver’s GPIO ISR handler service
<h1>interrupts</h1>
<h1>interrupts</h1>
<h2>gpio_intr_disable</h2>
( pin -- 0/err ) Disable GPIO module interrupt signal for 'pin'
<h2>gpio_intr_enable</h2>
( pin -- 0/err ) Enable GPIO module interrupt signal for'pin'
<h2>#GPIO_INTR_HIGH_LEVEL</h2>
( -- 5 ) constant - e.g. 2 #GPIO_INTR_HIGH_LEVEL gpio_set_intr_type
<h2>#GPIO_INTR_LOW_LEVEL</h2>
( -- 4 ) constant - e.g. 2 #GPIO_INTR_LOW_LEVEL gpio_set_intr_type
<h1>interrupts</h1>
<h1>interrupts</h1>
<h2>gpio_isr_handler_add</h2>
pin xt 0 -- 0/err ) "Having already set up the interrupt type
<h1>interrupts</h1>
<h2>gpio_isr_handler_remove</h2>
( pin -- 0/err ) Remove ISR handler for the corresponding GPIO pin
<h2>gpio_pulldown_dis</h2>
( pin -- 0/err ) Disbale pull down load on 'pin'
<h2>gpio_pulldown_en</h2>
( pin -- 0/err ) Enable pull down load on 'pin'
<h2>gpio_pullup_dis</h2>
( pin -- 0/err ) Disable pull up load on 'pin'
<h2>gpio_pullup_en</h2>
( pin -- 0/err ) Enable pull up load on 'pin'
<h2>gpio_reset_pin</h2>
( pin -- 0/err ) "Reset a gpio to default state (select gpio function
<h2>gpio_set_direction</h2>
( pin mode -- 0/err ) Set gpio signal direction of 'pin'
<h2>gpio_set_drive_capability</h2>
( pin cap -- 0/err ) Set GPIO pad 'pin' drive capability or strength 'cap'
<h2>gpio_set_intr_type</h2>
( pin type -- 0/err ) "Set the required i/o pin to the interrupt type
<h2>gpio_set_level</h2>
( pin level -- 0/err ) GPIO set the output level pf 'pin' =1 or 0
<h2>gpio_set_pull_mode</h2>
( pin mode -- 0/err ) Configure GPIO 'pin' pull-up/pull-down resistors by means of 'mode'. GPIO 34-39 don't have this facility
<h2>gpio_uninstall_isr_service</h2>
( -- ) "Uninstall the driver’s GPIO ISR service
<h2>gpio_wakeup_disable</h2>
( pin -- 0/err ) Disable GPIO wake-up function on 'pin'
<h2>gpio_wakeup_enable</h2>
( pin type -- 0/err ) Enable GPIO wake-up function on 'pin' - only type #GPIO_INTR_LOW_LEVEL or #GPIO_INTR_HIGH_LEVEL can be used
<h1>interrupts</h1>
<h2>LED control - pulse width modulation</h2>
<h2>duty</h2>
( channel duty -- ) "like ledcWrite
<h1>forth</h1>
<h2>freq</h2>
( channel freq -- ) "like ledcSetup
<h1>forth</h1>
<h2>ledcAttachPin</h2>
( pin channel -- ) Assigns which 'channel' (0-15) of the PWM engine the 'pin' is connected to
<h2>ledcDetachPin</h2>
( pin -- ) Detaches #pin' from the pwm engine
<h2>ledcRead</h2>
( channel -- n ) Read the current dutycycle setting for 'channel'
<h2>ledcReadFreq</h2>
( channel -- freq ) "Get frequency (x 1
<h2>ledcSetup</h2>
( channel freq resolution -- freq ) Setup one of the 16 pwm channels (0-15) at frequency=freq*1000 Hz with 'resolution'
<h2>ledcWrite</h2>
( channel duty -- ) Set 'channel' (0-15) at 'duty' level (0-100)
<h2>ledcWriteNote</h2>
( channel note octave -- freq ) "channel 0-12
<h1>ledc</h1>
<h1>ledc</h1>
<h2>Logic</h2>
<h2>AND</h2>
( n1 n2 – n3 ) n3 = n1 AND n2 (bit wise)
<h2>invert</h2>
<h2>LSHIFT</h2>
( x1 u -- x2 ) "Perform a logical left shift of u bit-places on x1
<h2>OR</h2>
( n1 n2 – n3 ) n3 = n1 OR n2 ( bit-wise )
<h2>RSHIFT</h2>
( x1 u -- x2 ) "Perform a logical right shift of u bit-places on x1
<h2>XOR</h2>
( n1 n2 -- n3 ) n3 = n1 XOR n2 ( bit-wise)
<h2>Looping</h2>
<h1> then inside ?do .. loop is NOT executed</h1>
<h2>+loop</h2>
( n -- ) e.g. : +looptest 20 0 do i . 2 +loop ; results when run in 0 2 4 6 8 10 12 14 16 18 being displayed
<h2>again</h2>
( -- ) begin <forth words> again
<h1>forth</h1>
<h1>forth</h1>
<h2>EXIT</h2>
( -- ) "Return control to the calling definition. Before executing EXIT within a do-loop
<h1>forth</h1>
<h2>i</h2>
( -- n ) Place current loop index on top of stack
<h2>j</h2>
( -- n ) Place index count for next outer lop top of stack
<h2>leave</h2>
( -- ) Force do loop termination
<h2>loop</h2>
( -- ) part of do <forth words> loop construct
<h2>next</h2>
( -- ) part of for <forth words> next construct
<h2>repeat</h2>
( -- ) part of begin <forth words that leave f on the stack> while < more forth words> repeat
<h1>forth</h1>
<h2>until</h2>
( f -- ) begin <forth words that leave f on stack> until
<h2>while</h2>
( f -- ) part of begin <forth words that leave f on the stack> while < more forth words> repeat
<h2>Maths</h2>
<h2>-</h2>
( n1 n2 -- n3 ) n3 = n1 - n2
<h2>*</h2>
( n1 n2 -- n3 ) n3 = n1 * n2
<h2>*/</h2>
( n1 n2 n3 -- n4 ) Multiply n1 by n2 producing the intermediate double-cell result d. Divide d by n3 giving the single-cell quotient n4
<h2>*/MOD</h2>
( n1 n2 -n3 -- n4 n5 ) Multiply n1 by n2 producing the intermediate double-cell result d. Divide d by n3 producing the single-cell remainder n4 and the single-cell quotient n5
<h2>/</h2>
( n1 n2 -- n3 ) "Divide n1 by n2
<h2>/mod</h2>
( n1 n2 -- n3 n4 ) "Divide n1 by n2
<h2>+</h2>
( n1 n2 -- n3 ) n3 = n1 + n1
<h2>2*</h2>
( n1 -- n2 ) n2 = n1 * 2
<h2>2/</h2>
( n1 -- n2 ) n2 = n1 / 2
<h2>4*</h2>
( n1 -- n2 ) n2 = n1 * 4
<h2>4/</h2>
( n1 -- n2 ) n2 = n1 / 4
<h2>abs</h2>
( n1 -- n2 ) n2 is the absolute value of n1
<h2>max</h2>
( n1 n2 -- n3 ) n3 = the larger of n1 or n2
<h2>min</h2>
( n1 n2 – n3 ) n3 = the smaller of n1 or n2
<h2>mod</h2>
( n1 n2 – n3 ) "Divide n1 by n2
<h2>negate</h2>
( n – -n ) Two's complement of top of stack
<h2>U/MOD</h2>
( u1 u2 -- rem quot ) "Unsigned division
<h2>1+</h2>
( n-- n+1 ) increment value on the stack by 1
<h2>1-</h2>
( n-- n1- ) decrement value on the stack by 1
<h2>Memory</h2>
<h2>!</h2>
( n addr --> ) store x at addr
<h2>@</h2>
( addr --n ) Retrieves the integer value n stored at address addr
<h2>+!</h2>
( n addr -- ) Increments the content of a variable by the value n
<h1>forth</h1>
<h1>forth</h1>
<h2>2!</h2>
( n1 n2 addr --> ) "store n1
<h2>2@</h2>
( addr --n1 n2 ) "read n1
<h2>C!</h2>
( c addr --> ) store byte c at addr
<h2>C@</h2>
( addr --c ) read byte c from addr
<h2>allocate</h2>
( n -- a ior ) "reserve a memory chunk of n bytes
<h2>cell/</h2>
( n1 -- n2 ) n2 = n1 / 4
<h2>cell+</h2>
( n1 -- n2 ) n2 = n1 + 4
<h2>cells</h2>
( n1 -- n2 ) n2 = n1 * 4
<h2>cmove</h2>
( addr1 addr2 n -- ) "move n bytes from addr1 to addr2
<h2>cmove></h2>
( addr1 addr2 n -- ) "copy n bytes from memory starting at c-addr1 to that starting at c-addr2
<h2>fill</h2>
( addr n c ) fill memory from addr for n bytes with byte c
<h2>free</h2>
( a -- ) free memory previously reserved allocate - see also resize
<h2>L!</h2>
( n addr -- ) write n to addr in real ESP32 memory space
<h2>L@</h2>
( addr --n ) read n from real ESP32 memory space
<h2>resize</h2>
( a n -- a ior ) "ior=true if a memory chunk reserved with MALLOC resized to n bytes correctly
<h2>Number I/O</h2>
<h2>?</h2>
( addr -- ) display value at addr
<h2>.</h2>
( n – ) display top of stack
<h2>#</h2>
( ud1 -- ud2 ) Convert next digit of ud1 and HOLD it
<h2>#></h2>
( ud -- addr n ) Drop ud and prepare string for TYPE
<h2>#s</h2>
( ud -- 0 0 ) Convert and HOLD all remaining significant digits
<h2><#</h2>
( -- ) Begin a formatted number conversion
<h2>base</h2>
( -- addr ) Stores the current number display base - defaults to 10 decimal
<h2>binary</h2>
( – ) Set current number base to 2 decimal
<h2>decimal</h2>
( – ) Set current number base to 10 decimal
<h2>extract</h2>
( n base -- n c ) extracts the least significant digit from a number n. n is divided by the radix in BASE and returned on the stack
<h2>hex</h2>
( – ) Set current number base to 16 decimal
<h2>hold</h2>
( c -- ) Insert character into formatted string
<h2>n.</h2>
( n -- ) "display n in decimal
<h2>octal</h2>
( -- ) Set current number base to 8 decimal
<h2>pad</h2>
( -- addr ) returns the address of the text buffer where numbers are constructed and text strings are stored temporarily
<h2>sign</h2>
(n ud -- ud ) HOLD minus sign only if n is negative
<h2>u.</h2>
( n -- ) display n in the current number base
<h2>Registers</h2>
<h2>m!</h2>
<h2>m@</h2>
<h2>SD card</h2>
<h1>SD</h1>
<h1>These words are inside the SD vocabulary. They allow use of an SDcard over SPI.</h1>
<h2>SD.begin </h2>
( -- ok ) "uses all the defaults ""/sd"" etc."
<h2>SD.beginDefaults ( -- sspin SPIClass frequency mountpointsz maxfiles format_if_empty )</h2>
<h2>"( SS SPI 4000000 ""/sd"" 5 false )"</h2>
<h2>SD.beginFull ( sspin SPIClass frequency mountpoint maxfiles format_if_empty -- ok )</h2>
<h2>SD.end </h2>
( -- )
<h2>SD.cardType </h2>
( -- n )
<h2>SD.totalBytes </h2>
( -- n )
<h2>SD.usedBytes </h2>
( -- n )
<h2>SD_MMC card</h2>
<h2>SD_MMC.begin</h2>
( mount mode1bit ) default mode1bit=false
<h2>SD_MMC.cardType</h2>
( -- n )
<h2>SD_MMC.end</h2>
( -- )
<h2>SD_MMC.totalBytes</h2>
( -- n )
<h2>SD_MMC.usedBytes</h2>
( -- n )
<h1>Serial communication</h1>
<h2>Serial.available</h2>
( -- f ) Get the number of bytes (characters) available for reading from the serial port. This is data that’s already arrived and stored in the serial receive buffer (which holds 64 bytes)
<h2>Serial.begin</h2>
( baud -- ) Start serial port. Sets the data rate in bits per second (baud) for serial data transmission
<h2>Serial.end</h2>
( -- ) "Disables serial communication
<h2>Serial.flush</h2>
( -- ) Waits for the transmission of outgoing serial data to complete
<h2>Serial.readBytes</h2>
( a length -- n ) "Serial.readBytes reads characters from the serial port into a buffer
<h2>Serial.write</h2>
( a n -- n ) Writes n bytes of data to the serial port from buffer at address a
<h2>Sockets</h2>
<h2>accept</h2>
( addr length-- f )
<h2>AF_INET</h2>
( -- 2) constant
<h2>bind</h2>
( addr -- f )
<h2>connect</h2>
( addr -- f )
<h2>errno</h2>
( -- f ) f = the error number of the last sockets action
<h2>listen</h2>
( socket backlog -- f ) Listen for socket connections and limit the queue of incoming connections - 'backlog' is the max no. of connections that can be put on hold
<h2>poll</h2>
( pollfd n1 n2 -- f )
<h2>select</h2>
( n1 n2 n3 n4 -- f )
<h2>sizeof(sockaddr_in)</h2>
( -- 16 ) constant
<h2>SOCK_STREAM</h2>
( -- 1) constant
<h1>sockets</h1>
<h2>Serial Peripheral Interface Flash File System</h2>
<h2>SPIFFS.begin</h2>
( format-on-fail path-z max-files -- f ) "Mounts file system. It must be called before any other SPIFFS words are used. Returns true if file system was mounted successfully
<h2>SPIFFS.end</h2>
( -- ) Unmounts the flash memory file system
<h2>SPIFFS.format</h2>
( -- f ) Format the flash memory 'disk'. returns true if successful
<h2>SPIFFS.totalBytes</h2>
( -- n ) Returns the total capacity of the flash memory 'disk'
<h2>SPIFFS.usedBytes</h2>
( -- n ) Returns the total space occupied by flash memory files
<h2>Stack functions</h2>
<h2>-rot</h2>
( x1 x2 x3 -- x2 x3 x1) rotate 3rd cell to top
<h2>>R</h2>
( n – ) move n to the return stack
<h2>2drop</h2>
( n1 n2 – ) discard the top of stack
<h2>2dup</h2>
( n1 n2 – n1 n2 n1 n2) duplicate the top two items on the data stack
<h1>forth</h1>
<h2>DROP</h2>
( n – ) discard the top of stack
<h2>DUP</h2>
( n – n n ) duplicate the top of stack
<h2>nip</h2>
( n1 n2 -- n2 ) remove the 2nd item on the data stack
<h2>OVER</h2>
( n1 n2 -- n1 n2 n1 ) duplicate 2nd item on the data stack
<h2>R@</h2>
( -- n ) copy the top of the return stack to the top of data stack
<h2>R></h2>
( – n ) Move top of return stack to data stack
<h2>rdrop</h2>
( -- ) drop the top of the return stack
<h2>rot</h2>
( n1 n2 n3 – n2 n3 n1 ) rotate 3rd cell to top
<h2>RP!</h2>
( addr -- ) set the return stack pointer
<h2>RP@</h2>
( -- addr ) read the return stack pointer
<h2>rp0</h2>
( -- addr ) constant - the initial value of the return stack pointer at switch-on
<h2>SP!</h2>
( addr -- ) Set the data stack pointer
<h2>SP@</h2>
( -- addr ) Read the data stack pointer
<h2>sp0</h2>
( -- n ) constant - the initial value of the data stack pointer at switch-on
<h2>SWAP</h2>
( n1 n2 – n2 n1 ) swap the top two data stack entries
<h2>Streams</h2>
<h2>>offset</h2>
<h2>>read</h2>
<h2>>stream</h2>
<h2>>write</h2>
<h2>ch>stream</h2>
<h2>empty?</h2>
<h2>full?</h2>
<h2>stream</h2>
"( n ""name"" -- )" "define a stream
<h2>stream#</h2>
<h2>stream></h2>
<h2>stream>ch</h2>
<h2>wait-read</h2>
<h2>wait-write</h2>
<h2>String functions</h2>
<h1>forth</h1>
<h2>$place</h2>
( addr cnt -- )
<h2>"r"""</h2>
"( ""string"" -- a n )" Creates a temporary counted string
<h2>r|</h2>