rp2040js 0.17.13 → 0.17.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -40,6 +40,8 @@ export declare class CortexM0Core {
|
|
|
40
40
|
VTOR: number;
|
|
41
41
|
SHPR2: number;
|
|
42
42
|
SHPR3: number;
|
|
43
|
+
/** Hook to listen for function calls - branch-link (BL/BLX) instructions */
|
|
44
|
+
blTaken: (core: CortexM0Core, blx: boolean) => void;
|
|
43
45
|
constructor(rp2040: RP2040);
|
|
44
46
|
get logger(): import(".").Logger;
|
|
45
47
|
reset(): void;
|
|
@@ -77,6 +77,11 @@ class CortexM0Core {
|
|
|
77
77
|
this.VTOR = 0;
|
|
78
78
|
this.SHPR2 = 0;
|
|
79
79
|
this.SHPR3 = 0;
|
|
80
|
+
/** Hook to listen for function calls - branch-link (BL/BLX) instructions */
|
|
81
|
+
this.blTaken = (core, blx) => {
|
|
82
|
+
void core; // surpress unused variable warnings
|
|
83
|
+
void blx;
|
|
84
|
+
};
|
|
80
85
|
this.SP = 0xfffffffc;
|
|
81
86
|
this.bankedSP = 0xfffffffc;
|
|
82
87
|
}
|
|
@@ -601,13 +606,12 @@ class CortexM0Core {
|
|
|
601
606
|
const Rm = (opcode >> 3) & 0x7;
|
|
602
607
|
const Rd = opcode & 0x7;
|
|
603
608
|
const input = this.registers[Rm];
|
|
604
|
-
const
|
|
609
|
+
const shiftN = imm5 ? imm5 : 32;
|
|
610
|
+
const result = shiftN < 32 ? input >> shiftN : (input & 0x80000000) >> 31;
|
|
605
611
|
this.registers[Rd] = result;
|
|
606
612
|
this.N = !!(result & 0x80000000);
|
|
607
613
|
this.Z = (result & 0xffffffff) === 0;
|
|
608
|
-
|
|
609
|
-
this.C = input & (1 << (imm5 - 1)) ? true : false;
|
|
610
|
-
}
|
|
614
|
+
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
611
615
|
}
|
|
612
616
|
// ASRS (register)
|
|
613
617
|
else if (opcode >> 6 === 0b0100000100) {
|
|
@@ -619,9 +623,7 @@ class CortexM0Core {
|
|
|
619
623
|
this.registers[Rdn] = result;
|
|
620
624
|
this.N = !!(result & 0x80000000);
|
|
621
625
|
this.Z = (result & 0xffffffff) === 0;
|
|
622
|
-
|
|
623
|
-
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
624
|
-
}
|
|
626
|
+
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
625
627
|
}
|
|
626
628
|
// B (with cond)
|
|
627
629
|
else if (opcode >> 12 === 0b1101 && ((opcode >> 9) & 0x7) !== 0b111) {
|
|
@@ -671,6 +673,7 @@ class CortexM0Core {
|
|
|
671
673
|
this.LR = (this.PC + 2) | 0x1;
|
|
672
674
|
this.PC += 2 + imm32;
|
|
673
675
|
this.cycles += 2;
|
|
676
|
+
this.blTaken(this, false);
|
|
674
677
|
}
|
|
675
678
|
// BLX
|
|
676
679
|
else if (opcode >> 7 === 0b010001111 && (opcode & 0x7) === 0) {
|
|
@@ -678,6 +681,7 @@ class CortexM0Core {
|
|
|
678
681
|
this.LR = this.PC | 0x1;
|
|
679
682
|
this.PC = this.registers[Rm] & ~1;
|
|
680
683
|
this.cycles++;
|
|
684
|
+
this.blTaken(this, true);
|
|
681
685
|
}
|
|
682
686
|
// BX
|
|
683
687
|
else if (opcode >> 7 === 0b010001110 && (opcode & 0x7) === 0) {
|
|
@@ -40,6 +40,8 @@ export declare class CortexM0Core {
|
|
|
40
40
|
VTOR: number;
|
|
41
41
|
SHPR2: number;
|
|
42
42
|
SHPR3: number;
|
|
43
|
+
/** Hook to listen for function calls - branch-link (BL/BLX) instructions */
|
|
44
|
+
blTaken: (core: CortexM0Core, blx: boolean) => void;
|
|
43
45
|
constructor(rp2040: RP2040);
|
|
44
46
|
get logger(): import("./index").Logger;
|
|
45
47
|
reset(): void;
|
|
@@ -74,6 +74,11 @@ export class CortexM0Core {
|
|
|
74
74
|
this.VTOR = 0;
|
|
75
75
|
this.SHPR2 = 0;
|
|
76
76
|
this.SHPR3 = 0;
|
|
77
|
+
/** Hook to listen for function calls - branch-link (BL/BLX) instructions */
|
|
78
|
+
this.blTaken = (core, blx) => {
|
|
79
|
+
void core; // surpress unused variable warnings
|
|
80
|
+
void blx;
|
|
81
|
+
};
|
|
77
82
|
this.SP = 0xfffffffc;
|
|
78
83
|
this.bankedSP = 0xfffffffc;
|
|
79
84
|
}
|
|
@@ -598,13 +603,12 @@ export class CortexM0Core {
|
|
|
598
603
|
const Rm = (opcode >> 3) & 0x7;
|
|
599
604
|
const Rd = opcode & 0x7;
|
|
600
605
|
const input = this.registers[Rm];
|
|
601
|
-
const
|
|
606
|
+
const shiftN = imm5 ? imm5 : 32;
|
|
607
|
+
const result = shiftN < 32 ? input >> shiftN : (input & 0x80000000) >> 31;
|
|
602
608
|
this.registers[Rd] = result;
|
|
603
609
|
this.N = !!(result & 0x80000000);
|
|
604
610
|
this.Z = (result & 0xffffffff) === 0;
|
|
605
|
-
|
|
606
|
-
this.C = input & (1 << (imm5 - 1)) ? true : false;
|
|
607
|
-
}
|
|
611
|
+
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
608
612
|
}
|
|
609
613
|
// ASRS (register)
|
|
610
614
|
else if (opcode >> 6 === 0b0100000100) {
|
|
@@ -616,9 +620,7 @@ export class CortexM0Core {
|
|
|
616
620
|
this.registers[Rdn] = result;
|
|
617
621
|
this.N = !!(result & 0x80000000);
|
|
618
622
|
this.Z = (result & 0xffffffff) === 0;
|
|
619
|
-
|
|
620
|
-
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
621
|
-
}
|
|
623
|
+
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
622
624
|
}
|
|
623
625
|
// B (with cond)
|
|
624
626
|
else if (opcode >> 12 === 0b1101 && ((opcode >> 9) & 0x7) !== 0b111) {
|
|
@@ -668,6 +670,7 @@ export class CortexM0Core {
|
|
|
668
670
|
this.LR = (this.PC + 2) | 0x1;
|
|
669
671
|
this.PC += 2 + imm32;
|
|
670
672
|
this.cycles += 2;
|
|
673
|
+
this.blTaken(this, false);
|
|
671
674
|
}
|
|
672
675
|
// BLX
|
|
673
676
|
else if (opcode >> 7 === 0b010001111 && (opcode & 0x7) === 0) {
|
|
@@ -675,6 +678,7 @@ export class CortexM0Core {
|
|
|
675
678
|
this.LR = this.PC | 0x1;
|
|
676
679
|
this.PC = this.registers[Rm] & ~1;
|
|
677
680
|
this.cycles++;
|
|
681
|
+
this.blTaken(this, true);
|
|
678
682
|
}
|
|
679
683
|
// BX
|
|
680
684
|
else if (opcode >> 7 === 0b010001110 && (opcode & 0x7) === 0) {
|