Skip to content

Commit

Permalink
fix: div instruction parsing and add test with mathlib (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusarich authored Jul 21, 2024
1 parent 09de023 commit 3fbebd4
Show file tree
Hide file tree
Showing 7 changed files with 2,925 additions and 3 deletions.
2 changes: 1 addition & 1 deletion reference/opcodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ opcodes:
MUL:

# A.5.2. Division.
DIV: ["bool", "int", "bool", "int", "int"]
DIV: ["bool", "int", "bool", "int", "int", "int"]

# A.5.3. Shifts, logical operations.
LSHIFT: ["int"]
Expand Down
2 changes: 1 addition & 1 deletion src/codepage/opcodes.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type OpCodeWithArgs =
| { code: 'PUSHCONT', args: [Cell, number, number, number, number] }
| { code: 'ADDCONST', args: [number] }
| { code: 'MULCONST', args: [number] }
| { code: 'DIV', args: [boolean, number, boolean, number, number] }
| { code: 'DIV', args: [boolean, number, boolean, number, number, number] }
| { code: 'LSHIFT', args: [number] }
| { code: 'RSHIFT', args: [number] }
| { code: 'FITS', args: [number] }
Expand Down
4 changes: 3 additions & 1 deletion src/codepage/opcodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,15 @@ CP0Auto.insertHex('a7', 8, (slice) => {
return { code: 'MULCONST', args: [x] };
});
CP0Auto.insertHex('a8', 8, { code: 'MUL' });

// #A9 m:uint1 s:uint2 cdft:(Either [ d:uint2 f:uint2 ] [ d:uint2 f:uint2 tt:uint8 ])
CP0Auto.insertHex('A9', 8, (slice) => {
let m = slice.loadBit();
let s = slice.loadUint(2);
let c = slice.loadBit();
let d = slice.loadUint(2);
let f = slice.loadUint(2);
return { code: 'DIV', args: [m, s, c, d, f] };
return { code: 'DIV', args: [m, s, c, d, f, c ? slice.loadUint(8) : 0] };
});
// 11079680 (DUMMY)
// 11132928 (DUMMY)
Expand Down
Loading

0 comments on commit 3fbebd4

Please sign in to comment.