101010.pl is one of the many independent Mastodon servers you can use to participate in the fediverse.
101010.pl czyli najstarszy polski serwer Mastodon. Posiadamy wpisy do 2048 znaków.

Server stats:

475
active users

#quiche

0 posts0 participants0 posts today

I want the command line compiler to be able to generate interactive console apps which can run in it's built in emulator.

The first step is to be able to hook the emulator to create 'breakpoints'. Here it's hooking the CP/M BDOS address, reading register values from the emulator, and overwriting the opcode (read by the emulator) with a RETurn.

Opting for a CP/M style API will give me some CP/M support already in the compiler.

I'm nearly finished with sub-range types in the #quiche compiler. Most of the work has been around range checking when assigning to a sub-range, and hundreds of tests against edge cases. The only tests now failing are a couple to do with function arguments and return values.

Range checks work when passing a literal or a variable, but this test shows a fail when passing the result of a expression.

Sub-ranges feel like quite an obscure feature of a language. But in Pascal they're an essential part of arrays
array ['a'..'z'] of Integer
So I'm filling out their implementation before I continue with arrays. The next step is the assignment validation when range checking is on.

Before I got sidetracked into the type system I was working to get the command line compiler fully up and running.

The sticking point was command line arguments. I tried using #FreePascal's built in parser but it didn't have the flexibility I needed. I've now written something which does and I can now set the platform and deployment options.

#quiche #quichelang #compiler #pascal #z80

1/n

And writing to an array element. As before the index expression is parsed and an AddrOf operation added to the IL code, which generates the address to write to. Then the right hand side expression is parsed, and a PtrStore operation added to write the data to the address.

Moving towards array references in #Quiche. This code uses an index literal, an index variable, and an index expression.

A ParseArrayIndex function generates IL for the expression (if any), then an AddrOf operation which takes the array variable and index and returns a pointer to the data.

The a PtrLoad operation loads the data and stores to a variable.

There's no bounds validation or code yet, and only code generation for the literal case so far.

I moving on to start implementing user types in the #Quiche #compiler. I figure the most useful type to have is arrays and, by implication, strings. Arrays boil down to typed pointers internally so I'm starting with the pointer stuff.

This now works to assign the address of a variable to a typed pointer, and to instantiate a variable to assign that pointers value to. The PI variable is to test that assigning a ^Byte to it fails (which it does).

Adding array definitions to the #Quiche #Compiler

An array boils down to a bounds and an element type. For multidimensional arrays the 'inner' element type is itself an array definition.

The parser for this works recursively which gives an elegantly simple solution (although the actual code is a little gnarly given the syntaxes). Parsing the bounds is parsing a type definition (of a suitable enumerable type). Parsing the element type means parsing another array definition.

I'm making a start on user types in the compiler. Basic type synonyms and typed pointers can now be declared. I want to work on the declarations code and data structures first, so I can't yet instantiate these types but can use them in other type declarations.

I now have a command line compiler compiling under Lazarus/Free Pascal. That will allow it to run on numerous platforms and, probably, makes it easier for anyone to build themselves.

The work was pretty straightforward once I found the compatibility mode first Delphi syntax. The other changes were for code which manipulates file paths, where the libraries have diverged somewhat.

I’m now tweaking the directory structure and relevant code.

And that completes WHILE loops:
* Fixed a bug with phi node generation.
* Write self-tests
* Fixed an unrelated bug which allowed intrinsic identifiers to be parsed as infix operators (which caused the compiler to barf and error but not the correct one).

I remembered that the Amstrad has a powerful set of print control codes which can set screen mode, cursor location, ink number and palette colours. Now Quiche can output strings I'm having some fun with palette switching. A still image doesn't really do this justice.

Adding support for string constants. The concatenation is purely compile time. (String variables will require a /lot/ more work). Next up is a Write function for strings.

This is the first type which will only be referenced with pointers (as opposed to the variable containing the actual value itself) so it's something of a tester for how things will work. It also requires support for typed constant data and generating the assembly for them.

Continued thread

Making some improvements to the tracking of CPU state and I can now optimise away the test before the jump.

Ideally it would use the carry flag as returned by the call. The challenge is that the current register allocator only looks at the current operation and it needs to allocate something, and it knows a boolean can be converted to zero flag easier than boolean to carry flag, so it expects the value in zero flag.

Any better will need a better register allocator.