IRC channel logs

2024-09-15.log

back to list of logs

<matrix_bridge><cosinusoidally> Written an M0 implementation in awk https://github.com/cosinusoidally/tcc_bootstrap_alt/blob/dev/m2min/m0.awk . Currently only works in mawk, but I'll fix gawk at some point. Next I'll look at writing a hex2.awk
<matrix_bridge><cosinusoidally> That's probably the 4th awk program I've ever written so might not be the most idiomatic awk code.
<oriansj>cosinusoidally: interesting; if I am reading this correct your get_tok function is doing the wrong thing if given %label
<oriansj>(looks like I was wrong, >.< guess I am bad at reading awk scripts ;-p)
<oriansj>but you got the byte order wrong; %0x12345678 would be 78 56 34 12 on x86 (which I am assuming is your target architecture) unless the goal was to target knight which is Big Endian not Little byte endian.
<matrix_bridge><cosinusoidally> oriansj: in signed_int_to_hex there is code to convert hex literals into little endian hex strings. The t3 contains the hex digits, the order is then flipped by d1= t3[7] t3[8] t3[5] t3[6] t3[3] t3[4] t3[1] t3[2];
<matrix_bridge><cosinusoidally> So in theory 0x12345678 would become 78563412
<matrix_bridge><cosinusoidally> mk_m0_awk is slightly messy atm, but it does compare real output from M0 to the output from m0.awk
<matrix_bridge><cosinusoidally> which currently matches even when m0.awk processes a 0x.. hex literal
<Googulator>oriansj: would it be feasible to write an awk interpreter in M2-compatible C with enough functionality to kick off the awk-based tcc bootstrap?
<stikonas>Googulator: why wouldn't it be feasible...
<stikonas>though of course that's x86 only
<oriansj>Googulator: why not, we have unxz, ungz and with just a little bit of effort you should be able to get an awk in mescc-tools-extras
<oriansj>hus far we have learned, basically anything can be written in the M2-Planet C subset and will work (if one is willing to do the work)
<stikonas>well, M2 subset is not that small anymore
<stikonas>and some of the missing things can be workarounded
<stikonas>if you are writing your own code rather than compiling existing codebase
<oriansj>stikonas: fair enough; in M2-Planet we slowly grew from around 1Kloc to 15Kloc
<stikonas>yeah, though I guess it's not easy to extend it much more
<stikonas>actually, what are the biggest things we are missing?
<stikonas>you added switch/case last I think
<oriansj>yep
<stikonas>well, increment/decrement is missing, though it's not that much of a deal if you write your own code
<oriansj>just like a dozen minor C features one needs to directly build TCC
<stikonas>yaeh, tcc needs almost the whole C99...
<stikonas>well, floats can be patched out, that's what mescc does before building it
<oriansj>or if one looks at cosinusoidally's work; much less
<oriansj>as tcc 1.7 didn't have much preprocessor support or even goto support
<oriansj>or we could let someone fork M2-Planet and (assuming that they get 2-3 people to actively work on extending it) in 2 years it'll probably be able to build GCC directly.
<oriansj>as that ultimately seems to be the path for every C compiler written.
<oriansj>(build up to compile the TCC version that can build GCC or build GCC directly)