DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
199 stars 32 forks source link

Feature: arbitrary assembly output #245

Closed erkyrath closed 9 months ago

erkyrath commented 9 months ago

The @"asm" statement is pretty flexible. But for really radical game file generation, you might want to throw some literal bytes into the routine being compiled.

Possible syntax:

@@ 1 2 3 $FF;

This currently gives the error "Expected an opcode name but found @", so it's available for expansion.

erkyrath commented 9 months ago

Going farther, we might want symbols (object or function values or whatever) in the list. This is a bit tricky because now we're specifying words as well as bytes. Maybe

@@ 1 2 3 (Kitchen) 4 5;

Another possibility:

@ -> 1 2 3;
@ --> Kitchen;
@ -> 4 5;

There's also labels and branch offsets to think about. I haven't come up with a complete plan.

erkyrath commented 9 months ago

This offers the tempting idea of data blocks inside a Glulx function. (Perhaps a branch lookup table for a truly efficient switch statement?) We'd have to think of a way to get a label address into an expression. Also a way to suppress dead code elimination.

erkyrath commented 9 months ago

Finished with PR merge.

DavidKinder commented 9 months ago

I'd left this open as I believe that the idea of being able to reference symbols isn't done?

erkyrath commented 9 months ago

Symbols work.

It was referencing labels that I didn't do. But I didn't mention that in this issue, aside from the side comment "There's also labels and branch offsets to think about." So let's leave that for a future discussion.