Skip to content

Commit

Permalink
Add missing const ops
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Dec 23, 2024
1 parent afdb54a commit 3e7099f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions asm/src/asm/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ fn register_stackops(t: &mut Opcodes) {
"NEGATE" => 0xa3,
"INC" => 0xa4,
"DEC" => 0xa5,
// TODO: "ADDCONST" | "ADDINT"
// TODO: "SUBCONST" | "SUBINT"
// TODO: "MULCONST" | "MULINT"
"ADDCONST" | "ADDINT" => 0xa6(i8),
"SUBCONST" | "SUBINT" => op_subconst,
"MULCONST" | "MULINT" => 0xa7(i8),
"MUL" => 0xa8,

"DIV" => 0xa904,
Expand Down Expand Up @@ -462,6 +462,8 @@ fn register_stackops(t: &mut Opcodes) {
"QNEGATE" => 0xb7a3,
"QINC" => 0xb7a4,
"QDEC" => 0xb7a5,
"QADDCONST" | "QADDINT" => 0xb7a6(i8),
"QMULCONST" | "QMULINT" => 0xb7a7(i8),
"QMUL" => 0xb7a8,
"QDIV" => 0xb7a904,
"QDIVR" => 0xb7a905,
Expand Down Expand Up @@ -1486,6 +1488,11 @@ fn op_pushcont(ctx: &mut Context, instr: &ast::Instr<'_>) -> Result<(), AsmError
write_pushcont(ctx, c).with_span(instr.span)
}

fn op_subconst(ctx: &mut Context, instr: &ast::Instr<'_>) -> Result<(), AsmError> {
let NatI8(s1) = instr.parse_args()?;
write_op_1sr_l(ctx, 0xa6, 8, -s1 as u8).with_span(instr.span)
}

fn op_pldrefidx(ctx: &mut Context, instr: &ast::Instr<'_>) -> Result<(), AsmError> {
let NatU2(s) = instr.parse_args()?;
ctx.get_builder(16)
Expand Down

0 comments on commit 3e7099f

Please sign in to comment.