RosettaCodeData/Task/Machine-code/Draco/machine-code-1.draco

22 lines
640 B
Plaintext

/* 8080 machine code in an array */
[6] byte add_mc = (
0xC1, /* POP B - get return address */
0xD1, /* POP D - get second argument */
0xE1, /* POP H - get first argument */
0x19, /* DAD D - add arguments */
0xC5, /* PUSH B - push return address back */
0xC9 /* RET - return */
);
proc nonrec main() void:
/* Declare a function pointer */
type fn = proc(word a, b) word;
fn add;
/* Pretend the array is actually a function */
add := pretend(add_mc, fn);
/* Call the function and print the result */
writeln(add(12, 7))
corp