Open kiranvshah opened 3 days ago
example from wikipedia:
INP
OUT // Initialize output
LOOP BRZ QUIT // Label this memory address as LOOP. If the accumulator value is 0, jump to the memory address labeled
// QUIT
SUB ONE // Subtract the value stored at address ONE from the accumulator
OUT
BRA LOOP // Jump (unconditionally) to the memory address labeled LOOP
QUIT HLT // Label this memory address as QUIT
ONE DAT 1 // Store the value 1 in this memory address, and label it ONE (variable declaration)
realised this when writing tests for compilation algorithm
see https://en.wikipedia.org/wiki/Little_man_computer#Labels, especially the examples beneath. like how you can write
label DAT 001
, you also need to be able to writelabel INP
, for example this is much like what i did in my prototype of assembly validation. i wonder if some of that logic could be reused for the assembly compilation algorithm (which needs updating) at the moment, branches can only lead to variables created with DAT - which are not instructions so this will not work