CALL and RET instructions.
Changed PSHP and POPP into CALL and RET, streamlining their use for subroutine calls. Updated Assembler and Emulator. New demonstration programs.
This commit is contained in:
@@ -71,11 +71,14 @@ void assemblerCleanup(intermediateElement *intermediateArray, int arraySize, cha
|
||||
}
|
||||
// Free the intermediateArray itself.
|
||||
free(intermediateArray);
|
||||
|
||||
// Free the list of included files.
|
||||
freeIncludeList();
|
||||
|
||||
// Free the list of labels.
|
||||
freeLabelList();
|
||||
// Free the output file name.
|
||||
|
||||
// Free the output file name
|
||||
free(outputFileName);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ Instruction instruction_set[] = {
|
||||
{0x11, "BRQ"},
|
||||
{0x12, "BRA"},
|
||||
{0x13, "BRB"},
|
||||
{0x14, "CALL"},
|
||||
{0x15, "RET"},
|
||||
// Register Operations:
|
||||
{0x20, "RSTA"},
|
||||
{0x21, "RSTB"},
|
||||
@@ -42,12 +44,10 @@ Instruction instruction_set[] = {
|
||||
{0x30, "PSHQ"},
|
||||
{0x31, "PSHA"},
|
||||
{0x32, "PSHB"},
|
||||
{0x33, "PSHP"},
|
||||
{0x34, "PSHD"},
|
||||
{0x35, "POPA"},
|
||||
{0x36, "POPB"},
|
||||
{0x37, "POPP"},
|
||||
{0x38, "POPD"},
|
||||
{0x33, "PSHD"},
|
||||
{0x34, "POPA"},
|
||||
{0x35, "POPB"},
|
||||
{0x36, "POPD"},
|
||||
// Data Operations:
|
||||
{0x40, "INCD"},
|
||||
{0x41, "DECD"},
|
||||
|
||||
@@ -112,9 +112,9 @@ void populateOutputBuffers(intermediateElement *intermediateArray, int arraySize
|
||||
Program[(*programCount)++] = intermediateArray[i].byteValue;
|
||||
|
||||
// Check if it's a branch instruction.
|
||||
if ((intermediateArray[i].byteValue & 0xF0) == 0x10) {
|
||||
if (((intermediateArray[i].byteValue & 0xF0) == 0x10) && (intermediateArray[i].byteValue != 0x15)){
|
||||
if (intermediateArray[i + 1].type != LABEL) {
|
||||
fprintf(stderr, "Error: Branch without label.\n");
|
||||
fprintf(stderr, RED "Error: Branch without label.\n" RESET);
|
||||
printf("File: %s at line %d.\n", intermediateArray[i].fileName, intermediateArray[i].lineNumber);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user