Re: LCC for the Gigatron. Take two.
Posted: 02 Feb 2022, 10:16
Good point. I changed three variables to long type and at output %ld. Close to plus minus 2 147 000 000.
A place for Gigatron builders and hackers
https://forum.gigatron.io/
Code: Select all
$ glcc -map=sim gigatron/libc/tst/TSTstrtol.c -o tst.gt1 --frags > tst.frags
Code: Select all
Fragment map
08a0-08ff (96 bytes) CODE main (1/5) gigatron/libc/tst/TSTstrtol.c
0900-08ff (0 byte) DATA _@_using_lmov libc.a(rt_lmov)
09a0-09ff (96 bytes) CODE main (2/5) gigatron/libc/tst/TSTstrtol.c
0aa0-0afe (95 bytes) CODE main (3/5) gigatron/libc/tst/TSTstrtol.c
0ba0-0bfe (95 bytes) CODE main (4/5) gigatron/libc/tst/TSTstrtol.c
...
Code: Select all
$ gtsim -rom gigatron/roms/dev.rom -prof tst.prof tst.gt1
Code: Select all
prof={
# pc: cycs Number of cycles spent on vCPU instructions at address less than pc
0x08a0: 20,
0x08a2: 48,
0x08a4: 68,
0x08a6: 96,
0x08a8: 116,
...
Code: Select all
$ ./gigatron/mapsim/gtprof tst.prof tst.frags | sort -nr
6235414 TOTAL
1636568 __@mac32x16 libc.a(rt_lmul.s)
1592544 __@lshl1_t0t1 libc.a(rt_lshl1t0t1.s)
1256606 _@_ladd libc.a(rt_ladd.s)
547320 _strtol_push libc.a(strtol.c)
207832 _@_fcopyz_ libc.a(rt_copyz.s)
193212 _@_lmul libc.a(rt_lmul.s)
142740 _@_lcopy_ libc.a(rt_lcopy.s)
125616 worker libc.a(strtol.c)
79062 _@_lcmps libc.a(lcmp.s)
78094 atol libc.a(atol.c)
66364 main gigatron/libc/tst/TSTstrtol.c
61380 atoi libc.a(atoi.c)
35840 _@_rtrn_ff libc.a(rt_save.s)
31920 _@_lshru libc.a(rt_lshru.s)
29680 _@_save_ff libc.a(rt_save.s)
20236 strtoul libc.a(strtol.c)
20236 strtol libc.a(strtol.c)
19824 _@_land libc.a(rt_land.s)
18480 _@_lcmpx libc.a(lcmpx.s)
17406 _strtol_decode_s libc.a(strtol.c)
14484 isspace libc.a(isspace.c)
10320 _@_lshl libc.a(rt_lshl.s)
9860 printf libsim.a(printf.s)
9752 _strtol_decode_u libc.a(strtol.c)
6864 _@_lexts libc.a(rt_lexts.s)
1248 _@_lneg libc.a(rt_lneg.s)
658 _start libsim.a(_start.s)
568 .callchain libsim.a(_start.s)
442 _init_bss libc.a(_init1.c)
258 _gt1exec _gt1exec.s
Code: Select all
typedef struct channel_s {
char wavA, wavX;
char keyL, keyH;
char oscL, oscH;
} channel_t;
Code: Select all
channel1.wavA='0';
channel1.wavX='2';
channel1.keyL='1';
channel1.keyH='b';
Code: Select all
#include <gigatron/sys.h>
// Then use int SYS_Lup(unsigned int addr)
// This is not a real SYS call, just a wrapper around the LUP vCPU opcode.
// Example:
void setup_channel(int c, int noteoffset)
{
channel_t *chan = &channel(c)
chan->wavA = 0;
chan->wavX = 2;
chan->keyL = SYS_Lup(notestable + noteoffset);
chan->keyL = SYS_Lup(notestable + noteoffset + 1);
}