├── .gitignore
├── DB_gig_font.txt
├── IOSerial.asm
├── LICENSE
├── MINT-macros.asm
├── MINT.asm
├── RC2014_MINT.hex
├── README.md
├── TEC-1ROM10.z80
├── TEC-1ROM10.z80.hex
├── TEC-1ROM10.z80.lst
├── constants.asm
├── display-test.z80
├── ftest.mac.asm
├── ftest.z80
├── inspiration.md
├── mycomputer.emu
├── ram.asm
├── rtest.z80
├── tec-test.z80
├── test.mac.asm
└── test.z80
/.gitignore:
--------------------------------------------------------------------------------
1 | notes.txt
2 | .vscode/
3 | *test.z80.hex
4 | *test.z80.lst
5 | notes.md
--------------------------------------------------------------------------------
/DB_gig_font.txt:
--------------------------------------------------------------------------------
1 |
2 | font:
3 | ; " "
4 | DB $00
5 | DB $00
6 | DB $00
7 | DB $00
8 | DB $00
9 | DB $00
10 | DB $00
11 | DB $00
12 | ; "!"
13 | DB $20
14 | DB $20
15 | DB $20
16 | DB $20
17 | DB $20
18 | DB $00
19 | DB $20
20 | DB $00
21 | ; """
22 | DB $D8
23 | DB $48
24 | DB $90
25 | DB $00
26 | DB $00
27 | DB $00
28 | DB $00
29 | DB $00
30 | ; "1 "
31 | DB $50
32 | DB $50
33 | DB $F8
34 | DB $50
35 | DB $F8
36 | DB $50
37 | DB $50
38 | DB $00
39 | ; "$"
40 | DB $20
41 | DB $78
42 | DB $A0
43 | DB $70
44 | DB $28
45 | DB $F0
46 | DB $20
47 | DB $00
48 | ; "%"
49 | DB $C0
50 | DB $C8
51 | DB $10
52 | DB $20
53 | DB $40
54 | DB $98
55 | DB $18
56 | DB $00
57 | ; "&"
58 | DB $40
59 | DB $A0
60 | DB $A0
61 | DB $40
62 | DB $A8
63 | DB $90
64 | DB $68
65 | DB $00
66 | ; "'"
67 | DB $60
68 | DB $20
69 | DB $40
70 | DB $00
71 | DB $00
72 | DB $00
73 | DB $00
74 | DB $00
75 | ; "("
76 | DB $10
77 | DB $20
78 | DB $40
79 | DB $40
80 | DB $40
81 | DB $20
82 | DB $10
83 | DB $00
84 | ; ")"
85 | DB $40
86 | DB $20
87 | DB $10
88 | DB $10
89 | DB $10
90 | DB $20
91 | DB $40
92 | DB $00
93 | ; "*"
94 | DB $00
95 | DB $20
96 | DB $A8
97 | DB $70
98 | DB $A8
99 | DB $20
100 | DB $00
101 | DB $00
102 | ; "+"
103 | DB $00
104 | DB $20
105 | DB $20
106 | DB $F8
107 | DB $20
108 | DB $20
109 | DB $00
110 | DB $00
111 | ; ","
112 | DB $00
113 | DB $00
114 | DB $00
115 | DB $00
116 | DB $00
117 | DB $60
118 | DB $20
119 | DB $40
120 | ; "-"
121 | DB $00
122 | DB $00
123 | DB $00
124 | DB $F8
125 | DB $00
126 | DB $00
127 | DB $00
128 | DB $00
129 | ; "0 "
130 | DB $00
131 | DB $00
132 | DB $00
133 | DB $00
134 | DB $00
135 | DB $00
136 | DB $60
137 | DB $00
138 | ; "/"
139 | DB $00
140 | DB $10
141 | DB $10
142 | DB $20
143 | DB $20
144 | DB $40
145 | DB $40
146 | DB $00
147 | ; "0"
148 | DB $70
149 | DB $88
150 | DB $98
151 | DB $A8
152 | DB $C8
153 | DB $88
154 | DB $70
155 | DB $00
156 | ; "1"
157 | DB $20
158 | DB $60
159 | DB $A0
160 | DB $20
161 | DB $20
162 | DB $20
163 | DB $F8
164 | DB $00
165 | ; "2"
166 | DB $70
167 | DB $88
168 | DB $08
169 | DB $30
170 | DB $40
171 | DB $80
172 | DB $F8
173 | DB $00
174 | ; "3"
175 | DB $70
176 | DB $88
177 | DB $08
178 | DB $30
179 | DB $08
180 | DB $88
181 | DB $70
182 | DB $00
183 | ; "4"
184 | DB $10
185 | DB $30
186 | DB $50
187 | DB $90
188 | DB $F8
189 | DB $10
190 | DB $10
191 | DB $00
192 | ; "5"
193 | DB $F8
194 | DB $80
195 | DB $F0
196 | DB $08
197 | DB $08
198 | DB $88
199 | DB $70
200 | DB $00
201 | ; "6"
202 | DB $30
203 | DB $40
204 | DB $80
205 | DB $F0
206 | DB $88
207 | DB $88
208 | DB $70
209 | DB $00
210 | ; "7"
211 | DB $F8
212 | DB $08
213 | DB $10
214 | DB $20
215 | DB $40
216 | DB $40
217 | DB $40
218 | DB $00
219 | ; "8"
220 | DB $70
221 | DB $88
222 | DB $88
223 | DB $70
224 | DB $88
225 | DB $88
226 | DB $70
227 | DB $00
228 | ; "9"
229 | DB $70
230 | DB $88
231 | DB $88
232 | DB $78
233 | DB $08
234 | DB $10
235 | DB $60
236 | DB $00
237 | ; ":"
238 | DB $00
239 | DB $00
240 | DB $60
241 | DB $00
242 | DB $00
243 | DB $60
244 | DB $00
245 | DB $00
246 | ; ";"
247 | DB $00
248 | DB $00
249 | DB $60
250 | DB $00
251 | DB $00
252 | DB $60
253 | DB $20
254 | DB $40
255 | ; "<"
256 | DB $10
257 | DB $20
258 | DB $40
259 | DB $80
260 | DB $40
261 | DB $20
262 | DB $10
263 | DB $00
264 | ; "="
265 | DB $00
266 | DB $00
267 | DB $F8
268 | DB $00
269 | DB $F8
270 | DB $00
271 | DB $00
272 | DB $00
273 | ; ">"
274 | DB $40
275 | DB $20
276 | DB $10
277 | DB $08
278 | DB $10
279 | DB $20
280 | DB $40
281 | DB $00
282 | ; "?"
283 | DB $70
284 | DB $88
285 | DB $08
286 | DB $10
287 | DB $20
288 | DB $00
289 | DB $20
290 | DB $00
291 | ; "@"
292 | DB $70
293 | DB $88
294 | DB $B8
295 | DB $A8
296 | DB $B8
297 | DB $80
298 | DB $70
299 | DB $00
300 | ; "A"
301 | DB $20
302 | DB $50
303 | DB $88
304 | DB $88
305 | DB $F8
306 | DB $88
307 | DB $88
308 | DB $00
309 | ; "B"
310 | DB $F0
311 | DB $88
312 | DB $88
313 | DB $F0
314 | DB $88
315 | DB $88
316 | DB $F0
317 | DB $00
318 | ; "C"
319 | DB $70
320 | DB $88
321 | DB $80
322 | DB $80
323 | DB $80
324 | DB $88
325 | DB $70
326 | DB $00
327 | ; "D"
328 | DB $E0
329 | DB $90
330 | DB $88
331 | DB $88
332 | DB $88
333 | DB $90
334 | DB $E0
335 | DB $00
336 | ; "E"
337 | DB $F8
338 | DB $80
339 | DB $80
340 | DB $F0
341 | DB $80
342 | DB $80
343 | DB $F8
344 | DB $00
345 | ; "F"
346 | DB $F8
347 | DB $80
348 | DB $80
349 | DB $F0
350 | DB $80
351 | DB $80
352 | DB $80
353 | DB $00
354 | ; "G"
355 | DB $70
356 | DB $88
357 | DB $80
358 | DB $98
359 | DB $88
360 | DB $88
361 | DB $70
362 | DB $00
363 | ; "H"
364 | DB $88
365 | DB $88
366 | DB $88
367 | DB $F8
368 | DB $88
369 | DB $88
370 | DB $88
371 | DB $00
372 | ; "I"
373 | DB $70
374 | DB $20
375 | DB $20
376 | DB $20
377 | DB $20
378 | DB $20
379 | DB $70
380 | DB $00
381 | ; "J"
382 | DB $38
383 | DB $10
384 | DB $10
385 | DB $10
386 | DB $10
387 | DB $90
388 | DB $60
389 | DB $00
390 | ; "K"
391 | DB $88
392 | DB $90
393 | DB $A0
394 | DB $C0
395 | DB $A0
396 | DB $90
397 | DB $88
398 | DB $00
399 | ; "L"
400 | DB $80
401 | DB $80
402 | DB $80
403 | DB $80
404 | DB $80
405 | DB $80
406 | DB $F8
407 | DB $00
408 | ; "M"
409 | DB $88
410 | DB $D8
411 | DB $A8
412 | DB $A8
413 | DB $88
414 | DB $88
415 | DB $88
416 | DB $00
417 | ; "N"
418 | DB $88
419 | DB $88
420 | DB $C8
421 | DB $A8
422 | DB $98
423 | DB $88
424 | DB $88
425 | DB $00
426 | ; "O"
427 | DB $70
428 | DB $88
429 | DB $88
430 | DB $88
431 | DB $88
432 | DB $88
433 | DB $70
434 | DB $00
435 | ; "P"
436 | DB $F0
437 | DB $88
438 | DB $88
439 | DB $F0
440 | DB $80
441 | DB $80
442 | DB $80
443 | DB $00
444 | ; "Q"
445 | DB $70
446 | DB $88
447 | DB $88
448 | DB $88
449 | DB $A8
450 | DB $90
451 | DB $68
452 | DB $00
453 | ; "R"
454 | DB $F0
455 | DB $88
456 | DB $88
457 | DB $F0
458 | DB $A0
459 | DB $90
460 | DB $88
461 | DB $00
462 | ; "S"
463 | DB $70
464 | DB $80
465 | DB $80
466 | DB $70
467 | DB $08
468 | DB $08
469 | DB $F0
470 | DB $00
471 | ; "T"
472 | DB $F8
473 | DB $20
474 | DB $20
475 | DB $20
476 | DB $20
477 | DB $20
478 | DB $20
479 | DB $00
480 | ; "U"
481 | DB $88
482 | DB $88
483 | DB $88
484 | DB $88
485 | DB $88
486 | DB $88
487 | DB $70
488 | DB $00
489 | ; "V"
490 | DB $88
491 | DB $88
492 | DB $88
493 | DB $88
494 | DB $50
495 | DB $50
496 | DB $20
497 | DB $00
498 | ; "W"
499 | DB $88
500 | DB $88
501 | DB $88
502 | DB $A8
503 | DB $A8
504 | DB $D8
505 | DB $88
506 | DB $00
507 | ; "1 "
508 | DB $88
509 | DB $88
510 | DB $50
511 | DB $20
512 | DB $50
513 | DB $88
514 | DB $88
515 | DB $00
516 | ; "Y"
517 | DB $88
518 | DB $88
519 | DB $88
520 | DB $50
521 | DB $20
522 | DB $20
523 | DB $20
524 | DB $00
525 | ; "Z"
526 | DB $F8
527 | DB $08
528 | DB $10
529 | DB $20
530 | DB $40
531 | DB $80
532 | DB $F8
533 | DB $00
534 | ; "~"
535 | DB $70
536 | DB $40
537 | DB $40
538 | DB $40
539 | DB $40
540 | DB $40
541 | DB $70
542 | DB $00
543 | ; "\\"
544 | DB $00
545 | DB $40
546 | DB $40
547 | DB $20
548 | DB $20
549 | DB $10
550 | DB $10
551 | DB $00
552 | ; "]"
553 | DB $70
554 | DB $10
555 | DB $10
556 | DB $10
557 | DB $10
558 | DB $10
559 | DB $70
560 | DB $00
561 | ; "^"
562 | DB $20
563 | DB $50
564 | DB $88
565 | DB $00
566 | DB $00
567 | DB $00
568 | DB $00
569 | DB $00
570 | ; "_"
571 | DB $00
572 | DB $00
573 | DB $00
574 | DB $00
575 | DB $00
576 | DB $00
577 | DB $F8
578 | DB $00
579 | ; "`"
580 | DB $30
581 | DB $20
582 | DB $10
583 | DB $00
584 | DB $00
585 | DB $00
586 | DB $00
587 | DB $00
588 | ; "a"
589 | DB $00
590 | DB $00
591 | DB $70
592 | DB $08
593 | DB $78
594 | DB $88
595 | DB $78
596 | DB $00
597 | ; "b"
598 | DB $80
599 | DB $80
600 | DB $F0
601 | DB $88
602 | DB $88
603 | DB $88
604 | DB $F0
605 | DB $00
606 | ; "c"
607 | DB $00
608 | DB $00
609 | DB $70
610 | DB $80
611 | DB $80
612 | DB $80
613 | DB $78
614 | DB $00
615 | ; "d"
616 | DB $08
617 | DB $08
618 | DB $78
619 | DB $88
620 | DB $88
621 | DB $88
622 | DB $78
623 | DB $00
624 | ; "e"
625 | DB $00
626 | DB $00
627 | DB $70
628 | DB $88
629 | DB $F8
630 | DB $80
631 | DB $70
632 | DB $00
633 | ; "f"
634 | DB $30
635 | DB $48
636 | DB $40
637 | DB $E0
638 | DB $40
639 | DB $40
640 | DB $40
641 | DB $00
642 | ; "g"
643 | DB $00
644 | DB $00
645 | DB $70
646 | DB $88
647 | DB $88
648 | DB $78
649 | DB $08
650 | DB $70
651 | ; "h"
652 | DB $80
653 | DB $80
654 | DB $F0
655 | DB $88
656 | DB $88
657 | DB $88
658 | DB $88
659 | DB $00
660 | ; "i"
661 | DB $20
662 | DB $00
663 | DB $60
664 | DB $20
665 | DB $20
666 | DB $20
667 | DB $70
668 | DB $00
669 | ; "j"
670 | DB $10
671 | DB $00
672 | DB $30
673 | DB $10
674 | DB $10
675 | DB $10
676 | DB $90
677 | DB $60
678 | ; "k"
679 | DB $80
680 | DB $80
681 | DB $90
682 | DB $A0
683 | DB $E0
684 | DB $90
685 | DB $88
686 | DB $00
687 | ; "l"
688 | DB $60
689 | DB $20
690 | DB $20
691 | DB $20
692 | DB $20
693 | DB $20
694 | DB $70
695 | DB $00
696 | ; "m"
697 | DB $00
698 | DB $00
699 | DB $D0
700 | DB $A8
701 | DB $A8
702 | DB $A8
703 | DB $88
704 | DB $00
705 | ; "n"
706 | DB $00
707 | DB $00
708 | DB $B0
709 | DB $C8
710 | DB $88
711 | DB $88
712 | DB $88
713 | DB $00
714 | ; "o"
715 | DB $00
716 | DB $00
717 | DB $70
718 | DB $88
719 | DB $88
720 | DB $88
721 | DB $70
722 | DB $00
723 | ; "p"
724 | DB $00
725 | DB $00
726 | DB $F0
727 | DB $88
728 | DB $88
729 | DB $F0
730 | DB $80
731 | DB $80
732 | ; "q"
733 | DB $00
734 | DB $00
735 | DB $78
736 | DB $88
737 | DB $88
738 | DB $78
739 | DB $08
740 | DB $08
741 | ; "r"
742 | DB $00
743 | DB $00
744 | DB $B0
745 | DB $C8
746 | DB $80
747 | DB $80
748 | DB $80
749 | DB $00
750 | ; "s"
751 | DB $00
752 | DB $00
753 | DB $70
754 | DB $80
755 | DB $70
756 | DB $08
757 | DB $F0
758 | DB $00
759 | ; "t"
760 | DB $40
761 | DB $40
762 | DB $E0
763 | DB $40
764 | DB $40
765 | DB $48
766 | DB $30
767 | DB $00
768 | ; "u"
769 | DB $00
770 | DB $00
771 | DB $88
772 | DB $88
773 | DB $88
774 | DB $98
775 | DB $68
776 | DB $00
777 | ; "v"
778 | DB $00
779 | DB $00
780 | DB $88
781 | DB $88
782 | DB $88
783 | DB $50
784 | DB $20
785 | DB $00
786 | ; "w"
787 | DB $00
788 | DB $00
789 | DB $88
790 | DB $88
791 | DB $A8
792 | DB $A8
793 | DB $50
794 | DB $00
795 | ; "x"
796 | DB $00
797 | DB $00
798 | DB $88
799 | DB $50
800 | DB $20
801 | DB $50
802 | DB $88
803 | DB $00
804 | ; "y"
805 | DB $00
806 | DB $00
807 | DB $88
808 | DB $88
809 | DB $88
810 | DB $78
811 | DB $08
812 | DB $70
813 | ; "z"
814 | DB $00
815 | DB $00
816 | DB $F8
817 | DB $10
818 | DB $20
819 | DB $40
820 | DB $F8
821 | DB $00
822 | ; "{"
823 | DB $30
824 | DB $40
825 | DB $40
826 | DB $80
827 | DB $40
828 | DB $40
829 | DB $30
830 | DB $00
831 | ; "|"
832 | DB $20
833 | DB $20
834 | DB $20
835 | DB $20
836 | DB $20
837 | DB $20
838 | DB $20
839 | DB $00
840 | ; "}"
841 | DB $60
842 | DB $10
843 | DB $10
844 | DB $08
845 | DB $10
846 | DB $10
847 | DB $60
848 | DB $00
849 | ; "~"
850 | DB $40
851 | DB $A8
852 | DB $10
853 | DB $00
854 | DB $00
855 | DB $00
856 | DB $00
857 | DB $00
858 | ; Inverse space
859 | DB $F8
860 | DB $F8
861 | DB $F8
862 | DB $F8
863 | DB $F8
864 | DB $F8
865 | DB $F8
866 | DB $00
867 | ; Leftwards arrow
868 | DB $00
869 | DB $20
870 | DB $40
871 | DB $F8
872 | DB $40
873 | DB $20
874 | DB $00
875 | DB $00
876 | ; Upwards arrow
877 | DB $00
878 | DB $20
879 | DB $70
880 | DB $A8
881 | DB $20
882 | DB $20
883 | DB $00
884 | DB $00
885 | ; Rightwards arrow
886 | DB $00
887 | DB $20
888 | DB $10
889 | DB $F8
890 | DB $10
891 | DB $20
892 | DB $00
893 | DB $00
894 | ; Downwards arrow
895 | DB $00
896 | DB $20
897 | DB $20
898 | DB $A8
899 | DB $70
900 | DB $20
901 | DB $00
902 | DB $00
903 |
--------------------------------------------------------------------------------
/IOSerial.asm:
--------------------------------------------------------------------------------
1 | ; ROM code
2 | ; Targets:
3 | ; TEC-1,TEC-1D,TEC-1F,Southern Cross,RC2014
4 | ; Memory Map: 2k ROM/RAM, 8K ROM/RAM, RC2014
5 | ; Serial: Bit Bang, 6850 ACIA
6 |
7 | .if TEC_1
8 | .if BITBANG
9 |
10 | ; bit bang baud rate constants @ 4MHz
11 | B300: .EQU 0220H
12 | B1200: .EQU 0080H
13 | B2400: .EQU 003FH
14 | B4800: .EQU 001BH
15 | B9600: .EQU 000BH
16 |
17 | .else ;6850
18 |
19 | ;
20 | ; 6850 ACIA registers
21 | ;----------------------
22 | CONTROL .EQU $80 ;(write)
23 | STATUS .EQU $80 ;(read)
24 | TDR .EQU $81 ;(write)
25 | RDR .EQU $81 ;(read)
26 | ;
27 | ; control register bits
28 | ;----------------------
29 | ;
30 | ;clock divisor
31 | ;
32 | MRESET .EQU $03 ;master reset the ACIA
33 | ; DIV_0 .EQU $00 ;CLOCK/1
34 | ; DIV_16 .EQU $01 ;CLOCK/16
35 | DIV_64 .EQU $02 ;CLOCK/64
36 | ;
37 | ; format select
38 | ;
39 | F7E2 .EQU $00 ;7 data bits, EVEN parity, 2 stop bits (1+7+1+2= 11 bits)
40 | F7O2 .EQU $04 ;7 data bits, ODD parity, 2 stop bits (1+7+1+2= 11 bits)
41 | F7E1 .EQU $08 ;7 data bits, EVEN parity, 1 stop bit (1+7+1+1= 10 bits)
42 | F7O1 .EQU $0C ;7 data bits, ODD parity, 1 stop bit (1+7+1+1= 10 bits)
43 | F8N2 .EQU $10 ;8 data bits, NO parity, 2 stop bits (1+8+0+2= 11 bits)
44 | F8N1 .EQU $14 ;8 data bits, NO parity, 1 stop bit (1+8+0+1= 10 bits)
45 | F8E1 .EQU $18 ;8 data bits, EVEN parity, 1 stop bit (1+8+1+1= 11 bits)
46 | F8O1 .EQU $1C ;8 data bits, ODD parity,1 stop bit (1+8+1+1= 11 bits)
47 | ;
48 | ; transmitter control
49 | ;
50 | RTSLID .EQU $00 ;RTS LOW, transmit interrupt disabled
51 | RTSLIE .EQU $20 ;RTS LOW, transmit interrupt enabled
52 | RTSHID .EQU $40 ;RTS HIGH, transmit interrupt disabled
53 | RTSLIDB .EQU $60 ;RTS LOW, transmit interrupt disabled and 'break' transmitted
54 | ;
55 | ; receiver interrupt
56 | ;
57 | RIE .EQU $80 ;receiver interrupt enabled
58 | ;
59 | ; status register bits
60 | ;---------------------
61 | RDRF .EQU 0 ;receive data register full
62 | TDRE .EQU 1 ;transmit data register empty
63 | DCD .EQU 2 ;data carrier detect
64 | CTS .EQU 3 ;clear to send
65 | FE .EQU 4 ;framing error
66 | OVRN .EQU 5 ;overrun
67 | PE .EQU 6 ;parity error
68 | IRQ .EQU 7 ;interrupt request
69 |
70 | .endif
71 | .endif
72 |
73 | ; I/O port addresses
74 |
75 | .if TEC_1
76 | KEYBUF: .EQU 00H ;MM74C923N KEYBOARD ENCODER
77 | SCAN: .EQU 01H ;DISPLAY SCAN LATCH
78 | DISPLY: .EQU 02H ;DISPLAY LATCH
79 | PORT3: .EQU 03H ;ST3 (8X8), STROBE (RELAY BOARD) DATLATCH (DAT BOARD)
80 | PORT4: .EQU 04H ;ST4 (8X8), LCD 'E' (DAT BOARD)
81 | PORT5: .EQU 05H
82 | PORT6: .EQU 06H
83 | PORT7: .EQU 07H ;ENABLE/DISABLE SINGLE STEPPER (IF INSTALLED)
84 | .else ;SC
85 | IO0: .EQU 80H ;IO PORT 0
86 | IO1: .EQU 81H ;IO PORT 1
87 | IO2: .EQU 82H ;IO PORT 2
88 | IO3: .EQU 83H ;IO PORT 3
89 | DISPLY: .EQU 84H ;DISPLAY LATCH
90 | SCAN: .EQU 85H ;DISPLAY SCAN LATCH
91 | KEYBUF: .EQU 86H ;KEYBOARD BUFFER
92 | IO7: .EQU 87H ;ENABLE/DISABLE SINGLE STEPPER (IF INSTALLED)
93 | .endif
94 |
95 | ; ASCII codes
96 | ESC: .EQU 1BH
97 | CR: .EQU 0DH
98 | LF: .EQU 0AH
99 |
100 | .ORG ROMSTART
101 | ;reset
102 | RSTVEC:
103 | JP RESET
104 | ;RST 1
105 | .ORG ROMSTART+$08
106 | PUSH HL
107 | LD HL,(RST08)
108 | JP (HL)
109 |
110 | ;RST 2
111 | .ORG ROMSTART+$10
112 | PUSH HL
113 | LD HL,(RST10)
114 | JP (HL)
115 |
116 | ;RST 3
117 | .ORG ROMSTART+$18
118 | PUSH HL
119 | LD HL,(RST18)
120 | JP (HL)
121 |
122 | ;RST 4
123 | .ORG ROMSTART+$20
124 | PUSH HL
125 | LD HL,(RST20)
126 | JP (HL)
127 |
128 | ;RST 5
129 | .ORG ROMSTART+$28
130 | PUSH HL
131 | LD HL,(RST28)
132 | JP (HL)
133 |
134 | ;RST 6
135 | .ORG ROMSTART+$30
136 | PUSH HL
137 | LD HL,(RST30)
138 | JP (HL)
139 |
140 | ;RST 7 Interrupt
141 | .ORG ROMSTART+$38
142 | PUSH HL
143 | LD HL,(INTVEC)
144 | JP (HL)
145 | RETI
146 |
147 | .ORG ROMSTART+$40
148 |
149 | ;hexadecimal to 7 segment display code table
150 | .if TEC_1
151 |
152 | sevensegment:
153 | .DB 0EBH,28H,0CDH,0ADH ;0,1,2,3
154 | .DB 2EH,0A7H,0E7H,29H ;4,5,6,7
155 | .DB 0EFH,2FH,6FH,0E6H ;8,9,A,B
156 | .DB 0C3H,0ECH,0C7H,47H ;C,D,E,F
157 | .else ;SC
158 |
159 | sevensegment:
160 | .DB 3FH,06H,5BH,4FH ;0,1,2,3
161 | .DB 66H,6DH,7DH,07H ;4,5,6,7
162 | .DB 7FH,6FH,77H,7CH ;8,9,A,B
163 | .DB 39H,5EH,79H,71H ;C,D,E,F
164 | .endif
165 |
166 |
167 | ;---------------
168 | ; BIT TIME DELAY
169 | ;---------------
170 | ;DELAY FOR ONE SERIAL BIT TIME
171 | ;ENTRY : HL = DELAY TIME
172 | ; NO REGISTERS MODIFIED
173 | ;
174 | PWRUP:
175 | LD hl,$2000
176 | BITIME:
177 | PUSH HL
178 | PUSH DE
179 | LD DE,0001H
180 | BITIM1:
181 | SBC HL,DE
182 | JP NC,BITIM1
183 | POP DE
184 | POP HL
185 | IntRet:
186 | RET
187 |
188 | ;RST 8 Non Maskable Interrupt
189 | .ORG ROMSTART+$66
190 | PUSH HL
191 | LD HL,(NMIVEC)
192 | JP (HL)
193 |
194 |
195 | .if BITBANG
196 |
197 | ;------------------------
198 | ; SERIAL TRANSMIT ROUTINE
199 | ;------------------------
200 | ;TRANSMIT BYTE SERIALLY ON DOUT
201 | ;
202 | ; ENTRY : A = BYTE TO TRANSMIT
203 | ; EXIT : NO REGISTERS MODIFIED
204 | ;
205 |
206 | TxChar:
207 | TXDATA:
208 | PUSH AF
209 | PUSH BC
210 | PUSH HL
211 | LD HL,(BAUD)
212 | LD C,A
213 | ;
214 | ; TRANSMIT START BIT
215 | ;
216 | XOR A
217 | OUT (SCAN),A
218 | CALL BITIME
219 | ;
220 | ; TRANSMIT DATA
221 | ;
222 | LD B,08H
223 | RRC C
224 | NXTBIT:
225 | RRC C ;SHIFT BITS TO D6,
226 | LD A,C ;LSB FIRST AND OUTPUT
227 | AND 40H ;THEM FOR ONE BIT TIME.
228 | OUT (SCAN),A
229 | CALL BITIME
230 | DJNZ NXTBIT
231 | ;
232 | ; SEND STOP BITS
233 | ;
234 | LD A,40H
235 | OUT (SCAN),A
236 | CALL BITIME
237 | CALL BITIME
238 | POP HL
239 | POP BC
240 | POP AF
241 | RET
242 | ;-----------------------
243 | ; SERIAL RECEIVE ROUTINE
244 | ;-----------------------
245 | ;RECEIVE SERIAL BYTE FROM DIN
246 | ;
247 | ; ENTRY : NONE
248 | ; EXIT : A= RECEIVED BYTE IF CARRY CLEAR
249 | ;
250 | ; REGISTERS MODIFIED A AND F
251 | ;
252 | RxChar:
253 | RXDATA:
254 | PUSH BC
255 | PUSH HL
256 | ;
257 | ; WAIT FOR START BIT
258 | ;
259 | RXDAT1: IN A,(KEYBUF)
260 | BIT 7,A
261 | JR NZ,RXDAT1 ;NO START BIT
262 | ;
263 | ; DETECTED START BIT
264 | ;
265 | LD HL,(BAUD)
266 | SRL H
267 | RR L ;DELAY FOR HALF BIT TIME
268 | CALL BITIME
269 | IN A,(KEYBUF)
270 | BIT 7,A
271 | JR NZ,RXDAT1 ;START BIT NOT VALID
272 | ;
273 | ; DETECTED VALID START BIT,READ IN DATA
274 | ;
275 | LD B,08H
276 | RXDAT2:
277 | LD HL,(BAUD)
278 | CALL BITIME ;DELAY ONE BIT TIME
279 | IN A,(KEYBUF)
280 | RL A
281 | RR C ;SHIFT BIT INTO DATA REG
282 | DJNZ RXDAT2
283 | LD A,C
284 | OR A ;CLEAR CARRY FLAG
285 | POP HL
286 | POP BC
287 | RET
288 |
289 | .else ;6850
290 | ;
291 | ; transmit a character in a
292 | ;--------------------------
293 | TXDATA:
294 | TxChar:
295 | push bc
296 | ld b,a ;save the character for later
297 | TxChar1:
298 | in a,(STATUS) ;get the ACIA status
299 | bit 1,a
300 | ; bit TDRE,a ;is the TDRE bit high?
301 | jr z,TxChar1 ;no, the TDR is not empty
302 | ld a,b ;yes, get the character
303 | out (TDR),a ;and put it in the TDR
304 | pop bc
305 | ret
306 | ;
307 | ; receive a character in a
308 | ;---------------------------------
309 | RXDATA:
310 | RxChar:
311 | in a,(STATUS) ;get the ACIA status
312 | bit 0,a
313 | ; bit RDRF,a ;is the RDRF bit high?
314 | jr z,RxChar ;no, the RDR is empty
315 | in a,(RDR) ;yes, read the received char
316 | ret
317 | .endif
318 |
319 | .if LOADER
320 | ; .ORG ROMSTART + $0700
321 | ;-----------------------
322 | ; RECEIVE INTEL HEX FILE
323 | ;-----------------------
324 | INTELH:
325 | LD IX,BUF
326 | ;
327 | ; WAIT FOR RECORD MARK
328 | ;
329 | INTEL1:
330 | XOR A
331 | LD (IX+3),A ;CLEAR CHECKSUM
332 | CALL RXDATA ;WAIT FOR THE RECORD MARK
333 | CP ':' ;TO BE TRANSMITTED
334 | JR NZ,INTEL1 ;NOT RECORD MARK
335 | ;
336 | ; GET RECORD LENGTH
337 | ;
338 | CALL GETBYT
339 | LD (IX+0),A ;NUMBER OF DATA BYTES
340 | ;
341 | ; GET ADDRESS FIELD
342 | ;
343 | CALL GETBYT
344 | LD (IX+2),A ;LOAD ADDRESS HIGH BYTE
345 | CALL GETBYT
346 | LD (IX+1),A ;LOAD ADDRESS LOW BYTE
347 | ;
348 | ; GET RECORD TYPE
349 | ;
350 | CALL GETBYT
351 | JR NZ,INTEL4 ;END OF FILE RECORD
352 | ;
353 | ; READ IN THE DATA
354 | ;
355 | LD B,(IX+0) ;NUMBER OF DATA BYTES
356 | LD H,(IX+2) ;LOAD ADDRESS HIGH BYTE
357 | LD L,(IX+1) ;LOAD ADDRESS LOW BYTE
358 |
359 | INTEL2:
360 | CALL GETBYT ;GET DATA BYTE
361 | LD (HL),A ;STORE DATA BYTE
362 | INC HL
363 | DJNZ INTEL2 ;LOAD MORE BYTES
364 | ;
365 | ; GET CHECKSUM AND COMPARE
366 | ;
367 | LD A,(IX+3) ;CONVERT CHECKSUM TO
368 | NEG ;TWO'S COMPLEMENT
369 | LD (IX+4),A ;SAVE COMPUTED CHECKSUM
370 | CALL GETBYT
371 | LD (IX+3),A ;SAVE RECORD CHECKSUM
372 | CP (IX+4) ;COMPARE CHECKSUM
373 | JR Z,INTEL1 ;CHECKSUM OK,NEXT RECORD
374 | RET ;NZ=CHECKSUM ERROR
375 | ;
376 | ; END OF FILE RECORD
377 | ;
378 | INTEL4:
379 | LD A,(IX+3) ;CONVERT CHECKSUM TO
380 | NEG ;TWO'S COMPLEMENT
381 | LD (IX+4),A ;SAVE COMPUTED CHECKSUM
382 | CALL GETBYT
383 | LD (IX+3),A ;SAVE EOF CHECKSUM
384 | CP (IX+4) ;COMPARE CHECKSUM
385 | RET ;NZ=CHECKSUM ERROR
386 | ;--------------------------
387 | ; GET BYTE FROM SERIAL PORT
388 | ;--------------------------
389 | GETBYT:
390 | PUSH BC
391 | CALL RXDATA
392 | BIT 6,A
393 | JR Z,GETBT1
394 | ADD A,09H
395 | GETBT1:
396 | AND 0FH
397 | SLA A
398 | SLA A
399 | SLA A
400 | SLA A
401 | LD C,A
402 | ;
403 | ; GET LOW NYBBLE
404 | ;
405 | CALL RXDATA
406 | BIT 6,A
407 | JR Z,GETBT2
408 | ADD A,09H
409 | GETBT2 AND 0FH
410 | OR C
411 | LD B,A
412 | ADD A,(IX+3)
413 | LD (IX+3),A ;ADD TO CHECKSUM
414 | LD A,B
415 | AND A ;CLEAR CARRY
416 | POP BC
417 | RET
418 | .endif
419 |
420 | ; in this example code just wait for an INTEL Hex file download
421 | ;just going to send a char to let you know I'm here
422 | .if LOADER
423 |
424 | Load:
425 | ld a,'L' ; L for load
426 | call TxChar
427 | call INTELH
428 | jp z,RAMSTART ;assume the downloaded code starts here
429 | ld a,'0' ;0 is false
430 | call TxChar
431 | jr load ;if at first you don't succeed...
432 | .endif
433 |
434 | getchar:
435 | LD HL,(GETCVEC)
436 | JP (HL)
437 |
438 | putchar:
439 | PUSH HL
440 | LD HL,(PUTCVEC)
441 | EX (SP),HL
442 | RET
443 |
444 | RESET:
445 | ld SP,stack
446 | LD HL,IntRet
447 | LD (RST08),HL
448 | LD (RST10),HL
449 | LD (RST18),HL
450 | LD (RST20),HL
451 | LD (RST28),HL
452 | LD (RST30),HL
453 | LD (INTVEC),HL
454 | LD (NMIVEC),HL
455 |
456 | LD HL,RXDATA
457 | LD (GETCVEC),HL
458 | LD HL,TXDATA
459 | LD (PUTCVEC),HL
460 |
461 | .if TEC_1
462 | .if BITBANG = 0
463 |
464 | ld a,MRESET
465 | out (CONTROL),a ;reset the ACIA
466 |
467 | .endif
468 | .endif
469 |
470 | call PWRUP
471 | IM 1
472 | EI
473 |
474 | .if TEC_1
475 | .if BITBANG
476 |
477 | ;inline serial initialisation
478 | LD A,$40
479 | LD C,SCAN
480 | OUT (C),A
481 | LD HL,B4800
482 | LD (BAUD),HL
483 |
484 | .else ;6850
485 |
486 | ld a,RTSLID+F8N2+DIV_64
487 | out (CONTROL),a ;initialise ACIA 8 bit word, No parity 2 stop divide by 64 for 115200 baud
488 |
489 | .endif
490 | .endif
491 |
492 |
493 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/MINT-macros.asm:
--------------------------------------------------------------------------------
1 | empty_:
2 | DB ";"
3 |
4 | backsp_:
5 | DB "\\c@0=0=(1_\\c\\+`\b \b`);"
6 |
7 | reedit_:
8 | DB "\\e\\@\\Z;"
9 |
10 | edit_:
11 | .cstr "`?`\\K\\N`> `\\^A-\\Z;"
12 |
13 | list_:
14 | .cstr "\\N26(\\i@\\Z\\c@0>(\\N))\\N`> `;"
15 |
16 | printStack_:
17 | .cstr "`=> `\\P\\N\\N`> `;"
18 |
19 | toggleBase_:
20 | .cstr "\\b@0=\\b!;"
21 |
22 |
--------------------------------------------------------------------------------
/MINT.asm:
--------------------------------------------------------------------------------
1 | ; *************************************************************************
2 | ;
3 | ; MINT Minimal Interpreter for the Z80
4 | ;
5 | ; Ken Boak, John Hardy and Craig Jones.
6 | ;
7 | ; GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
8 | ;
9 | ; see the LICENSE file in this repo for more information
10 | ;
11 | ; *****************************************************************************
12 |
13 | DSIZE EQU $80
14 | RSIZE EQU $80
15 | TIBSIZE EQU $100
16 | TRUE EQU 1
17 | FALSE EQU 0
18 |
19 | NUMGRPS EQU 5
20 | GRPSIZE EQU $40
21 |
22 | ; **************************************************************************
23 | ; Page 0 Initialisation
24 | ; **************************************************************************
25 |
26 | .ORG ROMSTART + $180
27 |
28 | start:
29 | mint:
30 | LD SP,DSTACK
31 | CALL initialize
32 | CALL printStr
33 | .cstr "MINT V1.0\r\n"
34 | JR interpret
35 |
36 | ; ***********************************************************************
37 | ; Initial values for user mintVars
38 | ; ***********************************************************************
39 | iSysVars:
40 | DW dStack ; a vS0
41 | DW FALSE ; b vBase16
42 | DW 0 ; c vTIBPtr
43 | DW DEFS ; d vDEFS
44 | DW 0 ; e vEdited the last command to be edited
45 | DW 0 ; f
46 | DW 0 ; g
47 | DW HEAP ; h vHeapPtr
48 |
49 | initialize:
50 | LD IX,RSTACK
51 | LD IY,NEXT ; IY provides a faster jump to NEXT
52 | LD HL,iSysVars
53 | LD DE,sysVars
54 | LD BC,8 * 2
55 | LDIR
56 |
57 | LD HL,DEFS
58 | LD B,GRPSIZE/2 * NUMGRPS
59 | init1:
60 | LD (HL),lsb(empty_)
61 | INC HL
62 | LD (HL),msb(empty_)
63 | INC HL
64 | DJNZ init1
65 | RET
66 |
67 | macro: ;=25
68 | LD (vTIBPtr),BC
69 | LD HL,ctrlCodes
70 | ADD A,L
71 | LD L,A
72 | LD E,(HL)
73 | LD D,msb(macros)
74 | PUSH DE
75 | call ENTER
76 | .cstr "\\G"
77 | LD BC,(vTIBPtr)
78 | JR interpret2
79 |
80 | interpret:
81 | call ENTER
82 | .cstr "\\N`> `"
83 |
84 | interpret1: ; used by tests
85 | LD BC,0 ; load BC with offset into TIB
86 | LD (vTIBPtr),BC
87 |
88 | interpret2: ; calc nesting (a macro might have changed it)
89 | LD E,0 ; initilize nesting value
90 | PUSH BC ; save offset into TIB,
91 | ; BC is also the count of chars in TIB
92 | LD HL,TIB ; HL is start of TIB
93 | JR interpret4
94 |
95 | interpret3:
96 | LD A,(HL) ; A = char in TIB
97 | INC HL ; inc pointer into TIB
98 | DEC BC ; dec count of chars in TIB
99 | call nesting ; update nesting value
100 |
101 | interpret4:
102 | LD A,C ; is count zero?
103 | OR B
104 | JR NZ, interpret3 ; if not loop
105 | POP BC ; restore offset into TIB
106 | ; *******************************************************************
107 | ; Wait for a character from the serial input (keyboard)
108 | ; and store it in the text buffer. Keep accepting characters,
109 | ; increasing the instruction pointer BC - until a newline received.
110 | ; *******************************************************************
111 |
112 | waitchar:
113 | CALL getchar ; loop around waiting for character
114 | CP $20
115 | JR NC,waitchar1
116 | CP $0 ; is it end of string?
117 | JR Z,waitchar4
118 | CP '\r' ; carriage return?
119 | JR Z,waitchar3
120 | LD D,0
121 | JR macro
122 |
123 | waitchar1:
124 | LD HL,TIB
125 | ADD HL,BC
126 | LD (HL),A ; store the character in textbuf
127 | INC BC
128 | CALL putchar ; echo character to screen
129 | CALL nesting
130 | JR waitchar ; wait for next character
131 |
132 | waitchar3:
133 | LD HL,TIB
134 | ADD HL,BC
135 | LD (HL),"\r" ; store the crlf in textbuf
136 | INC HL
137 | LD (HL),"\n"
138 | INC HL ; ????
139 | INC BC
140 | INC BC
141 | CALL crlf ; echo character to screen
142 | LD A,E ; if zero nesting append and ETX after \r
143 | OR A
144 | JR NZ,waitchar
145 | LD (HL),$03 ; store end of text ETX in text buffer
146 | INC BC
147 |
148 | waitchar4:
149 | LD (vTIBPtr),BC
150 | LD BC,TIB ; Instructions stored on heap at address HERE
151 | DEC BC
152 | JP NEXT
153 |
154 | ; ********************************************************************************
155 | ;
156 | ; Dispatch Routine.
157 | ;
158 | ; Get the next character and form a 1 byte jump address
159 | ;
160 | ; This target jump address is loaded into HL, and using JP (HL) to quickly
161 | ; jump to the selected function.
162 | ;
163 | ; Individual handler routines will deal with each category:
164 | ;
165 | ; 1. Detect characters A-Z and jump to the User Command handler routine
166 | ;
167 | ; 2. Detect characters a-z and jump to the variable handler routine
168 | ;
169 | ; 3. All other characters are punctuation and cause a jump to the associated
170 | ; primitive code.
171 | ;
172 | ; Instruction Pointer IP BC is incremented
173 | ;
174 | ; *********************************************************************************
175 |
176 | NEXT: ; 9
177 | INC BC ; 6t Increment the IP
178 | LD A, (BC) ; 7t Get the next character and dispatch
179 | LD L,A ; 4t Index into table
180 | LD H,msb(opcodes) ; 7t Start address of jump table
181 | LD L,(HL) ; 7t get low jump address
182 | LD H,msb(page4) ; 7t Load H with the 1st page address
183 | JP (HL) ; 4t Jump to routine
184 |
185 | ; ARRAY compilation routine
186 | compNEXT: ;=20
187 | POP DE ; DE = return address
188 | LD HL,(vHeapPtr) ; load heap ptr
189 | LD (HL),E ; store lsb
190 | LD A,(vByteMode)
191 | INC HL
192 | OR A
193 | JR NZ,compNext1
194 | LD (HL),D
195 | INC HL
196 | compNext1:
197 | LD (vHeapPtr),HL ; save heap ptr
198 | JR NEXT
199 |
200 | ; **************************************************************************
201 | ; calculate nesting value
202 | ; A is char to be tested,
203 | ; E is the nesting value (initially 0)
204 | ; E is increased by ( and [
205 | ; E is decreased by ) and ]
206 | ; E has its bit 7 toggled by `
207 | ; limited to 127 levels
208 | ; **************************************************************************
209 |
210 | nesting: ;= 44
211 | CP '`'
212 | JR NZ,nesting1
213 | BIT 7,E
214 | JR Z,nesting1a
215 | RES 7,E
216 | RET
217 | nesting1a:
218 | SET 7,E
219 | RET
220 | nesting1:
221 | BIT 7,E
222 | RET NZ
223 | CP ':'
224 | JR Z,nesting2
225 | CP '['
226 | JR Z,nesting2
227 | CP '('
228 | JR NZ,nesting3
229 | nesting2:
230 | INC E
231 | RET
232 | nesting3:
233 | CP ';'
234 | JR Z,nesting4
235 | CP ']'
236 | JR Z,nesting4
237 | CP ')'
238 | RET NZ
239 | nesting4:
240 | DEC E
241 | RET
242 |
243 | prompt: ;=9
244 | call printStr
245 | .cstr "\r\n> "
246 | RET
247 |
248 | ; **************************************************************************
249 | ; Macros must be written in Mint and end with ;
250 | ; this code must not span pages
251 | ; **************************************************************************
252 | macros:
253 |
254 | .include "MINT-macros.asm"
255 |
256 |
257 | ; **************************************************************************
258 | ; Page 2 Jump Tables
259 | ; **************************************************************************
260 | .align $100
261 | opcodes:
262 | ; ***********************************************************************
263 | ; Initial values for user mintVars
264 | ; ***********************************************************************
265 | DB lsb(exit_) ; NUL
266 | DB lsb(nop_) ; SOH
267 | DB lsb(nop_) ; STX
268 | DB lsb(etx_) ; ETX
269 | DB lsb(nop_) ; EOT
270 | DB lsb(nop_) ; ENQ
271 | DB lsb(nop_) ; ACK
272 | DB lsb(nop_) ; BEL
273 | DB lsb(nop_) ; BS
274 | DB lsb(nop_) ; TAB
275 | DB lsb(nop_) ; LF
276 | DB lsb(nop_) ; VT
277 | DB lsb(nop_) ; FF
278 | DB lsb(nop_) ; CR
279 | DB lsb(nop_) ; SO
280 | DB lsb(nop_) ; SI
281 | DB lsb(nop_) ; DLE
282 | DB lsb(nop_) ; DC1
283 | DB lsb(nop_) ; DC2
284 | DB lsb(nop_) ; DC3
285 | DB lsb(nop_) ; DC4
286 | DB lsb(nop_) ; NAK
287 | DB lsb(nop_) ; SYN
288 | DB lsb(nop_) ; ETB
289 | DB lsb(nop_) ; CAN
290 | DB lsb(nop_) ; EM
291 | DB lsb(nop_) ; SUB
292 | DB lsb(nop_) ; ESC
293 | DB lsb(nop_) ; FS
294 | DB lsb(nop_) ; GS
295 | DB lsb(nop_) ; RS
296 | DB lsb(nop_) ; US
297 | DB lsb(nop_) ; SP
298 | DB lsb(store_) ; !
299 | DB lsb(dup_) ; "
300 | DB lsb(hex_) ; #
301 | DB lsb(swap_) ; $
302 | DB lsb(over_) ; %
303 | DB lsb(and_) ; &
304 | DB lsb(drop_) ; '
305 | DB lsb(begin_) ; (
306 | DB lsb(again_) ; )
307 | DB lsb(mul_) ; *
308 | DB lsb(add_) ; +
309 | DB lsb(hdot_) ; ,
310 | DB lsb(sub_) ; -
311 | DB lsb(dot_) ; .
312 | DB lsb(div_) ; /
313 | DB lsb(num_) ; 0
314 | DB lsb(num_) ; 1
315 | DB lsb(num_) ; 2
316 | DB lsb(num_) ; 3
317 | DB lsb(num_) ; 4
318 | DB lsb(num_) ; 5
319 | DB lsb(num_) ; 6
320 | DB lsb(num_) ; 7
321 | DB lsb(num_) ; 8
322 | DB lsb(num_) ; 9
323 | DB lsb(def_) ; :
324 | DB lsb(ret_) ; ;
325 | DB lsb(lt_) ; <
326 | DB lsb(eq_) ; =
327 | DB lsb(gt_) ; >
328 | DB lsb(getRef_) ; ?
329 | DB lsb(fetch_) ; @
330 | DB lsb(call_) ; A
331 | DB lsb(call_) ; B
332 | DB lsb(call_) ; C
333 | DB lsb(call_) ; D
334 | DB lsb(call_) ; E
335 | DB lsb(call_) ; F
336 | DB lsb(call_) ; G
337 | DB lsb(call_) ; H
338 | DB lsb(call_) ; I
339 | DB lsb(call_) ; J
340 | DB lsb(call_) ; K
341 | DB lsb(call_) ; L
342 | DB lsb(call_) ; M
343 | DB lsb(call_) ; N
344 | DB lsb(call_) ; O
345 | DB lsb(call_) ; P
346 | DB lsb(call_) ; Q
347 | DB lsb(call_) ; R
348 | DB lsb(call_) ; S
349 | DB lsb(call_) ; T
350 | DB lsb(call_) ; U
351 | DB lsb(call_) ; V
352 | DB lsb(call_) ; W
353 | DB lsb(call_) ; X
354 | DB lsb(call_) ; Y
355 | DB lsb(call_) ; Z
356 | DB lsb(arrDef_) ; [
357 | DB lsb(alt_) ; \
358 | DB lsb(arrEnd_) ; ]
359 | DB lsb(xor_) ; ^
360 | DB lsb(neg_) ; _
361 | DB lsb(str_) ; `
362 | DB lsb(var_) ; a
363 | DB lsb(var_) ; b
364 | DB lsb(var_) ; c
365 | DB lsb(var_) ; d
366 | DB lsb(var_) ; e
367 | DB lsb(var_) ; f
368 | DB lsb(var_) ; g
369 | DB lsb(var_) ; h
370 | DB lsb(var_) ; i
371 | DB lsb(var_) ; j
372 | DB lsb(var_) ; k
373 | DB lsb(var_) ; l
374 | DB lsb(var_) ; m
375 | DB lsb(var_) ; n
376 | DB lsb(var_) ; o
377 | DB lsb(var_) ; p
378 | DB lsb(var_) ; q
379 | DB lsb(var_) ; r
380 | DB lsb(var_) ; s
381 | DB lsb(var_) ; t
382 | DB lsb(var_) ; u
383 | DB lsb(var_) ; v
384 | DB lsb(var_) ; w
385 | DB lsb(var_) ; x
386 | DB lsb(var_) ; y
387 | DB lsb(var_) ; z
388 | DB lsb(shl_) ; {
389 | DB lsb(or_) ; |
390 | DB lsb(shr_) ; }
391 | DB lsb(inv_) ; ~
392 | DB lsb(nop_) ; backspace
393 |
394 |
395 | ; ***********************************************************************
396 | ; Alternate function codes
397 | ; ***********************************************************************
398 | ctrlCodes:
399 | altCodes:
400 | DB lsb(empty_) ; NUL ^@
401 | DB lsb(empty_) ; SOH ^A
402 | DB lsb(toggleBase_) ; STX ^B
403 | DB lsb(empty_) ; ETX ^C
404 | DB lsb(empty_) ; EOT ^D
405 | DB lsb(edit_) ; ENQ ^E
406 | DB lsb(empty_) ; ACK ^F
407 | DB lsb(empty_) ; BEL ^G
408 | DB lsb(backsp_) ; BS ^H
409 | DB lsb(empty_) ; TAB ^I
410 | DB lsb(reedit_) ; LF ^J
411 | DB lsb(empty_) ; VT ^K
412 | DB lsb(list_) ; FF ^L
413 | DB lsb(empty_) ; CR ^M
414 | DB lsb(empty_) ; SO ^N
415 | DB lsb(empty_) ; SI ^O
416 | DB lsb(printStack_) ; DLE ^P
417 | DB lsb(empty_) ; DC1 ^Q
418 | DB lsb(empty_) ; DC2 ^R
419 | DB lsb(empty_) ; DC3 ^S
420 | DB lsb(empty_) ; DC4 ^T
421 | DB lsb(empty_) ; NAK ^U
422 | DB lsb(empty_) ; SYN ^V
423 | DB lsb(empty_) ; ETB ^W
424 | DB lsb(empty_) ; CAN ^X
425 | DB lsb(empty_) ; EM ^Y
426 | DB lsb(empty_) ; SUB ^Z
427 | DB lsb(empty_) ; ESC ^[
428 | DB lsb(empty_) ; FS ^\
429 | DB lsb(empty_) ; GS ^]
430 | DB lsb(empty_) ; RS ^^
431 | DB lsb(empty_) ; US ^_)
432 | DB lsb(aNop_) ; SP ^`
433 | DB lsb(cStore_) ; !
434 | DB lsb(aNop_) ; "
435 | DB lsb(aNop_) ; #
436 | DB lsb(aNop_) ; $ ( -- adr ) text input ptr
437 | DB lsb(aNop_) ; %
438 | DB lsb(aNop_) ; &
439 | DB lsb(aNop_) ; '
440 | DB lsb(ifte_) ; ( ( b -- )
441 | DB lsb(aNop_) ; )
442 | DB lsb(aNop_) ; *
443 | DB lsb(incr_) ; + ( adr -- ) decrements variable at address
444 | DB lsb(aNop_) ; ,
445 | DB lsb(aNop_) ; -
446 | DB lsb(aNop_) ; .
447 | DB lsb(aNop_) ; /
448 | DB lsb(aNop_) ; 0
449 | DB lsb(aNop_) ; 1
450 | DB lsb(aNop_) ; 2
451 | DB lsb(aNop_) ; 3
452 | DB lsb(aNop_) ; 4
453 | DB lsb(aNop_) ; 5
454 | DB lsb(aNop_) ; 6
455 | DB lsb(aNop_) ; 7
456 | DB lsb(aNop_) ; 8
457 | DB lsb(aNop_) ; 9
458 | DB lsb(aNop_) ; : start defining a macro
459 | DB lsb(aNop_) ; ;
460 | DB lsb(aNop_) ; <
461 | DB lsb(aNop_) ; =
462 | DB lsb(aNop_) ; >
463 | DB lsb(aNop_) ; ?
464 | DB lsb(cFetch_) ; @
465 | DB lsb(aNop_) ; A
466 | DB lsb(break_) ; B
467 | DB lsb(nop_) ; C
468 | DB lsb(depth_) ; D ( -- val ) depth of data stack
469 | DB lsb(emit_) ; E ( val -- ) emits a char to output
470 | DB lsb(aNop_) ; F
471 | DB lsb(go_) ; G ( -- ? ) execute mint definition
472 | DB lsb(aNop_) ; H
473 | DB lsb(inPort_) ; I ( port -- val )
474 | DB lsb(aNop_) ; J
475 | DB lsb(key_) ; K ( -- val ) read a char from input
476 | DB lsb(aNop_) ; L
477 | DB lsb(aNop_) ; M
478 | DB lsb(newln_) ; N ; prints a newline to output
479 | DB lsb(outPort_) ; O ( val port -- )
480 | DB lsb(printStk_) ; P ( -- ) non-destructively prints stack
481 | DB lsb(aNop_) ; Q quits from Mint REPL
482 | DB lsb(rot_) ; R ( a b c -- b c a )
483 | DB lsb(aNop_) ; S
484 | DB lsb(aNop_) ; T
485 | DB lsb(aNop_) ; U
486 | DB lsb(aNop_) ; V
487 | DB lsb(aNop_) ; W ; ( b -- ) if false, skip to end of loop
488 | DB lsb(exec_) ; X
489 | DB lsb(aNop_) ; Y
490 | DB lsb(editDef_) ; Z
491 | DB lsb(cArrDef_) ; [
492 | DB lsb(comment_) ; \ comment text, skips reading until end of line
493 | DB lsb(aNop_) ; ]
494 | DB lsb(charCode_) ; ^
495 | DB lsb(aNop_) ; _
496 | DB lsb(aNop_) ; `
497 | DB lsb(sysVar_) ; a ; start of data stack variable
498 | DB lsb(sysVar_) ; b ; base16 variable
499 | DB lsb(sysVar_) ; c ; TIBPtr variable
500 | DB lsb(sysVar_) ; d
501 | DB lsb(sysVar_) ; e
502 | DB lsb(sysVar_) ; f
503 | DB lsb(sysVar_) ; g
504 | DB lsb(sysVar_) ; h ; heap ptr variable
505 | DB lsb(i_) ; i ; returns index variable of current loop
506 | DB lsb(j_) ; j ; returns index variable of outer loop
507 | DB lsb(sysVar_) ; k
508 | DB lsb(sysVar_) ; l
509 | DB lsb(sysVar_) ; m ( a b -- c ) return the minimum value
510 | DB lsb(sysVar_) ; n
511 | DB lsb(sysVar_) ; o
512 | DB lsb(sysVar_) ; p
513 | DB lsb(sysVar_) ; q
514 | DB lsb(sysVar_) ; r
515 | DB lsb(sysVar_) ; s
516 | DB lsb(sysVar_) ; t
517 | DB lsb(sysVar_) ; u
518 | DB lsb(sysVar_) ; v
519 | DB lsb(sysVar_) ; w
520 | DB lsb(sysVar_) ; x
521 | DB lsb(sysVar_) ; y
522 | DB lsb(sysVar_) ; z
523 | DB lsb(group_) ; {
524 | DB lsb(aNop_) ; |
525 | DB lsb(endGroup_) ; }
526 | DB lsb(aNop_) ; ~
527 | DB lsb(aNop_) ; BS
528 |
529 |
530 | ; **********************************************************************
531 | ; Page 4 primitive routines
532 | ; **********************************************************************
533 | .align $100
534 | page4:
535 |
536 | alt_:
537 | JP alt
538 |
539 | and_:
540 | POP DE ; 10t Bitwise AND the top 2 elements of the stack
541 | POP HL ; 10t
542 | LD A,E ; 4t
543 | AND L ; 4t
544 | LD L,A ; 4t
545 | LD A,D ; 4t
546 | AND H ; 4t
547 | and1:
548 | LD H,A ; 4t
549 | PUSH HL ; 11t
550 | JP (IY) ; 8t
551 |
552 | ; 63t
553 | or_:
554 | POP DE ; Bitwise OR the top 2 elements of the stack
555 | POP HL
556 | LD A,E
557 | OR L
558 | LD L,A
559 | LD A,D
560 | OR H
561 | JR and1
562 |
563 | xor_:
564 | POP DE ; Bitwise XOR the top 2 elements of the stack
565 | xor1:
566 | POP HL
567 | LD A,E
568 | XOR L
569 | LD L,A
570 | LD A,D
571 | XOR H
572 | JR and1
573 |
574 | inv_: ; Bitwise INVert the top member of the stack
575 | LD DE, $FFFF ; by xoring with $FFFF
576 | JR xor1
577 |
578 | add_: ; Add the top 2 members of the stack
579 | POP DE ; 10t
580 | POP HL ; 10t
581 | ADD HL,DE ; 11t
582 | PUSH HL ; 11t
583 | JP (IY) ; 8t
584 | ; 50t
585 |
586 | arrDef_:
587 | arrDef: ;= 18
588 | LD A,FALSE
589 | arrDef1:
590 | LD IY,compNEXT
591 | LD (vByteMode),A
592 | LD HL,(vHeapPtr) ; HL = heap ptr
593 | CALL rpush ; save start of array \[ \]
594 | JP NEXT ; hardwired to NEXT
595 |
596 | arrEnd_: JP arrEnd
597 | begin_: JP begin
598 | call_:
599 | LD HL,BC
600 | CALL rpush ; save Instruction Pointer
601 | LD A,(BC)
602 | CALL lookupDef1
603 | LD C,(HL)
604 | INC HL
605 | LD B,(HL)
606 | DEC BC
607 | JP (IY) ; Execute code from User def
608 |
609 |
610 | def_: JP def
611 |
612 | hdot_: ; print hexadecimal
613 | POP HL
614 | CALL printhex
615 | JR dot2
616 | dot_:
617 | POP HL
618 | CALL printdec
619 | dot2:
620 | LD A,' '
621 | CALL writeChar1
622 | JP (IY)
623 |
624 | drop_: ; Discard the top member of the stack
625 | POP HL
626 | JP (IY)
627 |
628 | dup_:
629 | POP HL ; Duplicate the top member of the stack
630 | PUSH HL
631 | PUSH HL
632 | JP (IY)
633 | etx_:
634 | etx:
635 | LD HL,-DSTACK
636 | ADD HL,SP
637 | JR NC,etx1
638 | LD SP,DSTACK
639 | etx1:
640 | JP interpret
641 |
642 |
643 | exit_:
644 | INC BC
645 | LD DE,BC
646 | CALL rpop ; Restore Instruction pointer
647 | LD BC,HL
648 | EX DE,HL
649 | JP (HL)
650 |
651 | fetch_: ; Fetch the value from the address placed on the top of the stack
652 | POP HL ; 10t
653 | fetch1:
654 | LD E,(HL) ; 7t
655 | INC HL ; 6t
656 | LD D,(HL) ; 7t
657 | PUSH DE ; 11t
658 | JP (IY) ; 8t
659 |
660 | hex_: JP hex
661 |
662 | nop_: JP NEXT ; hardwire white space to always go to NEXT (important for arrays)
663 |
664 | num_:
665 | JP number
666 |
667 | over_:
668 | POP HL ; Duplicate 2nd element of the stack
669 | POP DE
670 | PUSH DE
671 | PUSH HL
672 | PUSH DE ; And push it to top of stack
673 | JP (IY)
674 |
675 | ret_:
676 | CALL rpop ; Restore Instruction pointer
677 | LD BC,HL
678 | JP (IY)
679 |
680 | store_: ; Store the value at the address placed on the top of the stack
681 | POP HL ; 10t
682 | POP DE ; 10t
683 | LD (HL),E ; 7t
684 | INC HL ; 6t
685 | LD (HL),D ; 7t
686 | JP (IY) ; 8t
687 | ; 48t
688 | ; $ swap ; a b -- b a Swap the top 2 elements of the stack
689 | swap_:
690 | POP HL
691 | EX (SP),HL
692 | PUSH HL
693 | JP (IY)
694 |
695 | ; Left shift { is multply by 2
696 | shl_:
697 | POP HL ; Duplicate the top member of the stack
698 | ADD HL,HL
699 | PUSH HL ; shift left fallthrough into add_
700 | JP (IY) ; 8t
701 |
702 | ; Right shift } is a divide by 2
703 |
704 | shr_:
705 | POP HL ; Get the top member of the stack
706 | shr1:
707 | SRL H
708 | RR L
709 | PUSH HL
710 | JP (IY) ; 8t
711 |
712 | neg_: LD HL, 0 ; NEGate the value on top of stack (2's complement)
713 | POP DE ; 10t
714 | JR SUB_2 ; use the SUBtract routine
715 |
716 | sub_: ; Subtract the value 2nd on stack from top of stack
717 |
718 | POP DE ; 10t
719 | sub_1: POP HL ; 10t Entry point for INVert
720 | sub_2: AND A ; 4t Entry point for NEGate
721 | SBC HL,DE ; 15t
722 | PUSH HL ; 11t
723 | JP (IY) ; 8t
724 | ; 58t
725 | eq_: POP HL
726 | POP DE
727 | AND A ; reset the carry flag
728 | SBC HL,DE ; only equality sets HL=0 here
729 | JR Z, equal
730 | LD HL, 0
731 | JR less ; HL = 1
732 |
733 | getRef_:
734 | JP getRef
735 | gt_: POP DE
736 | POP HL
737 | JR cmp_
738 |
739 | lt_: POP HL
740 | POP DE
741 | cmp_: AND A ; reset the carry flag
742 | SBC HL,DE ; only equality sets HL=0 here
743 | JR Z,less ; equality returns 0 KB 25/11/21
744 | LD HL, 0
745 | JP M,less
746 | equal: INC L ; HL = 1
747 | less:
748 | PUSH HL
749 | JP (IY)
750 |
751 | var_:
752 | LD A,(BC)
753 |
754 | SUB "a" - ((VARS - mintVars)/2)
755 | ADD A,A
756 | LD L,A
757 | LD H,msb(mintVars)
758 |
759 | PUSH HL
760 | JP (IY)
761 |
762 | div_:
763 | JR div
764 | mul_:
765 | JP mul
766 |
767 | again_:
768 | JP again
769 | str_:
770 | str: ;= 15
771 | INC BC
772 |
773 | nextchar:
774 | LD A, (BC)
775 | INC BC
776 | CP "`" ; ` is the string terminator
777 | JR Z,str2
778 | CALL putchar
779 | JR nextchar
780 |
781 | str2:
782 | DEC BC
783 | JP (IY)
784 |
785 | ;*******************************************************************
786 | ; Page 5 primitive routines
787 | ;*******************************************************************
788 | ;falls through
789 |
790 | getRef: ;= 8
791 | INC BC
792 | LD A,(BC)
793 | CALL lookupDef
794 | JP fetch1
795 |
796 | alt: ;= 11
797 | INC BC
798 | LD A,(BC)
799 | LD HL,altCodes
800 | ADD A,L
801 | LD L,A
802 | LD L,(HL) ; 7t get low jump address
803 | LD H, msb(page6) ; Load H with the 5th page address
804 | JP (HL) ; 4t Jump to routine
805 |
806 | ; ********************************************************************
807 | ; 16-bit multiply
808 | mul: ;=19
809 | POP DE ; get first value
810 | POP HL
811 | PUSH BC ; Preserve the IP
812 | LD B,H ; BC = 2nd value
813 | LD C,L
814 |
815 | LD HL,0
816 | LD A,16
817 | Mul_Loop_1:
818 | ADD HL,HL
819 | RL E
820 | RL D
821 | JR NC,$+6
822 | ADD HL,BC
823 | JR NC,$+3
824 | INC DE
825 | DEC A
826 | JR NZ,Mul_Loop_1
827 |
828 | POP BC ; Restore the IP
829 | PUSH HL ; Put the product on the stack - stack bug fixed 2/12/21
830 | JP (IY)
831 |
832 | ; ********************************************************************
833 | ; 16-bit division subroutine.
834 | ;
835 | ; BC: divisor, DE: dividend, HL: remainder
836 |
837 | ; *********************************************************************
838 | ; This divides DE by BC, storing the result in DE, remainder in HL
839 | ; *********************************************************************
840 |
841 | ; 1382 cycles
842 | ; 35 bytes (reduced from 48)
843 |
844 |
845 | div: ;=24
846 | POP DE ; get first value
847 | POP HL ; get 2nd value
848 | PUSH BC ; Preserve the IP
849 | LD B,H ; BC = 2nd value
850 | LD C,L
851 |
852 | ld hl,0 ; Zero the remainder
853 | ld a,16 ; Loop counter
854 |
855 | div_loop: ;shift the bits from BC (numerator) into HL (accumulator)
856 | sla c
857 | rl b
858 | adc hl,hl
859 |
860 | sbc hl,de ;Check if remainder >= denominator (HL>=DE)
861 | jr c,div_adjust
862 | inc c
863 | jr div_done
864 |
865 | div_adjust: ; remainder is not >= denominator, so we have to add DE back to HL
866 | add hl,de
867 |
868 | div_done:
869 | dec a
870 | jr nz,div_loop
871 |
872 | LD D,B ; Result from BC to DE
873 | LD E,C
874 |
875 | div_end:
876 | POP BC ; Restore the IP
877 |
878 | PUSH DE ; Push Result
879 | PUSH HL ; Push remainder
880 |
881 | JP (IY)
882 |
883 | ; **************************************************************************
884 | ; def is used to create a colon definition
885 | ; When a colon is detected, the next character (usually uppercase alpha)
886 | ; is looked up in the vector table to get its associated code field address
887 | ; This CFA is updated to point to the character after uppercase alpha
888 | ; The remainder of the characters are then skipped until after a semicolon
889 | ; is found.
890 | ; ***************************************************************************
891 | ;= 31
892 | def: ; Create a colon definition
893 | INC BC
894 | LD A,(BC) ; Get the next character
895 | INC BC
896 | CALL lookupDef
897 | LD DE,(vHeapPtr) ; start of defintion
898 | LD (HL),E ; Save low byte of address in CFA
899 | INC HL
900 | LD (HL),D ; Save high byte of address in CFA+1
901 | def1: ; Skip to end of definition
902 | LD A,(BC) ; Get the next character
903 | INC BC ; Point to next character
904 | LD (DE),A
905 | INC DE
906 | CP ";" ; Is it a semicolon
907 | JR Z, def2 ; end the definition
908 | JR def1 ; get the next element
909 |
910 | def2:
911 | DEC BC
912 | def3:
913 | LD (vHeapPtr),DE ; bump heap ptr to after definiton
914 | JP (IY)
915 |
916 | ; ********************************************************************************
917 | ; Number Handling Routine - converts numeric ascii string to a 16-bit number in HL
918 | ; Read the first character.
919 | ;
920 | ; Number characters ($30 to $39) are converted to digits by subtracting $30
921 | ; and then added into the L register. (HL forms a 16-bit accumulator)
922 | ; Fetch the next character, if it is a number, multiply contents of HL by 10
923 | ; and then add in the next digit. Repeat this until a non-number character is
924 | ; detected. Add in the final digit so that HL contains the converted number.
925 | ; Push HL onto the stack and proceed to the dispatch routine.
926 | ; ********************************************************************************
927 |
928 | number: ;= 23
929 | LD HL,$0000 ; 10t Clear HL to accept the number
930 | LD A,(BC) ; 7t Get the character which is a numeral
931 |
932 | number1: ; corrected KB 24/11/21
933 |
934 | SUB $30 ; 7t Form decimal digit
935 | ADD A,L ; 4t Add into bottom of HL
936 | LD L,A ; 4t
937 | LD A,00 ; 4t Clear A
938 | ADC A,H ; Add with carry H-reg
939 | LD H,A ; Put result in H-reg
940 |
941 | INC BC ; 6t Increment IP
942 | LD A, (BC) ; 7t and get the next character
943 | CP $30 ; 7t Less than $30
944 | JR C, endnum ; 7/12t Not a number / end of number
945 | CP $3A ; 7t Greater or equal to $3A
946 | JR NC, endnum ; 7/12t Not a number / end of number
947 |
948 | times10: ; Multiply digit(s) in HL by 10
949 | ADD HL,HL ; 11t 2X
950 | LD E,L ; 4t LD DE,HL
951 | LD D,H ; 4t
952 | ADD HL,HL ; 11t 4X
953 | ADD HL,HL ; 11t 8X
954 | ADD HL,DE ; 11t 2X + 8X = 10X
955 | ; 52t cycles
956 |
957 | JR number1
958 |
959 | endnum:
960 | DEC BC
961 | PUSH HL ; 11t Put the number on the stack
962 | JP (IY) ; and process the next character
963 |
964 |
965 | ; *************************************
966 | ; Loop Handling Code
967 | ; *************************************
968 | ;= 23
969 | begin: ; Left parentesis begins a loop
970 | POP HL
971 | LD A,L ; zero?
972 | OR H
973 | JR Z,begin1
974 |
975 | DEC HL
976 | LD DE,-6
977 | ADD IX,DE
978 | LD (IX+0),0 ; loop var
979 | LD (IX+1),0
980 | LD (IX+2),L ; loop limit
981 | LD (IX+3),H
982 | LD (IX+4),C ; loop address
983 | LD (IX+5),B
984 |
985 | JP (IY)
986 | begin1:
987 | LD E,1
988 | begin2:
989 | INC BC
990 | LD A,(BC)
991 | CALL nesting
992 | XOR A
993 | OR E
994 | JR NZ,begin2
995 | begin3:
996 | JP (IY)
997 |
998 | again:
999 | LD E,(IX+0) ; peek loop var
1000 | LD D,(IX+1)
1001 |
1002 | LD A,D ; check if IFTEMode
1003 | AND E
1004 | INC A
1005 | JR NZ,again1
1006 | INC DE
1007 | PUSH DE ; push FALSE condition
1008 | LD DE,2
1009 | JR again3 ; drop IFTEMode
1010 |
1011 | again1:
1012 | LD L,(IX+2) ; peek loop limit
1013 | LD H,(IX+3)
1014 | OR A
1015 | SBC HL,DE
1016 | JR Z,again2
1017 | INC DE
1018 | LD (IX+0),E ; poke loop var
1019 | LD (IX+1),D
1020 | LD C,(IX+4) ; peek loop address
1021 | LD B,(IX+5)
1022 | JP (IY)
1023 | again2:
1024 | LD DE,6 ; drop loop frame
1025 | again3:
1026 | ADD IX,DE
1027 | JP (IY)
1028 |
1029 | ; **************************************************************************
1030 | ; Page 6 Alt primitives
1031 | ; **************************************************************************
1032 | .align $100
1033 | page6:
1034 |
1035 | cArrDef_: ; define a byte array
1036 | LD A,TRUE
1037 | JP arrDef1
1038 |
1039 | cFetch_:
1040 | POP HL ; 10t
1041 | LD D,0 ; 7t
1042 | LD E,(HL) ; 7t
1043 | PUSH DE ; 11t
1044 | anop_:
1045 | JP (IY) ; 8t
1046 | ; 49t
1047 | charCode_:
1048 | INC BC
1049 | LD A,(BC)
1050 | LD H,0
1051 | LD L,A
1052 | PUSH HL
1053 | JP (IY)
1054 |
1055 | comment_:
1056 | INC BC ; point to next char
1057 | LD A,(BC)
1058 | CP "\r" ; terminate at cr
1059 | JR NZ,comment_
1060 | ; CP "\n" ; terminate at lf
1061 | ; JR NZ,comment_
1062 | DEC BC
1063 | JP (IY)
1064 |
1065 | cStore_:
1066 | POP HL ; 10t
1067 | POP DE ; 10t
1068 | LD (HL),E ; 7t
1069 | JP (IY) ; 8t
1070 | ; 48t
1071 | depth_:
1072 | LD HL,0
1073 | ADD HL,SP
1074 | EX DE,HL
1075 | LD HL,DSTACK
1076 | OR A
1077 | SBC HL,DE
1078 | JP shr1
1079 |
1080 | emit_:
1081 | POP HL
1082 | LD A,L
1083 | CALL putchar
1084 | JP (IY)
1085 |
1086 | ifte_:
1087 | POP DE
1088 | LD A,E
1089 | OR D
1090 | JR NZ,ifte1
1091 | INC DE
1092 | PUSH DE ; push TRUE on stack for else clause
1093 | JP begin1 ; skip to closing ) works with \) too
1094 | ifte1:
1095 | LD HL,-1 ; push -1 on return stack to indicate IFTEMode
1096 | CALL rpush
1097 | JP (IY)
1098 |
1099 | exec_:
1100 | CALL exec1
1101 | JP (IY)
1102 | exec1:
1103 | POP HL
1104 | EX (SP),HL
1105 | JP (HL)
1106 |
1107 | go_:
1108 | LD HL,BC
1109 | CALL rpush ; save Instruction Pointer
1110 | POP BC
1111 | DEC BC
1112 | JP (IY) ; Execute code from User def
1113 |
1114 | endGroup_:
1115 | call rpop
1116 | LD (vDEFS),HL
1117 | JP (IY)
1118 |
1119 | group_:
1120 | POP DE
1121 | LD D,E
1122 | LD E,0
1123 | SRL D
1124 | RR E
1125 | SRL D
1126 | RR E
1127 | LD HL,(vDEFS)
1128 | call rpush
1129 | LD HL,DEFS
1130 | ADD HL,DE
1131 | LD (vDEFS),HL
1132 | JP (IY) ; Execute code from User def
1133 |
1134 | sysVar_:
1135 | LD A,(BC)
1136 | SUB "a" - ((sysVars - mintVars)/2)
1137 | ADD A,A
1138 | LD L,A
1139 | LD H,msb(mintVars)
1140 | PUSH HL
1141 | JP (IY) ; Execute code from User def
1142 |
1143 | i_:
1144 | PUSH IX
1145 | JP (IY)
1146 |
1147 | ; \+ a b -- [b]+a ; increment variable at b by a
1148 | incr_:
1149 | POP HL
1150 | POP DE
1151 | LD A,E
1152 | ADD A,(HL)
1153 | LD (HL),A
1154 | INC HL
1155 | LD A,D
1156 | ADC A,(HL)
1157 | LD (HL),A
1158 | JP (IY)
1159 |
1160 | inPort_:
1161 | POP HL
1162 | LD A,C
1163 | LD C,L
1164 | IN L,(C)
1165 | LD H,0
1166 | LD C,A
1167 | PUSH HL
1168 | JP (IY)
1169 |
1170 | j_:
1171 | PUSH IX
1172 | POP HL
1173 | LD DE,6
1174 | ADD HL,DE
1175 | PUSH HL
1176 | JP (IY)
1177 |
1178 | key_:
1179 | CALL getchar
1180 | LD L,A
1181 | LD H,0
1182 | PUSH HL
1183 | JP (IY)
1184 |
1185 | newln_:
1186 | call crlf
1187 | JP (IY)
1188 |
1189 | outPort_:
1190 | POP HL
1191 | LD E,C
1192 | LD C,L
1193 | POP HL
1194 | OUT (C),L
1195 | LD C,E
1196 | JP (IY)
1197 |
1198 | rot_: ; a b c -- b c a
1199 | POP DE ; a b de = c
1200 | POP HL ; a hl = b
1201 | EX (SP),HL ; b hl = a
1202 | PUSH DE ; b c
1203 | PUSH HL ; b c a
1204 | JP (IY)
1205 |
1206 | break_:
1207 | POP HL
1208 | LD A,L ; zero?
1209 | OR H
1210 | JR NZ,break1
1211 | JP (IY)
1212 | break1:
1213 | LD DE,6 ; drop loop frame
1214 | ADD IX,DE
1215 | JP begin1 ; skip to end of loop
1216 |
1217 | printStk_:
1218 | JR printStk
1219 | editDef_:
1220 | ; **************************************************************************
1221 | ; Page 6 primitive routines
1222 | ; **************************************************************************
1223 | ; falls through
1224 | ; **************************************************************************
1225 | ; copy definition to text input buffer
1226 | ; update TIBPtr
1227 | ; **************************************************************************
1228 |
1229 | editDef: ; lookup up def based on number
1230 | LD A,"A"
1231 | POP DE
1232 | ADD A,E
1233 | EX AF,AF'
1234 | LD HL,(vDEFS)
1235 | ADD HL,DE
1236 | ADD HL,DE
1237 | LD E,(HL)
1238 | INC HL
1239 | LD D,(HL)
1240 | EX DE,HL
1241 | LD A,(HL)
1242 | CP ";"
1243 | LD DE,TIB
1244 | JR Z,editDef3
1245 | LD A,":"
1246 | CALL writeChar
1247 | EX AF,AF'
1248 | CALL writeChar
1249 | JR editDef2
1250 | editDef1:
1251 | INC HL
1252 | editDef2:
1253 | LD A,(HL)
1254 | CALL writeChar
1255 | CP ";"
1256 | JR NZ,editDef1
1257 | editDef3:
1258 | LD HL,TIB
1259 | EX DE,HL
1260 | OR A
1261 | SBC HL,DE
1262 | LD (vTIBPtr),HL
1263 | JP (IY)
1264 |
1265 | printStk: ;= 40
1266 | call ENTER
1267 | .cstr "\\a@2-\\D1-(",$22,"@\\b@\\(,)(.)2-)'"
1268 | JP (IY)
1269 |
1270 | ;*******************************************************************
1271 | ; Page 5 primitive routines continued
1272 | ;*******************************************************************
1273 |
1274 | arrEnd: ;= 27
1275 | CALL rpop ; DE = start of array
1276 | PUSH HL
1277 | EX DE,HL
1278 | LD HL,(vHeapPtr) ; HL = heap ptr
1279 | OR A
1280 | SBC HL,DE ; bytes on heap
1281 | LD A,(vByteMode)
1282 | OR A
1283 | JR NZ,arrEnd2
1284 | SRL H ; BC = m words
1285 | RR L
1286 | arrEnd2:
1287 | PUSH HL
1288 | LD IY,NEXT
1289 | JP (IY) ; hardwired to NEXT
1290 |
1291 | hex: ;= 26
1292 | LD HL,0 ; 10t Clear HL to accept the number
1293 | hex1:
1294 | INC BC
1295 | LD A,(BC) ; 7t Get the character which is a numeral
1296 | BIT 6,A ; 7t is it uppercase alpha?
1297 | JR Z, hex2 ; no a decimal
1298 | SUB 7 ; sub 7 to make $A - $F
1299 | hex2:
1300 | SUB $30 ; 7t Form decimal digit
1301 | JP C,endnum
1302 | CP $0F+1
1303 | JP NC,endnum
1304 | ADD HL,HL ; 11t 2X ; Multiply digit(s) in HL by 16
1305 | ADD HL,HL ; 11t 4X
1306 | ADD HL,HL ; 11t 8X
1307 | ADD HL,HL ; 11t 16X
1308 | ADD A,L ; 4t Add into bottom of HL
1309 | LD L,A ; 4t
1310 | JR hex1
1311 |
1312 | ;*******************************************************************
1313 | ; Subroutines
1314 | ;*******************************************************************
1315 |
1316 | crlf: ;=7
1317 | call printStr
1318 | .cstr "\r\n"
1319 | RET
1320 |
1321 | enter: ; 9
1322 | LD HL,BC
1323 | CALL rpush ; save Instruction Pointer
1324 | POP BC
1325 | DEC BC
1326 | JP (IY) ; Execute code from User def
1327 |
1328 | lookupDef: ;=20
1329 | SUB "A"
1330 | LD (vEdited),A
1331 | JR lookupDef2
1332 | lookupDef1:
1333 | SUB "A"
1334 | lookupDef2:
1335 | ADD A,A
1336 | LD E,A
1337 | LD D,0
1338 | LD HL,(vDEFS)
1339 | ADD HL,DE
1340 | RET
1341 |
1342 | printStr: ;=14
1343 | EX (SP),HL
1344 | JR printStr2
1345 |
1346 | printStr1:
1347 | CALL putchar
1348 | INC HL
1349 |
1350 | printStr2:
1351 | LD A,(HL)
1352 | OR A
1353 | JR NZ,printStr1
1354 | INC HL
1355 | EX (SP),HL
1356 | RET
1357 |
1358 | printdec:
1359 |
1360 | ;Number in hl to decimal ASCII
1361 |
1362 | ;inputs: hl = number to ASCII
1363 | ;example: hl=300 outputs '00300'
1364 | ;destroys: af, de, hl
1365 | DispHL: ;= 36
1366 | ld de,-10000
1367 | call Num1
1368 | ld de,-1000
1369 | call Num1
1370 | ld de,-100
1371 | call Num1
1372 | ld e,-10
1373 | call Num1
1374 | ld e,-1
1375 | Num1:
1376 | ld a,'0'-1
1377 | Num2:
1378 | inc a
1379 | add hl,de
1380 | jr c,Num2
1381 | sbc hl,de
1382 | JP putchar
1383 |
1384 | ; Print an 8-bit HEX number - shortened KB 25/11/21
1385 | ; A: Number to print
1386 | Print_Hex8: ;= 20
1387 | LD C,A
1388 | RRA
1389 | RRA
1390 | RRA
1391 | RRA
1392 | CALL conv
1393 | LD A,C
1394 | conv:
1395 | AND 0x0F
1396 | ADD A,0x90
1397 | DAA
1398 | ADC A,0x40
1399 | DAA
1400 | JP putchar
1401 |
1402 | printhex: ;= 11
1403 | ; Display HL as a 16-bit number in hex.
1404 | PUSH BC ; preserve the IP
1405 | LD A,H
1406 | CALL Print_Hex8
1407 | LD A,L
1408 | CALL Print_Hex8
1409 | POP BC
1410 | RET
1411 |
1412 | rpush: ;=11
1413 | DEC IX
1414 | LD (IX+0),H
1415 | DEC IX
1416 | LD (IX+0),L
1417 | RET
1418 |
1419 | rpop: ;=11
1420 | LD L,(IX+0)
1421 | INC IX
1422 | LD H,(IX+0)
1423 | INC IX
1424 | RET
1425 |
1426 | writeChar:
1427 | LD (DE),A
1428 | INC DE
1429 |
1430 | writeChar1:
1431 | JP putchar
1432 |
1433 |
1434 |
--------------------------------------------------------------------------------
/RC2014_MINT.hex:
--------------------------------------------------------------------------------
1 | :03800000C38B80AF
2 | :05800800E52A6A8AE987
3 | :05801000E52A6C8AE97D
4 | :05801800E52A6E8AE973
5 | :05802000E52A708AE969
6 | :05802800E52A728AE95F
7 | :05803000E52A748AE955
8 | :07803800E52A788AE9ED4D0D
9 | :108040003F065B4F666D7D077F6F777C395E797188
10 | :10805000210020E5D5110100ED52D25880D1E1C9AF
11 | :10806600E52A7A8AE9C547DB80CB4F28FA78D3819F
12 | :10807600C1C9DB80CB4728FADB81C92A7C8AE9E5BE
13 | :108086002A7E8AE3C9318088215F80226A8A226C2F
14 | :108096008A226E8A22708A22728A22748A22788AB8
15 | :1080A600227A8A217880227C8A216B80227E8ACD60
16 | :0880B6005080ED56FBC38081F0
17 | :10818000318088CDAA81CD7782604D494E542056EA
18 | :10819000312E30605C4E00C3E48180880000000016
19 | :1081A000C08A000000000000008CDD210089FD2154
20 | :1081B0004682219A8111008A011000EDB021C08A07
21 | :1081C00006A036932336822310F8C9ED43048A2192
22 | :1081D0008083856F5E1682D5CD77825C4700ED4B3C
23 | :1081E000048A1811CD77825C4E603E206000010049
24 | :1081F00000ED43048A1E00C521008918067E230B6A
25 | :10820000CDC68779B020F6C1CD8180FE20300CFE2E
26 | :1082100000282BFE0D2812160018B02100890977BE
27 | :1082200003CD8580CDC68718DF21008909360D234F
28 | :10823000360A0303CD65827BB720CD360303ED43B9
29 | :10824000048A0100890B030A6F26836E2684E9DD08
30 | :108250002BDD7400DD2BDD7500C9DD6E00DD23DD57
31 | :108260006600DD23C93E0DCD85803E0A18063E20FE
32 | :1082700018021213C385806069CD4F82C10BFDE9DE
33 | :10828000D12A0E8A733A368A23B720027223220E2D
34 | :108290008A18B33B005C6340303D303D28315F5C61
35 | :1082A000635C2B385C45602060385C45293B00608E
36 | :1082B0003F605C4B5C4E603E20605C5E412D5C5AD2
37 | :1082C0003B005C4E3236285C69405C5A5C6340304F
38 | :1082D0003E285C4E29295C4E603E20603B00603D9C
39 | :1082E0003E20605C505C4E5C4E603E20603B005C1B
40 | :0982F0006240303D5C62213B005C
41 | :108300006074745D74747474747474747474747458
42 | :10831000747474747474747474747474747474741D
43 | :10832000748858718F7A035531E2E42546A74CE6EC
44 | :10833000777777777777777777774381C7AFC3BBDF
45 | :108340006A343434343434343434343434343434B7
46 | :1083500034343434343434343434342B002E17A1D0
47 | :10836000E8D8D8D8D8D8D8D8D8D8D8D8D8D8D8D87D
48 | :10837000D8D8D8D8D8D8D8D8D8D8D8940E992074E6
49 | :108380009393EF9393AF939395939393C293939314
50 | :10839000DE93939393939393939393939393939362
51 | :1083A0000A1D0A0A0A0A0A0A3B0A0A8F0A0A0A0A64
52 | :1083B0000A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A1D
53 | :1083C000050AD97422340A550A9A0AAF0A0AB8BDB6
54 | :1083D000E80AC60A0A0A0A0A4D0AEA00140A0CCD7B
55 | :1083E0000A81818181818181818BA58181818181C6
56 | :1083F0008181818181818181818181660A5E0A0A10
57 | :10840000C32585D1E17BA56F7AA467E5FDE9D1E1BC
58 | :108410007BB56F7AB418F3D1E17BAD6F7AAC18EA13
59 | :1084200011FFFF18F3D1E119E5FDE9C34887C35AED
60 | :1084300087C36E856069CD4F820ACDF2854E234693
61 | :108440000BFDE9C37687E1CDE7851804E1CDC3854F
62 | :10845000CD6E82FDE9E1FDE9E1E5E5FDE9C3E481F9
63 | :10846000035059CD5A82444DEBE9E15E2356D5FDC8
64 | :10847000E9C39587C34682C3A185E1D1D5E5D5FD82
65 | :10848000E9CD5A82444DFDE9E1D1732372FDE9E162
66 | :10849000E3E5FDE9E129E5FDE9E1CB3CCB1DE5FDA7
67 | :1084A000E9210000D11802D1E1A7ED52E5FDE9E193
68 | :1084B000D1A7ED52281E210000181A030ACDF2851B
69 | :1084C000C36B84D1E11802E1D1A7ED522807210046
70 | :1084D00000FAD5842CE5FDE90AD621876F268AE5C6
71 | :1084E000FDE91813184A1864030A03FE602805CD35
72 | :1084F000858018F50BFDE921348AAFB62025DD5EB5
73 | :1085000000DD5601DD6E02DD6603B7ED52280F1364
74 | :10851000DD7300DD7201DD4E04DD4605FDE9110667
75 | :1085200000DD19FDE9030A218083856F6E2686E947
76 | :10853000D1E1C5444D2100003E1029CB13CB1230B0
77 | :1085400004093001133D20F2C1E5FDE9D1E1C54444
78 | :108550004D2100003E10CB21CB10ED6AED523803C7
79 | :108560000C1801193D20EF5059C1D5E5FDE9213422
80 | :108570008A3600E17DB4281C2B11FAFFDD19DD36A7
81 | :108580000000DD360100DD7502DD7403DD7104DD00
82 | :108590007005FDE91E01030ACDC687AFB320F7FDC4
83 | :1085A000E92100000AD630856F3E008C67030AFE81
84 | :1085B00030380CFE3A3008295D5429291918E60B89
85 | :1085C000E5FDE911F0D8CDDC851118FCCDDC851175
86 | :1085D0009CFFCDDC851EF6CDDC851EFF3E2F3C19B1
87 | :1085E00038FCED52C38580C57CCDB2877DCDB28786
88 | :0D85F000C1C9D641875F16002A068A19C945
89 | :108600003E01C34A87E116005ED5FDE9030A260054
90 | :108610006FE5FDE9030AFE0D20FA0BFDE9E1D173D8
91 | :10862000FDE921000039EB218088B7ED52CB3CCB2E
92 | :108630001DE5FDE9E17DCD8580FDE921348A360126
93 | :10864000D1B7ED62ED5223E5CA9485FDE9CD52869E
94 | :10865000FDE9E1E3E96069CD4F82C10BFDE9CD5A47
95 | :108660008222068AFDE9D1531E00CB3ACB1BCB3ABE
96 | :10867000CB1B2A068ACD4F8221C08A1922068AFD89
97 | :10868000E90AD661876F268AE5FDE9DDE5FDE9E1C6
98 | :10869000D17B8677237A8E77FDE9E1794DED6826E7
99 | :1086A000004FE5FDE9DDE5E111060019E5FDE9CD45
100 | :1086B00081806F2600E5FDE9CD6582FDE9E1594D38
101 | :1086C000E1ED694BFDE9D1E1E3D5E5FDE9E1CB7CE5
102 | :1086D000210000280123E5FDE9E17DB42002FDE948
103 | :1086E000110600DD19C3948518363E41D183082A4E
104 | :1086F000068A19195E2356EB7EFE3B110089281469
105 | :108700003E3ACD728208CD72821801237ECD7282EC
106 | :10871000FE3B20F7210089EBB7ED5222048AFDE9E8
107 | :10872000CD77825C6140322D5C44312D225C5F301C
108 | :108730003D282822405C62405C28242E29282C29D0
109 | :10874000322D29292700FDE93E00FD2180823236A5
110 | :108750008A2A0E8ACD4F82C34682CD5A82E5EB2A01
111 | :108760000E8AB7ED523A368AB72004CB3CCB1DE5D2
112 | :10877000FD214682FDE9030A03CDF285ED5B0E8AF9
113 | :108780007323720A031213FE3BCA8E8718F5ED534A
114 | :108790000E8A0BFDE9210000030ACB772802D607D9
115 | :1087A000D630DABF85FE10D2BF8529292929856FE9
116 | :1087B00018E64F1F1F1F1FCDBB8779E60FC69027F6
117 | :1087C000CE4027C38580FE60200ACB7B2803CBBB2D
118 | :1087D000C9CBFBC9CB7BC0FE3A2808FE5B2804FE50
119 | :1087E0002820021CC9FE3B2807FE5D2803FE29C085
120 | :0287F0001DC9A1
121 | :10E000000000000000000000202020202000200050
122 | :10E01000D8489000000000005050F850F8505000D0
123 | :10E020002078A07028F02000C0C810204098180068
124 | :10E0300040A0A040A89068006020400000000000C0
125 | :10E0400010204040402010004020101010204000C0
126 | :10E050000020A870A8200000002020F82020000048
127 | :10E060000000000000602040000000F800000000F8
128 | :10E070000000000000006000001010202040400060
129 | :10E08000708898A8C88870002060A0202020F80020
130 | :10E09000708808304080F800708808300888700068
131 | :10E0A00010305090F8101000F880F00808887000C8
132 | :10E0B000304080F088887000F80810204040400010
133 | :10E0C0007088887088887000708888780810600070
134 | :10E0D0000000600000600000000060000060204060
135 | :10E0E00010204080402010000000F800F8000000E0
136 | :10E0F00040201008102040007088081020002000E8
137 | :10E100007088B8A8B880700020508888F888880087
138 | :10E11000F08888F08888F00070888080808870009F
139 | :10E12000E09088888890E000F88080F08080F80097
140 | :10E13000F88080F0808080007088809888887000E7
141 | :10E14000888888F888888800702020202020700027
142 | :10E1500038101010109060008890A0C0A090880027
143 | :10E16000808080808080F80088D8A8A8888888006F
144 | :10E170008888C8A8988888007088888888887000EF
145 | :10E18000F08888F08080800070888888A890680077
146 | :10E19000F08888F0A0908800708080700808F000F7
147 | :10E1A000F820202020202000888888888888700017
148 | :10E1B0008888888850502000888888A8A8D8880037
149 | :10E1C0008888502050888800888888502020200027
150 | :10E1D000F80810204080F800704040404040700037
151 | :10E1E000004040202010100070101010101070001F
152 | :10E1F0002050880000000000000000000000F8002F
153 | :10E2000030201000000000000000700878887800BE
154 | :10E210008080F0888888F00000007080808078001E
155 | :10E22000080878888888780000007088F880700076
156 | :10E23000304840E040404000000070888878087016
157 | :10E240008080F0888888880020006020202070006E
158 | :10E250001000301010109060808090A0E090880036
159 | :10E2600060202020202070000000D0A8A8A88800EE
160 | :10E270000000B0C888888800000070888888700016
161 | :10E280000000F08888F0808000007888887808088E
162 | :10E290000000B0C880808000000070807008F0002E
163 | :10E2A0004040E0404048300000008888889868007E
164 | :10E2B000000088888850200000008888A8A85000A6
165 | :10E2C00000008850205088000000888888780870F6
166 | :10E2D0000000F8102040F8003040408040403000FE
167 | :10E2E0002020202020202000601010081010600046
168 | :10E2F00040A8100000000000F8F8F8F8F8F8F8005E
169 | :10E30000002040F840200000002070A820200000DD
170 | :10E31000002010F810200000002020A8702000002D
171 | :00000001FF
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MINT
2 |
3 | A Minimal Interpreter in Z80 assembly language for small Z80 systems such as the TEC-1 and RC2014.
4 |
5 | ## What is MINT ?
6 |
7 | MINT is a tiny, stack based language based on Forth. On the Z80 it can be implemented in fewer than 2048 bytes of machine code - and it is relatively quick compared to other interpreted languages.
8 |
9 | It uses reverse Polish notation (RPN) so you have to put the operands before the operator. It's just like the old HP calculators from 50 years ago.
10 |
11 | If you want to add two numbers you just type:
12 |
13 | 123 456 + .
14 |
15 | When you hit return the result will be displayed thus
16 |
17 | 00579
18 |
19 | > This is the cursor / prompt that confirms that the code has been executed and control has been passed back to the User.
20 |
21 | ## Fundamentals
22 |
23 | Like other small interpreted languages, the intention of MINT is to create a 16-bit virtual machine by combining the mostly 8-bit operations available on the Z80, to provide 16-bit integer arithmetic and variable handling.
24 |
25 | The language needs the basic arithmetic operations of ADD, SUBTRACT, MULTIPLY and DIVIDE. These are implemented as 16-bit integer operations and invoked using the familiar characters +, -, \* and /.
26 |
27 | These are augmented by the bitwise Boolean operators AND, OR, XOR, INVERT and 2's complement NEGATE.
28 |
29 | With MINT, these instructions are just one byte long and a look-up table is used instead of a switch-case structure. When using an 8-bit microprocessor, such as the Z80, it is simpler and faster to handle 8-bit instructions, so MINT uses a bytecode system, rather than the 16-bit threaded code that is used by a conventional Forth.
30 |
31 | In the example above 123 456 + .
32 |
33 | The numerical strings 123 and 456 are evaluated as 16-bit binary numbers and placed on the data stack. The plus symbol is interpreted as a jump to the routine that performs a 16-bit addition of the top two elements on the data stack, placing their sum on the top of the data stack. The dot character prints out the top value of the data stack, consuming it at the same time.
34 |
35 | In addition to the arithmetic and boolean operations, there are also the three comparison operators Greater Than, Less Than and Equal to, represented by symbols > < and =.
36 |
37 | The top two elements on the stack will be compared, resulting in 1 if the comparison is TRUE and 0 if the comparison is FALSE.
38 |
39 | With the comparison operators, it becomes possible to develop conditionally executed code, which forms the basis of program control words, such as IF, THEN, ELSE, and looping and branching structures.
40 |
41 | In total there are approximately 30 characters that are recognised as the internal instruction set, or primitives. From these characters the user can construct further definitions to extend the usefulness of the language.
42 |
43 | ## How MINT Works.
44 |
45 | MINT is an interpreted language that uses printable ascii characters as its "instructions". There are 95 such characters:
46 |
47 | - 10 Numerals - 0-9 used for decimal number entry
48 | - 11 Alphanumerics - 0-F used for hexadecimal number entry (only uppercase chars are recognized as hex digits)
49 | - 26 lowercase letters - used as User Variables
50 | - 26 system variables - most are available for general use
51 | - 33 arithmetic and punctuation codes - used to select the program operation aka "primitives"
52 | - 22 "alternate" codes - to extend the basic set of alphanumeric characters, these are prefixed by \
53 | - 26 uppercase letters - used as User Commands
54 |
55 | The interpreter scans a text string, held in a text buffer, one character at a time. It then uses a look-up table to broadly categorise the current character into one of the above groups.
56 |
57 | For each category of character there is a handling routine, which determines how the character should be processed.
58 |
59 | NUMBERS
60 |
61 | A number string such as 1234 will be scanned one digit at a time and converted into a 16-bit binary number using a routine called num\_ . The converted binary number is then placed on the top of the data stack which is used as a means of temporary storage, before being used later. Multiple numbers may be entered in a sequence separated by spaces: 1234 5678 3579 When the return key is pressed they will be processed in turn and each placed onto the stack. They may then be used as operands or parameters for a calculation or other function.
62 |
63 | VARIABLES
64 |
65 | User Variables are assigned to the lowercase alpha characters using a routine called var\_ The user variables are stored in an array of 26 pairs of bytes in RAM. The lowercase character is a shorthand way of addressing the pair of bytes that holds the variable. It is not usually necessary to know specifically at what address the variable is held at, as it can always be accessed using its name.
66 |
67 | When a lowercase character is interpreted the variable handler routine converts it to a 16-bit address, and places that address on the top of the stack.
68 |
69 | SYSTEM VARIABLES
70 | System variables contain values which MINT uses internally but are available for programmatic use. These are the lowercase letters preceded by a \ e.g. \a, \b, \c etc. However Mint only uses a few of these variables so the user may use the other ones as they like.
71 |
72 | PRIMITIVES
73 |
74 | A primitive is a built-in function, normally stored in ROM and not usually needed to be modified by the User. Primitives will include the familiar mathematical functions such as ADD, SUBtract, MULtiply and DIVide, and also boolean logic operations such as AND, OR, XOR and INVert.
75 |
76 | There are also a small group of primitives that perform operations on the stack, DUP is used to duplicate the top item, DROP will remove the top item, making the second item available. SWAP will exchange the top two items, effectively placing the second item on top.
77 |
78 | In total, MINT contains 33 primitives which are executed when the interpreter finds the relevant symbol. Some of these will be commonly used arithmetic symbols like "+" and "-" Others are allocated to punctuation symbols. The full-stop, or dot character is used to print out the number held on the top of the stack.
79 |
80 | ALTERNATE CODES
81 | Because ASCII provides only a limited set of symbols to use as primitives, MINT extends the basic set with a set of symbols prefixed by a \. An alternate code is any symbol or uppercase letter starting with a \ e.g. \+ \D etc. Alternate lowercase letters serve as system variables
82 |
83 | USER COMMANDS
84 |
85 | User Commands are what gives MINT its power and flexibility. Each uppercase letter can be assigned a routine written by the user in the Mint language. For example you may have a routine which produces a hexadecimal dump of the contents of memory. You could define a routine at D for this DUMP operation. You may also pass parameters to a user routine via the stack. In the case of a hex dump routine it would be common to give it the starting address of the section you want to dump, and this might be written 1234 D. On pressing return, the command will be interpreted and the dump routine will commence printing from location 1234. There are clearly 26 User Commands which is usually enough for most small applications.
86 |
87 | ## Using MINT on the TEC-1
88 |
89 | MINT was designed for for small Z80 based systems but specifically with the small memory configuration of the TEC-1 single board computer. It is only 2K to work with the original TEC-1 and interfaces to the serial interface via a simple adapter.
90 |
91 | On initialisation it will present a user prompt ">" followed by a CR and LF. It is now ready to accept commands from the keyboard.
92 |
93 | ## Using MINT on the RC2014
94 |
95 | MINT was developed for the RC2014 Micro Z80 Single Board Computer. This board is supplied with a comprehensive Monitor program (The Small Computer Monitor (SCM) by Stephen Cousins). A 32K ROM contains the monitor and BASIC between $0000 and $7FFF. The 32K RAM starts at $8000, and MINT is loaded in to run from address $8000.
96 |
97 | Install the Intel Hex file RC2014_MINT.hex by pasting it into the SCM. At the Ready prompt, type G8000 to execute.
98 |
99 | If necessary, you can use the serial getchar and putchar routines that are available within the Small Computer Monitor
100 |
101 | See the User Manual pages 45 and 46 on how this is done
102 |
103 | https://smallcomputercentral.files.wordpress.com/2018/05/scmon-v1-0-userguide-e1-0-0.pdf
104 |
105 | MINT was assembled using asm80.com, an online 8-bit assembler. It will generate an Intel Hex file that can be pasted into RAM at address $8000 using a serial terminal program. I use TeraTerm when working within the windows environment.
106 |
107 | Once the MINT code image is pasted into RAM you can run it using the Go command "G8000"
108 |
109 | On initialisation it will respond:
110 |
111 | MINT V1.0
112 |
113 | On initialisation it will present a user prompt ">" followed by a CR and LF. It is now ready to accept commands from the keyboard.
114 |
115 | ## Examples
116 |
117 | Spaces are shown for clarity, but only necessary to separate consecutive number strings. Most other operators can be concatenated without spaces.
118 |
119 | 1234 5678 + . ; ADD 1234 to 5678 and print the result
120 |
121 | 1234 5678 - . ; Subtract 1234 from 5678 and print the result
122 |
123 | 1234 a! ; Store 1234 in the variable a
124 |
125 | 5678 b! ; Store 5678 in the variable b
126 |
127 | b@ . ; print the value stored in b
128 |
129 | a@ b@ + . ; add the contents of a to b and print the sum
130 |
131 | a@ b! ; copy the contents of a into b
132 |
133 | ##Loops
134 |
135 | 0(this code will not be executed but skipped)
136 | 1(this code will be execute once)
137 | 10(this code will execute 10 times)
138 |
139 | You can use the comparison operators < = and > to compare 2 values and conditionally execute the code between the brackets.
140 |
141 | ARRAYS
142 |
143 | An array of 16-bit numbers can be defined by enclosing them within square brackets:
144 |
145 | [1 2 3 4 5 6 7 8 9 0]
146 |
147 | Defining an array puts its start address and length onto the stack
148 |
149 | These can then be allocated to a variable, which acts as a pointer to the array in memory
150 |
151 | [1 2 3 4 5 6 7 8 9 0] $ a!
152 |
153 | The swap $ is used to get the starting address onto the top of the stack and then store that into the variable a.
154 |
155 | To fetch the Nth member of the array, we can create a colon definition N
156 |
157 | :N @ $ {+ @. ;
158 |
159 | ### LIST OF PRIMITIVES
160 |
161 | Mint is a bytecode interpreter - this means that all of its instructions are 1 byte long. However, the choice of instruction uses printable ASCII characters, as a human readable alternative to assembly language. The interpreter handles 16-bit integers and addresses which is sufficient for small applications running on an 8-bit cpu.
162 |
163 | ### Maths Operators
164 |
165 | | Symbol | Description | Effect |
166 | | ------ | ----------------------------------------- | -------- |
167 | | - | 16-bit integer subtraction SUB | a b -- c |
168 | | { | shift the number to the left (2\*) | a -- b |
169 | | } | shift the number to the right (2/) | a -- b |
170 | | / | 16-bit by 8-bit division DIV | a b -- c |
171 | | \_ | 16-bit negation (2's complement) NEG | a -- b |
172 | | \* | 8-bit by 8-bit integer multiplication MUL | a b -- c |
173 | | \> | 16-bit comparison GT | a b -- c |
174 | | + | 16-bit integer addition ADD | a b -- c |
175 | | < | 16-bit comparison LT | a b -- c |
176 | | = | 16 bit comparison EQ | a b -- c |
177 |
178 | ### Logical Operators
179 |
180 | | Symbol | Description | Effect |
181 | | ------ | ---------------------------- | -------- |
182 | | \| | 16-bit bitwise OR | a b -- c |
183 | | & | 16-bit bitwise AND | a b -- c |
184 | | ^ | 16-bit bitwise XOR | a b -- c |
185 | | ~ | 16-bit bitwise inversion INV | a -- b |
186 |
187 | Note: logical NOT can be achieved with 0=
188 |
189 | ### Stack Operations
190 |
191 | | Symbol | Description | Effect |
192 | | ------ | -------------------------------------------------------------------- | -------------- |
193 | | ' | drop the top member of the stack DROP | a a -- a |
194 | | " | duplicate the top member of the stack DUP | a -- a a |
195 | | \\D | returns the depth of the stack | -- n |
196 | | \\R | rotate the top 2 members of the stack ROT | a b c -- b c a |
197 | | % | over - take the 2nd member of the stack and copy to top of the stack | a b -- a b a |
198 | | $ | swap the top 2 members of the stack SWAP | a b -- b a |
199 |
200 | ### Input & Output Operations
201 |
202 | | Symbol | Description | Effect |
203 | | ------ | --------------------------------------------------------- | ----------- |
204 | | , | print the number on the stack as a hexadecimal | a -- |
205 | | . | print the top member of the stack as a decimal number DOT | a -- |
206 | | \\E | emits a char to output | val -- |
207 | | \\I | input from a I/O port | port -- val |
208 | | \\K | read a char from input | -- val |
209 | | \\N | prints a CRLF to output | -- |
210 | | \\O | output to an I/O port | val port -- |
211 | | \\P | non-destructively prints stack | -- |
212 | | \\Z | print definition by number | n -- |
213 | | \` | print the literal string between \` and \` | -- |
214 | | # | the following number is in hexadecimal | a -- |
215 |
216 | ### User Definitions
217 |
218 | | Symbol | Description | Effect |
219 | | ------- | -------------------------- | ------ |
220 | | ; | end of user definition END | |
221 | | : | define a new word DEF | |
222 | | ? | get the address of the def | -- adr |
223 | | \{ | enter group NUM | num -- |
224 | | \} | exit group | -- |
225 |
226 | NOTE:
227 | is an uppercase letter immediately following operation which is the name of the definition
228 | is the group number. There are currently 5 groups numbered 0 - 4
229 |
230 | ### Loops and conditional execution
231 |
232 | | Symbol | Description | Effect |
233 | | ------ | ------------------------------------------------- | ------ |
234 | | ( | BEGIN a loop or conditionally executed code block | n -- |
235 | | ) | END a loop or conditionally executed code block | -- |
236 | | \\( | beginIFTE \\(`true`)(`false`) | b -- |
237 | | \\B | if true break out of loop | b -- |
238 | | \\i | loop counter variable | -- adr |
239 | | \\j | outer loop counter variable | -- adr |
240 |
241 | ### Memory and Variable Operations
242 |
243 | | Symbol | Description | Effect |
244 | | ------ | ------------------------------------------- | ------------- |
245 | | ! | STORE a value to memory | val adr -- |
246 | | [ | begin an array definition | -- |
247 | | ] | end an array definition | -- adr nwords |
248 | | @ | FETCH a value from memory | -- val |
249 | | \\! | STORE a byte to memory | val adr -- |
250 | | \\[ | begin a byte array definition | -- |
251 | | \\@ | FETCH a byte from memory | -- val |
252 | | \\+ | increments variable at address by an amount | val adr -- |
253 |
254 | ### System Variables
255 |
256 | | Symbol | Description | Effect |
257 | | ------ | ------------------------------------ | ------ |
258 | | \\a | data stack start variable | -- adr |
259 | | \\b | base16 flag variable | -- adr |
260 | | \\c | text input buffer pointer variable | -- adr |
261 | | \\d | start of user definitions | -- adr |
262 | | \\h | heap pointer variable | -- adr |
263 | | \\i | See: Loops and conditional execution | -- adr |
264 | | \\j | See: Loops and conditional execution | -- adr |
265 |
266 | ### Miscellaneous
267 |
268 | | Symbol | Description | Effect |
269 | | ------ | --------------------------------------------- | -------- |
270 | | \\\\ | comment text, skips reading until end of line | -- |
271 | | \\G | execute mint code at address | adr -- ? |
272 | | \\Q | quits from Mint interpreter | -- |
273 | | \\X | execute machine code at address | adr -- ? |
274 |
275 | ### Control keys
276 |
277 | | Symbol | Description |
278 | | ------ | ------------------------------- |
279 | | ^B | toggle base decimal/hexadecimal |
280 | | ^E | edit a definition |
281 | | ^H | backspace |
282 | | ^J | re-edit |
283 | | ^L | list definitions |
284 | | ^P | print stack |
285 |
--------------------------------------------------------------------------------
/TEC-1ROM10.z80:
--------------------------------------------------------------------------------
1 | .engine mycomputer
2 |
3 | .include "constants.asm"
4 | .include "IOSerial.asm"
5 |
6 | jp start
7 |
8 | .include "MINT.asm"
9 | .include "ram.asm"
10 |
--------------------------------------------------------------------------------
/TEC-1ROM10.z80.hex:
--------------------------------------------------------------------------------
1 | :03000000C38B00AF
2 | :05000800E52A6A0AE987
3 | :05001000E52A6C0AE97D
4 | :05001800E52A6E0AE973
5 | :05002000E52A700AE969
6 | :05002800E52A720AE95F
7 | :05003000E52A740AE955
8 | :07003800E52A780AE9ED4D0D
9 | :10004000EB28CDAD2EA7E729EF2F6FE6C3ECC7470E
10 | :10005000210020E5D5110100ED52D25800D1E1C9AF
11 | :10006600E52A7A0AE9C547DB80CB4F28FA78D3819F
12 | :10007600C1C9DB80CB4728FADB81C92A7C0AE9E5BE
13 | :100086002A7E0AE3C9318008215F00226A0A226CAF
14 | :100096000A226E0A22700A22720A22740A22780A38
15 | :1000A600227A0A217800227C0A216B00227E0A3EEF
16 | :1000B60003D380CD5000ED56FB3E12D380C38001A2
17 | :10018000318008CDA701CD8B074D494E5420563103
18 | :100190002E300D0A00184A800800000000C00A0036
19 | :1001A0000000000000000CDD210009FD21470221B4
20 | :1001B000970111000A011000EDB021C00A06A03617
21 | :1001C000982336022310F8C9ED43040A21800385E1
22 | :1001D0006F5E1602D5CD70075C4700ED4B040A1820
23 | :1001E00011CD70075C4E603E206000010000ED43C1
24 | :1001F000040A1E00C521000918067E230BCD6302E8
25 | :1002000079B020F6C1CD8100FE20300CFE00282CF4
26 | :10021000FE0D2812160018B0210009097703CD85BC
27 | :1002200000CD630218DF21000909360D23360A23A9
28 | :100230000303CD69077BB720CC360303ED43040AE3
29 | :100240000100090BC34702030A6F26036E2604E967
30 | :10025000D12A0E0A733A360A23B720027223220EDD
31 | :100260000A18E4FE60200ACB7B2803CBBBC9CBFB7A
32 | :10027000C9CB7BC0FE3A2808FE5B2804FE2820027A
33 | :100280001CC9FE3B2807FE5D2803FE29C01DC9CD01
34 | :100290008B070D0A3E2000C93B5C6340303D303D7A
35 | :1002A00028315F5C635C2B6008200860293B5C653B
36 | :1002B0005C405C5A3B603F605C4B5C4E603E206043
37 | :1002C0005C5E412D5C5A3B005C4E3236285C6940D6
38 | :1002D0005C5A5C6340303E285C4E29295C4E603E8F
39 | :1002E00020603B00603D3E20605C505C4E5C4E6098
40 | :0F02F0003E20603B005C6240303D5C62213B0081
41 | :100300007A8E8E6E8E8E8E8E8E8E8E8E8E8E8E8E41
42 | :100310008E8E8E8E8E8E8E8E8E8E8E8E8E8E8E8EFD
43 | :100320008EA2698BA994036640FCF92555C15BF741
44 | :1003300091919191919191919191529BDCC9D8D5D4
45 | :10034000844343434343434343434343434343433C
46 | :1003500043434343434343434343432B003D17BB82
47 | :10036000FFEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDAB
48 | :10037000EDEDEDEDEDEDEDEDEDEDEDAE0EB3208E31
49 | :100380009898F59898B598989998AE98C89898982C
50 | :10039000E498989898989898989898989898989891
51 | :1003A0000A1D0A0A0A0A0A0A370A0A8B0A0A0A0AEC
52 | :1003B0000A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A9D
53 | :1003C000050AC98E22300A510A960AAB0A0AB4B944
54 | :1003D000D80AC20A0A0A0A0A490ADA00140A0C0AE6
55 | :1003E0000A7D7D7D7D7D7D7D7D87A17D7D7D7D7D82
56 | :1003F0007D7D7D7D7D7D7D7D7D7D7D620A5A0A0AC4
57 | :10040000C31605D1E17BA56F7AA467E5FDE9D1E1CB
58 | :100410007BB56F7AB418F3D1E17BAD6F7AAC18EA93
59 | :1004200011FFFF18F3D1E119E5FDE93E00FD215070
60 | :100430000232360A2A0E0ACDDC07C34702C3300750
61 | :10044000C39F056069CDDC070ACD80074E23460BAC
62 | :10045000FDE9C35F05E1CDD1071804E1CD99073E61
63 | :1004600020CDF407FDE9E1FDE9E1E5E5FDE92180C5
64 | :10047000F7393003318008C3E101035059CDE70754
65 | :10048000444DEBE9E15E2356D5FDE9C34C07C34774
66 | :1004900002C37D05E1D1D5E5D5FDE9CDE707444DA2
67 | :1004A000FDE9E1D1732372FDE9E1E3E5FDE9E1292D
68 | :1004B000E5FDE9E1CB3CCB1DE5FDE9210000D118CC
69 | :1004C00002D1E1A7ED52E5FDE9E1D1A7ED522819EE
70 | :1004D0002100001815C30E05D1E11802E1D1A7EDE6
71 | :1004E000522807210000FAEA042CE5FDE90AD6218A
72 | :1004F000876F260AE5FDE91844C32105C3CD05032E
73 | :100500000A03FE602805CD850018F50BFDE9030AF6
74 | :10051000CD7907C38504030A218003856F6E260603
75 | :10052000E9D1E1C5444D2100003E1029CB13CB1287
76 | :100530003004093001133D20F2C1E5FDE9D1E1C5E8
77 | :10054000444D2100003E10CB21CB10ED6AED523816
78 | :10055000030C1801193D20EF5059C1D5E5FDE90301
79 | :100560000A03CD7907ED5B0E0A7323720A03121397
80 | :10057000FE3B280218F60BED530E0AFDE9210000A0
81 | :100580000AD630856F3E008C67030AFE30380CFEB9
82 | :100590003A3008295D5429291918E60BE5FDE9E1EF
83 | :1005A0007DB4281C2B11FAFFDD19DD360000DD3685
84 | :1005B0000100DD7502DD7403DD7104DD7005FDE908
85 | :1005C0001E01030ACD6302AFB320F7FDE9DD5E0033
86 | :1005D000DD56017AA33C200713D5110200181DDD5A
87 | :1005E0006E02DD6603B7ED52280F13DD7300DD7276
88 | :1005F00001DD4E04DD4605FDE9110600DD19FDE9CA
89 | :100600003E01C32D04E116005ED5FDE9030A260074
90 | :100610006FE5FDE9030AFE0D20FA0BFDE9E1D17358
91 | :10062000FDE921000039EB218008B7ED52C3B40485
92 | :10063000E17DCD8500FDE9D17BB2200513D5C3C096
93 | :100640000521FFFFCDDC07FDE9CD4E06FDE9E1E325
94 | :10065000E96069CDDC07C10BFDE9CDE70722060A99
95 | :10066000FDE9D1531E00CB3ACB1BCB3ACB1B2A065C
96 | :100670000ACDDC0721C00A1922060AFDE90AD66163
97 | :10068000876F260AE5FDE9DDE5FDE9E1D17B8677A7
98 | :10069000237A8E77FDE9E1794DED6826004FE5FD7F
99 | :1006A000E9DDE5E111060019E5FDE9CD81006F26E0
100 | :1006B00000E5FDE9CD6907FDE9E1594DE1ED694B43
101 | :1006C000FDE9D1E1E3D5E5FDE9E17DB42002FDE9F5
102 | :1006D000110600DD19C3C00518363E41D183082A32
103 | :1006E000060A19195E2356EB7EFE3B1100092814F9
104 | :1006F0003E3ACDF20708CDF2071801237ECDF2076E
105 | :10070000FE3B20F7210009EBB7ED5222040AFDE978
106 | :10071000CD70075C6140322D5C44312D2822405C55
107 | :1007200062405C282C29282E29322D292700FDE93A
108 | :10073000CDE707E5EB2A0E0AB7ED523A360AB720A5
109 | :1007400004CB3CCB1DE5FD214702FDE92100000360
110 | :100750000ACB772802D607D630DA9B05FE10D29B4B
111 | :100760000529292929856F18E6CD8B070D0A00C9AF
112 | :100770006069CDDC07C10BFDE9D64132080A1802D9
113 | :10078000D641875F16002A060A19C9E31804CD85E9
114 | :1007900000237EB720F823E3C911F0D8CDB20711AA
115 | :1007A00018FCCDB207119CFFCDB2071EF6CDB207E3
116 | :1007B0001EFF3E2F3C1938FCED52C385004F1F1F12
117 | :1007C0001F1FCDC60779E60FC69027CE4027C385E9
118 | :1007D00000C57CCDBD077DCDBD07C1C9DD2BDD7456
119 | :1007E00000DD2BDD7500C9DD6E00DD23DD6600DD7B
120 | :0707F00023C91213C38500A9
121 | :00000001FF
--------------------------------------------------------------------------------
/constants.asm:
--------------------------------------------------------------------------------
1 | TEC_1 EQU 1
2 | RC2014 EQU 0
3 |
4 | EXTENDED EQU 0
5 |
6 | .if RC2014
7 |
8 | ; Configuration for RC2014
9 |
10 | ROMSTART EQU $8000
11 | RAMSTART EQU $8800
12 | LOADER EQU 0
13 | BITBANG EQU 0
14 |
15 | .endif
16 |
17 | .if TEC_1
18 |
19 | ; Configuration for TEC-1
20 | LOADER EQU 0
21 | BITBANG EQU 0
22 |
23 | ROMSTART EQU $0000
24 | RAMSTART EQU $0800
25 | ROMSIZE EQU $0800
26 | RAMSIZE EQU $0800
27 |
28 | ;TEC-1D SC 8k rom/ram
29 | ; ROMSTART .equ $0000
30 | ; RAMSTART .equ $2000
31 | ; ROMSIZE .equ 8192
32 | ; RAMSIZE .equ 8192
33 |
34 | .endif
35 |
--------------------------------------------------------------------------------
/display-test.z80:
--------------------------------------------------------------------------------
1 | .engine mycomputer
2 |
3 | .include "constants.asm"
4 | .include "IOSerial.asm"
5 |
6 | .macro testDefs
7 | ; 0 1 2 3 4 5 6 7 8 9 A B C D E F ; hex digit to 7 segments stored in c
8 | DB "\\[#EB #28 #CD #AD #2E #A7 #E7 #29 #EF #2F #6F #E6 #C3 #EC #C7 #47]' c!"
9 | DB "\\[0 0 0 0 0 0]' d!" ; display buffer
10 |
11 | DB ":A c@+ \\@;" ; char -- seg convert char to 7segments
12 | DB ":B #0F& A $\\!;" ; buf val -- read char from string convert to seg and write to buffer
13 | DB ":C }}}} $ 1- $;" ; buf val -- buf' val' rshift val 4 bits -- decrement buf ptr
14 | DB ":D d@3+ $ 4(%%B C)'';" ; val -- write 4 hex digits from val to buf
15 |
16 | DB ":E #40 | 1\\O;" ; dig -- write digit bit, keep bit 6 high
17 | DB ":F \\@ 2\\O;" ; buf -- output segment + digit info to LEDs
18 | DB ":G }$ 1+$;" ; buf dig -- buf' dig' move to next segment, inc buf ptr
19 | DB ":H \\d@ #20 6(%%EF G)'' ;" ; -- display scan 6 digits
20 |
21 | DB ":J 10(\\i@ D 100(H)) 0E;" ; -- count to 10, convert, scan 100 times
22 | .endm
23 |
24 | LD SP,DSTACK
25 | CALL initialize
26 | JP testsStart
27 |
28 | .include "MINT.asm"
29 | .include "ram.asm"
30 | .include "ftest.mac.asm"
31 |
32 | .org $4000
33 |
34 | testsStart:
35 |
36 | CALL enter
37 |
38 | utilDefs
39 | testDefs
40 |
41 | tester "", "0 A", "#EB"
42 | tester "", "15 A", "#47"
43 |
44 | ; tester "", "?X\\@A", "#6E"
45 | ; tester "", "d@ ?X D d@\\@", "#6E"
46 | ; tester "", "d@ ?X DI", ""
47 |
48 | ; tester "", "J\\P\\N", ""
49 |
50 | .cstr "`Done!`"
51 | HALT
52 |
53 |
54 |
--------------------------------------------------------------------------------
/ftest.mac.asm:
--------------------------------------------------------------------------------
1 |
2 | .macro utilDefs
3 | DB ":Q ",$22,";" ; ( n -- n n ) a convenient way to access "
4 | DB ":W \\h@! 2\\h\\+;" ; ( n -- ) compiles a word to heap
5 | DB ":K \\D\\t@- 0$ ($1+^);" ; ( x1...xn num -- hash )
6 | .endm
7 |
8 | .macro arrayDefs
9 | DB ":H 0\\R\\R ( $%@ 1+^ $ 2+)';" ; arr len -- hash hash array
10 |
11 | DB ":R \\f! ( $%@ \\f@\\G $ 2+) ' ;" ; v0 arr len fun -- val reduce array
12 |
13 | DB ":M \\f! \\h@\\R\\R " ; arr len fun -- arr' len' map array
14 | DB "(Q@"
15 | DB "\\f@\\G W 2+"
16 | DB ")"
17 | DB "' \\h@ % -};"
18 |
19 | DB ":F \\f! \\h@ \\R\\R "
20 | DB "(Q@Q "
21 | DB "\\f@\\G "
22 | DB "\\(W)(') 2+ "
23 | DB ")"
24 | DB " ' \\h@ % -};"
25 |
26 | DB ":Z `[ `(Q @.2+)`]` ' ;" ; arr len -- print array
27 | .endm
28 |
29 | .macro tester, name1, test1, expect1
30 | DB "`.`\\D\\t!"
31 | DB " ",test1," "
32 | DB "K\\D\\t!" ; ( -- hash1 )
33 | DB " ",expect1," "
34 | DB "K=0=(\\N`fail: ",name1," ",test1," expected: "
35 | DB expect1,"`\\N\\N",0,")"
36 | .endm
37 |
38 |
--------------------------------------------------------------------------------
/ftest.z80:
--------------------------------------------------------------------------------
1 | .engine mycomputer
2 |
3 | .include "constants.asm"
4 | .include "IOSerial.asm"
5 |
6 | LD SP,DSTACK
7 | CALL initialize
8 | JP testsStart
9 |
10 | .include "MINT.asm"
11 | .include "ram.asm"
12 | .include "ftest.mac.asm"
13 |
14 | .org $4000
15 |
16 | testsStart:
17 |
18 | CALL enter
19 | utilDefs
20 | arrayDefs
21 |
22 | ; tester "", "0t! 10(\\i@ 4>\\B 1t\\+) t@","5"
23 | ; .cstr "`Done!`"
24 | ; HALT
25 |
26 | tester "odd", ":O2/$ '; [1 2 3 4 5 6] ?O F H", "[1 3 5] H"
27 | tester "dup", "1Q", "1 1"
28 | tester "nums", "1 2 3", "1 2 3"
29 | tester "TE11p20", "25(\\i@ 2\\O 1 30(Q #40 | 1\\O { #3F & Q0=('1))') #40 1\\O", ""
30 | tester "max", ":G %%> \\(')($ '); 5 2 G", "5"
31 | tester "count", ":C'1+; 0 [1 4 3 6 2] ?C R", "5"
32 | tester "sum", ":P+; 0 [1 4 3 6 2] ?P R", "16"
33 | tester "greatest", ":G %%> \\(')($ ') ; 1 [1 4 3 6 2] ?G R", "6"
34 | tester "least", ":L %%< \\(')($ ') ; 1 [1 4 3 6 2] ?L R", "1"
35 | tester "double", ":D {; [1 2 3] ?D M H", "[2 4 6] H"
36 |
37 | tester "", "#1#12#123#1234", "1 18 291 4660"
38 | tester "", "2 3<", "1"
39 | tester "", "3 3<", "0"
40 | tester "", "3 3>", "0"
41 | tester "", "4 3>", "1"
42 |
43 | tester "", "0","0"
44 | tester "", "1","1"
45 | tester "", "1 2+", "3"
46 | tester "", "123 456+", "579"
47 | tester "", "1_ 2+","1"
48 | ; tester "", "1_\\_","1"
49 | tester "", "1 2+","3"
50 | tester "", "1_ 2+","1"
51 | tester "", "1_~","0"
52 |
53 | tester "", "1 2 3 \\R'' ", "2"
54 | tester "", "\\^A","65"
55 |
56 | tester "", "3x! 1 x\\+ x@", "4"
57 | tester "", "3x! 1_ x\\+ x@", "2"
58 | tester "", ":X1; X", "1"
59 | tester "", "2x! x@", "2"
60 | tester "", ":Aa!; 3A a@", "3"
61 | tester "", ":Aa!; :Ba@; 4AB", "4"
62 |
63 | tester "", "100 0(6)", "100"
64 | tester "", "100 1(6)$ '", "6"
65 | tester "", "2(6)+", "12"
66 | tester "", "1(\\i@)", "0"
67 | tester "", "1(1(\\i@ \\j@+))", "0"
68 | tester "", "2(2(\\i@ \\j@))+++++++", "4"
69 | tester "", "0\\(100)(200)", "200"
70 | tester "", "1\\(100)(200)", "100"
71 |
72 | tester "", "0t! 10(1t\\+) t@", "10"
73 | tester "", "0t! 10(\\i@ 4>\\B 1t\\+) t@","5"
74 | tester "", "100a! 1 a\\+ a@", "101"
75 |
76 | tester "", "[3] '@", "3"
77 | tester "", "[3] $ ' ", "1"
78 | tester "", "[1 2 3] ' @ ", "1"
79 | tester "", "[]$ '", "0"
80 | tester "", "0t! [1 2 3] $ a! ( a@ \\i@ {+ @ t\\+ ) t@", "6"
81 | tester "", "\\h@ [1 2 3]'' \\h@ $ - ", "6"
82 |
83 | tester "", "\\[3] ' \\@", "3"
84 | tester "", "\\[3] $ ' ", "1"
85 | tester "", "\\[1 2 3] ' \\@ ", "1"
86 | tester "", "\\[]$ '", "0"
87 | tester "", "\\h@ \\[1 2 3]'' \\h@ $ - ", "3"
88 |
89 | DB ":A 0 t!" ; total = 0
90 | DB "[1 2 3 4 5]" ; declare array, returns address length
91 | DB "$ a!" ; store address in a, leave length
92 | DB "(" ; loop
93 | DB "a@ \\i@ {+ @" ; access nth element
94 | DB "t\\+" ; add to total
95 | DB ")" ; end loop
96 | DB "t@;" ; print total
97 | tester "", "A", "15"
98 |
99 | .cstr "`Done!`"
100 | HALT
101 |
102 |
--------------------------------------------------------------------------------
/inspiration.md:
--------------------------------------------------------------------------------
1 | ## Inspiration
2 |
3 | The design of the Mint interpreter has drawn from many sources of inspiration. First amongst these is the work of Charles Moore and his design of the Forth programming language. Another important source of inspiration is the STABLE programming language, a small and minimal interpreter written by Sandor Schneider. Also Mint takes inspiration from Chris Curl's S4 programming language.
4 |
5 | Mint is a direct descendant of Ken Boak's own SIMPL programming language and has been expanded and extended greatly with many elements from Forth. Mint has been influenced by discussions in various online communities. In particular in the Minimalist Computing Facebook community and the Forth 2020 Facebook.
6 |
7 | Mint's fast and efficient design has been strongly influenced by Peter Jackaki's Forth implementations, especially his TAQOZ Forth engine for the Propeller chips.
8 |
9 | Mint is a collaboration between Ken Boak, John Hardy and Craig Jones.
--------------------------------------------------------------------------------
/mycomputer.emu:
--------------------------------------------------------------------------------
1 | cpu Z80
2 |
3 | memory.rom.from 0x0000
4 | memory.rom.to 0x7ff
5 | memory.ram.from 0x800
6 | memory.ram.to 0xffff
7 |
8 | serial 6850
9 | serial.data 0x81
10 | serial.control 0x80
11 |
12 | serial.interrupt 1
13 |
14 | terminal.caps 0
15 |
--------------------------------------------------------------------------------
/ram.asm:
--------------------------------------------------------------------------------
1 | .ORG RAMSTART
2 |
3 | DS DSIZE
4 | stack:
5 | dStack:
6 |
7 | DS RSIZE
8 | rStack:
9 |
10 | TIB: DS TIBSIZE
11 |
12 | .align $100
13 | mintVars:
14 | sysVars:
15 |
16 | vS0: DS 2 ; a
17 | vBase16: DS 2 ; b
18 | vTIBPtr: DS 2 ; c
19 | vDefs: DS 2 ; d
20 | vEdited: DS 2 ; e
21 | DS 2 ; f
22 | DS 2 ; g
23 | vHeapPtr: DS 2 ; h
24 | DS 2 ; i
25 | DS 2 ; j
26 | DS 2 ; k
27 | DS 2 ; l
28 | DS 2 ; m
29 | DS 2 ; n
30 | DS 2 ; o
31 | DS 2 ; p
32 | DS 2 ; q
33 | DS 2 ; r
34 | DS 2 ; s
35 | DS 2 ; t
36 | DS 2 ; u
37 | DS 2 ; v
38 | DS 2 ; w
39 | DS 2 ; x
40 | DS 2 ; y
41 | DS 2 ; z
42 |
43 | DS 2 ;
44 | vByteMode: DS 2 ;
45 | DS $30
46 | tbPtr: DS 2 ; reserved for tests
47 |
48 | RST08: DS 2
49 | RST10: DS 2
50 | RST18: DS 2
51 | RST20: DS 2
52 | RST28: DS 2
53 | RST30: DS 2 ;
54 | BAUD DS 2 ;
55 | INTVEC: DS 2 ;
56 | NMIVEC: DS 2 ;
57 | GETCVEC: DS 2 ;
58 | PUTCVEC: DS 2 ;
59 | ; ****************************************************************
60 | ; VARS Table - holds 26 16-bit user variables
61 | ; ****************************************************************
62 | vars: DS 26 * 2
63 |
64 | ; ****************************************************************
65 | ; DEFS Table - holds 26 addresses of user routines
66 | ; ****************************************************************
67 | .align $40
68 | .org $-12
69 | DS 12 ; vars for group 0
70 | defs: DS GRPSIZE * NUMGRPS
71 |
72 | HEAP:
73 |
--------------------------------------------------------------------------------
/rtest.z80:
--------------------------------------------------------------------------------
1 | ; .engine mycomputer
2 |
3 | .include "constants.asm"
4 | .include "IOSerial.asm"
5 |
6 | .macro testInput,s1
7 | ld HL,buf1%%M
8 | ld (tbPtr),HL
9 | jr buf2%%M
10 | buf1%%M:
11 | DB s1,$0D
12 | buf2%%M:
13 | .endm
14 |
15 | LD SP,DSTACK
16 | CALL initialize
17 | ld HL,testGetCharImpl ; change getchar implmentation to use tbuf
18 | LD (GETCVEC),HL
19 |
20 | testInput {"\\D."}
21 | JP interpret
22 |
23 | testGetCharImpl:
24 | PUSH HL
25 | LD HL,(tbPtr)
26 | LD A,(HL)
27 | INC HL
28 | LD (tbPtr),HL
29 | POP HL
30 | RET ;NZ flagged if character input
31 |
32 | .include "MINT.asm"
33 | .include "ram.asm"
34 |
--------------------------------------------------------------------------------
/tec-test.z80:
--------------------------------------------------------------------------------
1 | .engine mycomputer
2 |
3 | .include "constants.asm"
4 | .include "IOSerial.asm"
5 |
6 | .macro tec1Tables
7 | DB "\\[" ; char to 7 segments
8 | ; sp ! " # $ % & ' ( ) * + , - . /
9 | DB "#00 #18 #00 #00 #00 #00 #00 #00 "
10 | DB "#00 #04 #10 #00 #00 #00 #00 #00 "
11 | ; 0 1 2 3 4 5 6 7 8 9
12 | DB "#EB #28 #CD #AD #2E #A7 #E7 #29 #EF #2F "
13 | ; : ; < = > ? @
14 | DB "#00 #00 #00 #00 #00 #00 #00 "
15 | ; A B C D E F G H
16 | ; I J K L M N O P
17 | ; Q R S T U V W X
18 | ; Y Z
19 | DB " #6F #E6 #C3 #EC #C7 #47 #E3 #6E "
20 | DB " #28 #E8 #CE #C2 #6B #6B #EB #4F "
21 | DB " #2F #43 #A7 #46 #EA #E0 #EA #6E "
22 | DB " #AE #CD "
23 | DB "]' c!"
24 |
25 | DB "\\[0 0 0 0 0 0]' d!" ; display buffer
26 | .endm
27 |
28 | .macro tec1Defs
29 | DB ":A #20 - c@+ \\@;" ; char -- seg convert char to 7segments
30 | DB ":B \\@A$\\!;" ; buf str -- read char from string convert to seg and write to buffer
31 | DB ":C 1+$1+$;" ; buf str -- buf' str' increment str ptr and buf ptr
32 | DB ":D 6(%%B C)'';" ; buf str -- copy 6 chars from str to seg buffer
33 |
34 | DB ":E #40 |1\\O;" ; dig -- write digit bit, keep bit 6 high
35 | DB ":F \\@2\\O;" ; buf -- output segment + digit info to LEDs
36 | DB ":G }$1+$;" ; buf dig -- buf' dig' move to next segment, inc buf ptr
37 | DB ":H \\d@ #20 6(%%EF G)'' ;" ; -- display scan 6 digits
38 | DB ":I 100(H) 0E;" ; -- scan 255 times, then reset digit bit to 0
39 | DB ":J d@ ?X 3(%% \\i@+ DI)'';"
40 | .endm
41 |
42 | LD SP,DSTACK
43 | CALL initialize
44 | JP testsStart
45 |
46 | .include "MINT.asm"
47 | .include "ram.asm"
48 | .include "ftest.mac.asm"
49 |
50 | .org $4000
51 |
52 | testsStart:
53 |
54 | CALL enter
55 |
56 | utilDefs
57 | tec1Tables
58 | tec1Defs
59 |
60 | DB ":XHELLO THERE ITS ME AGAIN! ;"
61 | tester "", "10000() #41 #20 - c@ + \\@", "#6F"
62 | tester "", "72A", "#6E"
63 | tester "", "?X\\@A", "#6E"
64 | tester "", "d@ ?X D d@\\@", "#6E"
65 | tester "", "d@ ?X DI", ""
66 | tester "", "J\\P\\N", ""
67 |
68 | .cstr "`Done!`"
69 | HALT
70 |
71 |
72 |
--------------------------------------------------------------------------------
/test.mac.asm:
--------------------------------------------------------------------------------
1 | .macro expect,msg1,val1
2 | POP HL
3 | PUSH HL
4 | LD DE,val1
5 | OR A
6 | SBC HL,DE
7 | LD A,L
8 | OR H
9 | JR Z,expect%%M
10 | CALL enter
11 | .cstr "`",msg1,"`\\N`Actual: `\\P\\N"
12 | LD HL,val1
13 | PUSH HL
14 | CALL enter
15 | .cstr "`Expected: `."
16 | HALT
17 | .cstr
18 | expect%%M:
19 | POP HL
20 | .endm
21 |
22 | .macro test,code1,val1
23 | CALL enter
24 | .cstr code1
25 | expect code1,val1
26 | .endm
27 |
28 |
--------------------------------------------------------------------------------
/test.z80:
--------------------------------------------------------------------------------
1 | .engine mycomputer
2 |
3 | .include "constants.asm"
4 | .include "test.mac.asm"
5 |
6 | .include "IOSerial.asm"
7 |
8 | LD SP,DSTACK
9 | CALL initialize
10 | JP testsStart
11 |
12 | .include "MINT.asm"
13 | .include "ram.asm"
14 |
15 | .org $4000
16 |
17 | testsStart:
18 | test "0\\(100)(200)",200
19 | test "1\\(100)(200)",100
20 |
21 | ; CALL enter
22 | ; .cstr "`Done!!`"
23 | ; HALT
24 |
25 | test "2 3<", 1
26 | test "3 3<", 0
27 | test "3 3>", 0
28 | test "4 3>", 1
29 |
30 | test "0",0
31 | test "1",1
32 | test "1 2+", 3
33 | test "123 456+", 579
34 | test "1_ 2+",1
35 | ; test "1_\\_",1
36 | test "1 2+",3
37 | test "1_ 2+",1
38 | test "1_~",0
39 |
40 | test "1 2 3 \\R'' ", 2
41 | test "\\^A",65
42 |
43 | test "3x! 1 x\\+ x@", 4
44 | test "3x! 1_ x\\+ x@", 2
45 | test ":X1; X", 1
46 | test "2x! x@", 2
47 | test ":Aa!; 3A a@", 3
48 | test ":Aa!; :Ba@; 4AB", 4
49 |
50 | test "100 0(6)", 100
51 | test "100 1(6)", 6
52 | test "2(6)+", 12
53 | test "1(\\i@)", 0
54 | test "1(1(\\i@ \\j@+))", 0
55 | test "2(2(\\i@ \\j@))+++++++", 4
56 |
57 | test "0\\(100)(200)",200
58 | test "1\\(100)(200)",100
59 |
60 | test "0t! 10(1t\\+) t@",10
61 | test "0t! 10(\\i@ 4>\\B \\i@ 1t\\+) t@",5
62 | test "100a! 1 a\\+ a@", 101
63 |
64 | test "[3] '@", 3
65 | test "[3] $ ' ", 1
66 | test "[1 2 3] $ @ ", 1
67 | test "[]", 0
68 | test "0t! [1 2 3] $ a! ( a@ \\i@ {+ @ t\\+ ) t@", 6
69 | test "\\h@ [1 2 3]'' \\h@ $ - ", 6
70 |
71 | test "\\[3] ' \\@", 3
72 | test "\\[3] $ ' ", 1
73 | test "\\[1 2 3] $ \\@ ", 1
74 | test "\\[]", 0
75 | test "\\h@ \\[1 2 3]'' \\h@ $ - ", 3
76 |
77 | CALL enter
78 | DB "0 t!" ; total = 0
79 | DB "[1 2 3 4 5]" ; declare array, returns address length
80 | DB "$ a!" ; store address in a, leave length
81 | DB "(" ; loop
82 | DB "a@ \\i@ {+ @" ; access nth element
83 | DB "t\\+" ; add to total
84 | DB ")" ; end loop
85 | DB "t@" ; print total
86 | DB 0
87 | expect "sum over array",15
88 |
89 | CALL enter
90 | .cstr "`Done!`"
91 | HALT
92 |
--------------------------------------------------------------------------------