-
Notifications
You must be signed in to change notification settings - Fork 0
ridg
Duart Snel edited this page Jul 27, 2021
·
1 revision
IDG Higher level language playground.
x = 0 // memory location assignment (convenient label "x" for referring back to it)
$r1 = 0 // register assignment ($ indicates register)
ADD 10 x
ADD x 10 // add lit to mem location x
ADD 10 $r1 // add 10 to register 1
ADD x x // add 2 memory locations together
ADD $r1 $r2 // add 2 registers together
FUNCTION test
ADD 13 x
<some instruction>
<some instruction>
<some instruction> // Automatically returns when the functions ends (no tabs left)
<some instruction>
<some instruction>
<some instruction>
<some instruction>
CALL test
<some instruction>
<some instruction>
<some instruction>
y = 10 + 20
z = x + y
JUMPTO test IF z == 30 // jump to the function "test" if z == 30.. [==, !=, >, >=, <, <=]
k = IMAGE_WIDTH
k = IMAGE_HEIGHT
m = PIXELCOLORAT k k // need to first transform into pixel index here. (if it has more than 1 var we need to use an instruction as it needs to be determined at runtime)
m = PIXELCOLORAT k 2
m = PIXELCOLORAT 1 2
m = PIXELCOLORAT 534 // combined x and y into an index
l = PIXELINDEXAT x y // stores the result in "l"
l = PIXELINDEXAT 1 y
l = PIXELINDEXAT 1 2
$r1 = PIXELINDEXAT 1 2 // stores the result in register r1 (faster as it doesn't need to be moved off a temporary register)
############### MISC (sugar) ######################
car = {wheel: 2, engine: {cylinders: 4, power: 200}, id: 392} // internally resolves in the compiler. (basically fancy nested labels)
ADD 2 car.wheel // Add literal to car.wheel
ADD 2 (MULTIPLY 2 (MOVE 2 x)) // do the innermost operation first and then move outwards.
IMPORT "test.ridg" // include another instruction file into this one (at the imported location)