Skip to content

Commit

Permalink
fix dw and da
Browse files Browse the repository at this point in the history
  • Loading branch information
MESYETI committed Nov 18, 2023
1 parent 90db64d commit b636787
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion source/assembler/assembler.d
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,25 @@ class Assembler {
foreach (ref param ; node.params) {
switch (param.type) {
case NodeType.Integer: {
output ~= cast(ubyte) (cast(IntegerNode) param).value;
auto paramNode = cast(IntegerNode) param;
ubyte[] bytes;
auto val = paramNode.value;

final switch (inst.name) {
case "dw": {
bytes ~= cast(ubyte) (val & 0xFF);
bytes ~= cast(ubyte) ((val & 0xFF00) >> 8);
break;
}
case "da": {
bytes ~= cast(ubyte) (val & 0xFF);
bytes ~= cast(ubyte) ((val & 0xFF00) >> 8);
bytes ~= cast(ubyte) ((val & 0xFF0000) >> 16);
break;
}
}

output ~= bytes;
break;
}
default: {
Expand Down

0 comments on commit b636787

Please sign in to comment.