Commit edacf5d
committed
gec: operator-lamp / sleep(ms) / rand built-ins + examples/blink.c
Add compiler intrinsics handled in gen_builtin_call(), placed before the stdio
gate so they work without #include <stdio.h> (they ride on real CPU
instructions and runtime scratch only):
lon() light the OPER. CALL lamp (LON : 02 80, CI87 sets ALAM)
loff() extinguish it (LOFF: 02 40, CI88 resets ALAM)
sleep(ms) busy-wait n milliseconds (250 emulator cycles = 1 ms; a
calibrated nested loop, inner spin count tuned to ~98%)
rand() full-period 16-bit LCG (s = s*25173 + 13849, state __rseed
seeded in crt0; no hardware shift, hence an LCG not xorshift)
srand(seed) seed rand()
gec has no `long`/`bool` type, so counts and returns are int. lol() was dropped:
the OPER. CALL lamp FF (ALAM) is write-only to the program, so "read the lamp"
is not faithful.
examples/blink.c blinks the operator lamp on a ~500 ms (== 125000 instruction
clock) cycle, tracking on/off in a variable since ALAM is unreadable. Verified
via ./ge --trace cmds: CI87/CI88 fire at regular intervals. cc/test.sh: all
end-to-end examples pass.1 parent a60aeb3 commit edacf5d
2 files changed
Lines changed: 94 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
700 | 700 | | |
701 | 701 | | |
702 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
703 | 764 | | |
704 | 765 | | |
705 | 766 | | |
| |||
998 | 1059 | | |
999 | 1060 | | |
1000 | 1061 | | |
| 1062 | + | |
1001 | 1063 | | |
1002 | 1064 | | |
1003 | 1065 | | |
| |||
1007 | 1069 | | |
1008 | 1070 | | |
1009 | 1071 | | |
1010 | | - | |
| 1072 | + | |
| 1073 | + | |
1011 | 1074 | | |
1012 | 1075 | | |
1013 | 1076 | | |
| |||
0 commit comments