Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Machine-code/Draco/machine-code-2.draco
Normal file
28
Task/Machine-code/Draco/machine-code-2.draco
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
proc nonrec main() void:
|
||||
word a, b, c;
|
||||
|
||||
/* assign values to the input variables */
|
||||
a := 12;
|
||||
b := 7;
|
||||
|
||||
/* inline machine code to add A and B
|
||||
*
|
||||
* Note that we have to cast each value to a byte,
|
||||
* because by default, numeric constants are assumed
|
||||
* to be 16-bit words, and would be emitted as two
|
||||
* bytes each.
|
||||
*
|
||||
* The intent is for the programmer to define byte
|
||||
* constants corresponding to opcodes, and write
|
||||
* "assembly", but that is beyond the scope here. */
|
||||
code(
|
||||
make(0x2A, byte), a, /* LHLD a - load var A into HL */
|
||||
make(0xEB, byte), /* XCHG - put it in DE */
|
||||
make(0x2A, byte), b, /* LHLD b - load var B into HL */
|
||||
make(0x19, byte), /* DAD D - add DE to HL */
|
||||
make(0x22, byte), c /* SHLD c - store the result in var C */
|
||||
);
|
||||
|
||||
/* print the result */
|
||||
writeln(c);
|
||||
corp
|
||||
Loading…
Add table
Add a link
Reference in a new issue