Skip to content

Commit

Permalink
Add atomic instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruhlmann committed Dec 8, 2023
1 parent f008222 commit 9a9f199
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/instruction/atomic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ export * from "./greater_than";
export * from "./greater_than_equals";
export * from "./if";
export * from "./increment";
export * from "./int";
export * from "./left_shift";
export * from "./less_than";
export * from "./less_than_equals";
export * from "./literal";
export * from "./load";
export * from "./lodsb";
export * from "./marine";
export * from "./memory";
export * from "./next";
Expand Down
10 changes: 10 additions & 0 deletions src/instruction/atomic/int.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Instruction } from "../instruction";

export class InterruptInstruction extends Instruction {
public to_asm(_instruction_index: number): string {
return "pop ax\nint ax";
}
public to_wat(_instruction_index: number): string {
throw new Error("Method not implemented.");
}
}
10 changes: 10 additions & 0 deletions src/instruction/atomic/lodsb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Instruction } from "../instruction";

export class LoadStringBytesInstruction extends Instruction {
public to_asm(_instruction_index: number): string {
return "lodsb";
}
public to_wat(_instruction_index: number): string {
throw new Error("Method not implemented.");
}
}
8 changes: 6 additions & 2 deletions src/lexer/lookup_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import {
DropInstruction,
EndIfInstruction,
EqualityInstruction,
GreaterThanInstruction,
GreaterThanEqualsInstruction,
GreaterThanInstruction,
IncrementInstruction,
Instruction,
InterruptInstruction,
LeftBinaryShiftInstruction,
LessThanInstruction,
LessThanEqualsInstruction,
LessThanInstruction,
LoadMemoryInstruction,
LoadStringBytesInstruction,
MarineInstruction,
NotEqualityInstruction,
OverInstruction,
Expand Down Expand Up @@ -79,7 +81,9 @@ export class InstructionLookupTable {
else: UnreferencedElseInstruction,
endif: EndIfInstruction,
if: UnreferencedIfInstruction,
int: InterruptInstruction,
load: LoadMemoryInstruction,
lodsb: LoadStringBytesInstruction,
marine: MarineInstruction,
mem: PushMemoryPointerInstruction,
over: OverInstruction,
Expand Down

0 comments on commit 9a9f199

Please sign in to comment.