Skip to content

Commit 243b8f2

Browse files
committed
make jal with only label work
1 parent 90ceb18 commit 243b8f2

File tree

7 files changed

+24
-7
lines changed

7 files changed

+24
-7
lines changed

dist/webpage/assembler/assembler.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/webpage/assembler/assembler.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/webpage/assembler/instructions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313
{
314314
"name": "jal",
315315
"type": "J",
316-
"args": ["offreg"],
316+
"args": ["oreg","label"],
317317
"opcode": 111
318318
},
319319
{

dist/webpage/fetches.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/webpage/assembler/assembler.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ function assemble(files: [string, string][]) {
468468
}
469469
}
470470

471+
const putBack = () => {
472+
s--;
473+
};
474+
471475
const helperNext = (itterate = true) => {
472476
return lineArr[(s += +itterate) - +itterate];
473477
};
@@ -617,6 +621,19 @@ function assemble(files: [string, string][]) {
617621
}
618622
return Number(sym.content);
619623
}
624+
function getRegiOr0(float = false) {
625+
const sym = getNextSymbol();
626+
if (!sym || sym.type !== "register") {
627+
putBack();
628+
return 0;
629+
}
630+
if (!float && sym.floating) {
631+
throw new AssemblError(I18n.errors.expectIntReg(i + 1 + ""), i, file);
632+
} else if (float && !sym.floating) {
633+
throw new AssemblError(I18n.errors.expectFloatReg(i + 1 + ""), i, file);
634+
}
635+
return sym.number;
636+
}
620637
function getRegi(float = false) {
621638
const sym = getNextSymbol();
622639
if (!sym)
@@ -818,7 +835,7 @@ function assemble(files: [string, string][]) {
818835
break;
819836
}
820837
case "J": {
821-
const lay = info.opcode | (getRegi() << 7);
838+
const lay = info.opcode | (getRegiOr0() << 7);
822839
placeData({
823840
type: "instruction",
824841
content: lay,

src/webpage/assembler/instructions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313
{
314314
"name": "jal",
315315
"type": "J",
316-
"args": ["offreg"],
316+
"args": ["oreg","label"],
317317
"opcode": 111
318318
},
319319
{

src/webpage/fetches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type instructionType =
5454
| {
5555
name: string;
5656
type: "J";
57-
args: ["reg", "label"];
57+
args: ["oreg", "label"];
5858
opcode: number;
5959
}
6060
| {

0 commit comments

Comments
 (0)