23 |
{props.instruction.label} {props.loc}
24 |
{OpcodesNames[props.instruction.opcode]}
25 |
{props.instruction.operandsString[0]}
26 |
{props.instruction.operandsString[1]}
27 |
{props.instruction.operandsString[2]}
28 |
29 | )
30 | }
31 |
32 | export default InstructionComponent;
33 |
--------------------------------------------------------------------------------
/src/test/functional/Superscalar/newop.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect, beforeEach, test } from 'vitest'
2 | import { Code } from '../../../core/Common/Code';
3 | import { Superscalar } from '../../../core/Superscalar/Superscalar';
4 | import { SuperscalarStatus } from '../../../core/Superscalar/SuperscalarEnums';
5 | import { codeInput, resultContent } from "../code/nuevaOp";
6 |
7 |
8 | const context: { code: Code, machine: Superscalar } = { code: null, machine: null };
9 |
10 | beforeEach(() => {
11 | context.code = new Code();
12 | context.machine = new Superscalar();
13 | context.machine.init(true);
14 | });
15 |
16 | test('nuevaOp.pla is executed properly', t => {
17 | // Execute code
18 | context.code.load(codeInput);
19 | context.machine.code = context.code;
20 | while (context.machine.tic() !== SuperscalarStatus.SUPER_ENDEXE) { }
21 |
22 | // Check registers
23 | const resultBase = 2;
24 | const result = context.machine.gpr.content.slice(
25 | resultBase, resultBase + resultContent.length
26 | );
27 | expect(result).toStrictEqual(resultContent);
28 |
29 | // Check where the program counter is
30 | expect(context.machine.pc).toBe(7);
31 |
32 | // Check the number of cycles are correct
33 | expect(context.machine.status.cycle).toBe(14);
34 |
35 | })
--------------------------------------------------------------------------------
/src/core/Common/Memory.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Returns an Error when target method is called with
3 | * a non-positive `address: number` argument.
4 | */
5 | export const forcePositiveAddresses = (address: number): Error | undefined => {
6 | if (address < 0) {
7 | return Error("Negative numbers are invalid as addresses");
8 | }
9 | };
10 |
11 | export class Memory implements Iterable