Skip to content

Commit

Permalink
Fix lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Dec 29, 2024
1 parent 1d7aa1e commit e490eee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
19 changes: 9 additions & 10 deletions assembly/math.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NO_OF_REGISTERS} from "./registers";
import { NO_OF_REGISTERS } from "./registers";

/**
* Multiply two unsigned 64-bit numbers and take the upper 64-bits of the result.
Expand Down Expand Up @@ -32,11 +32,11 @@ export function mulUpperUnsigned(a: u64, b: u64): u64 {
* Same as [mulUpperUnsigned] but treat the arguments as signed (two-complement) 64-bit numbers and the result alike.
*/
export function mulUpperSigned(a: i64, b: i64): u64 {
const aSign = (a < 0) ? 1 : -1;
const bSign = (b < 0) ? 1 : -1;
const aSign = a < 0 ? 1 : -1;
const bSign = b < 0 ? 1 : -1;
const sign = aSign * bSign;
const aAbs = (a < 0) ? ~a + 1 : a;
const bAbs = (b < 0) ? ~b + 1 : b;
const aAbs = a < 0 ? ~a + 1 : a;
const bAbs = b < 0 ? ~b + 1 : b;

if (sign < 0) {
return ~mulUpperUnsigned(aAbs, bAbs) + 1;
Expand All @@ -45,21 +45,20 @@ export function mulUpperSigned(a: i64, b: i64): u64 {
}

export function mulUpperSignedUnsigned(a: i64, b: u64): u64 {
const aSign = (a < 0) ? 1 : -1;
const aSign = a < 0 ? 1 : -1;
if (aSign < 0) {
const aAbs = ~a + 1;
return ~mulUpperUnsigned(aAbs, b) + 1;
}
return mulUpperUnsigned(a, b);
}


@inline
// @inline
export function u32SignExtend(v: u32): i64 {
return i64(i32(v))
return i64(i32(v));
}

@inline
// @inline
export function reg(v: u64): u32 {
return v >= u64(NO_OF_REGISTERS) ? NO_OF_REGISTERS - 1 : u32(v);
}
Expand Down
3 changes: 2 additions & 1 deletion assembly/program-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ function skipBytes(kind: Arguments, data: Uint8Array): i32 {
return 1 + i32(Math.min(4, data.length));
case Arguments.TwoRegOneOff:
return 1 + i32(Math.min(4, data.length));
case Arguments.TwoRegTwoImm:
case Arguments.TwoRegTwoImm: {
const n = nibbles(data[1]);
const split = n.low + 1;
return 2 + split + immBytes(data.length, 2 + split);
}
case Arguments.ThreeReg:
return 2;
default:
Expand Down

0 comments on commit e490eee

Please sign in to comment.