From ba54d070ceb879f1ec899c3c4c3f7e75a1b0bfea Mon Sep 17 00:00:00 2001 From: dhwanish-3 <108540722+dhwanish-3@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:42:38 +0530 Subject: [PATCH 1/2] Stage 23 + 2 Assgns + rootfile can being modified --- Stage23/Assgn1/create.expl | 14 + Stage23/Assgn1/create.xsm | 137 ++++++++ Stage23/Assgn2/delete.expl | 23 ++ Stage23/Assgn2/delete.xsm | 168 ++++++++++ Stage23/int15.spl | 33 ++ Stage23/int15.xsm | 91 +++++ Stage23/int4.spl | 159 +++++++++ Stage23/int4.xsm | 532 ++++++++++++++++++++++++++++++ Stage23/mod0.spl | 137 ++++++++ Stage23/mod0.xsm | 350 ++++++++++++++++++++ Stage23/mod4.spl | 96 ++++++ Stage23/mod4.xsm | 149 +++++++++ Stage23/mod7.spl | 203 ++++++++++++ Stage23/mod7.xsm | 392 ++++++++++++++++++++++ expl/assemblycode.xsm | 549 ++++--------------------------- xfs-interface/inodeusertable.txt | 128 +++---- xfs-interface/rootfile.txt | 78 ++--- xfs-interface/stage23.sh | 27 ++ 18 files changed, 2685 insertions(+), 581 deletions(-) create mode 100644 Stage23/Assgn1/create.expl create mode 100644 Stage23/Assgn1/create.xsm create mode 100644 Stage23/Assgn2/delete.expl create mode 100644 Stage23/Assgn2/delete.xsm create mode 100644 Stage23/int15.spl create mode 100644 Stage23/int15.xsm create mode 100644 Stage23/int4.spl create mode 100644 Stage23/int4.xsm create mode 100644 Stage23/mod0.spl create mode 100644 Stage23/mod0.xsm create mode 100644 Stage23/mod4.spl create mode 100644 Stage23/mod4.xsm create mode 100644 Stage23/mod7.spl create mode 100644 Stage23/mod7.xsm create mode 100644 xfs-interface/stage23.sh diff --git a/Stage23/Assgn1/create.expl b/Stage23/Assgn1/create.expl new file mode 100644 index 0000000..13a6cf7 --- /dev/null +++ b/Stage23/Assgn1/create.expl @@ -0,0 +1,14 @@ +int main() { + decl + int temp, permission; + str file; + enddecl + begin + temp = exposcall("Write", -2, "File Name:"); + temp = exposcall("Read", -1, file); + temp = exposcall("Write", -2, "Permission:"); + temp = exposcall("Read", -1, permission); + temp = exposcall("Create", file, permission); + return 0; + end +} \ No newline at end of file diff --git a/Stage23/Assgn1/create.xsm b/Stage23/Assgn1/create.xsm new file mode 100644 index 0000000..24eef80 --- /dev/null +++ b/Stage23/Assgn1/create.xsm @@ -0,0 +1,137 @@ +0 +2056 +0 +0 +0 +0 +0 +0 +MOV SP,4095 +MOV BP,4096 +PUSH R0 +CALL 2066 +INT 10 +PUSH BP +MOV BP,SP +PUSH R0 +PUSH R0 +PUSH R0 +MOV R0,"Write" +PUSH R0 +MOV R0,-2 +PUSH R0 +MOV R0,"File Name:" +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +MOV R0,"Read" +PUSH R0 +MOV R0,-1 +PUSH R0 +MOV R1,BP +MOV R0,3 +ADD R1,R0 +MOV R0,[R1] +MOV R0,R1 +MOV R0,R0 +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +MOV R0,"Write" +PUSH R0 +MOV R0,-2 +PUSH R0 +MOV R0,"Permission:" +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +MOV R0,"Read" +PUSH R0 +MOV R0,-1 +PUSH R0 +MOV R1,BP +MOV R0,2 +ADD R1,R0 +MOV R0,[R1] +MOV R0,R1 +MOV R0,R0 +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +MOV R0,"Create" +PUSH R0 +MOV R1,BP +MOV R0,3 +ADD R1,R0 +MOV R0,[R1] +MOV R0,R0 +PUSH R0 +MOV R2,BP +MOV R1,2 +ADD R2,R1 +MOV R1,[R2] +MOV R0,R1 +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +MOV R0,0 +MOV R1,BP +MOV R2,2 +SUB R1,R2 +MOV [R1],R0 +POP R0 +POP R0 +POP R0 +MOV BP,[SP] +POP R0 +RET diff --git a/Stage23/Assgn2/delete.expl b/Stage23/Assgn2/delete.expl new file mode 100644 index 0000000..18ac487 --- /dev/null +++ b/Stage23/Assgn2/delete.expl @@ -0,0 +1,23 @@ +int main() { + decl + int temp; + str file; + enddecl + begin + temp = exposcall("Write", -2, "File Name:"); + temp = exposcall("Read", -1, file); + temp = exposcall("Delete", file); + if(temp == 0) then + temp = exposcall("Write", -2, "Deleted"); + else + if(temp == -1) then + temp = exposcall("Write", -2, "no permission"); + else + if(temp == -2) then + temp = exposcall("Write", -2, "File open"); + endif; + endif; + endif; + return 0; + end +} \ No newline at end of file diff --git a/Stage23/Assgn2/delete.xsm b/Stage23/Assgn2/delete.xsm new file mode 100644 index 0000000..5985ea0 --- /dev/null +++ b/Stage23/Assgn2/delete.xsm @@ -0,0 +1,168 @@ +0 +2056 +0 +0 +0 +0 +0 +0 +MOV SP,4095 +MOV BP,4096 +PUSH R0 +CALL 2066 +INT 10 +PUSH BP +MOV BP,SP +PUSH R0 +PUSH R0 +MOV R0,"Write" +PUSH R0 +MOV R0,-2 +PUSH R0 +MOV R0,"File Name:" +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +MOV R0,"Read" +PUSH R0 +MOV R0,-1 +PUSH R0 +MOV R1,BP +MOV R0,2 +ADD R1,R0 +MOV R0,[R1] +MOV R0,R1 +MOV R0,R0 +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +MOV R0,"Delete" +PUSH R0 +MOV R1,BP +MOV R0,2 +ADD R1,R0 +MOV R0,[R1] +MOV R0,R0 +PUSH R0 +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +MOV R1,BP +MOV R0,1 +ADD R1,R0 +MOV R0,[R1] +MOV R1,0 +EQ R0,R1 +JZ R0,2250 +MOV R0,"Write" +PUSH R0 +MOV R0,-2 +PUSH R0 +MOV R0,"Deleted" +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +JMP 2356 +MOV R1,BP +MOV R0,1 +ADD R1,R0 +MOV R0,[R1] +MOV R1,-1 +EQ R0,R1 +JZ R0,2302 +MOV R0,"Write" +PUSH R0 +MOV R0,-2 +PUSH R0 +MOV R0,"no permission" +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] +MOV R2,BP +MOV R1,1 +ADD R2,R1 +MOV [R2],R0 +JMP 2356 +MOV R1,BP +MOV R0,1 +ADD R1,R0 +MOV R0,[R1] +MOV R1,-2 +EQ R0,R1 +JZ R0,2356 +PUSH R0 +MOV R0,"Write" +PUSH R0 +MOV R0,-2 +PUSH R0 +MOV R0,"File open" +PUSH R0 +PUSH R0 +PUSH R0 +CALL 0 +SUB SP,5 +POP R0 +MOV R1,6 +MOV R2,SP +ADD R2,R1 +MOV R1,[R2] +MOV R3,BP +MOV R2,1 +ADD R3,R2 +MOV [R3],R1 +MOV R0,0 +MOV R1,BP +MOV R2,2 +SUB R1,R2 +MOV [R1],R0 +POP R0 +POP R0 +MOV BP,[SP] +POP R0 +RET diff --git a/Stage23/int15.spl b/Stage23/int15.spl new file mode 100644 index 0000000..9eb6b3e --- /dev/null +++ b/Stage23/int15.spl @@ -0,0 +1,33 @@ +[PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13] = SP; +SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 11] * 512 - 1; + +[PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 9] = 21; + +if ([SYSTEM_STATUS_TABLE + 1] != 1 && [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 3] != 1) then + SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13]; + [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 9] = 0; + ireturn; +else + // inode table + R1 = 1; + R2 = [SYSTEM_STATUS_TABLE + 1]; + R3 = 59; + R4 = 3; + call DEVICE_MANAGER; + + // user table + R1 = 1; + R2 = [SYSTEM_STATUS_TABLE + 1]; + R3 = 60; + R4 = 4; + call DEVICE_MANAGER; + + // root file + R1 = 1; + R2 = [SYSTEM_STATUS_TABLE + 1]; + R3 = 62; + R4 = 5; + call DEVICE_MANAGER; + + halt; +endif; \ No newline at end of file diff --git a/Stage23/int15.xsm b/Stage23/int15.xsm new file mode 100644 index 0000000..0825dc6 --- /dev/null +++ b/Stage23/int15.xsm @@ -0,0 +1,91 @@ +MOV R16, 28672 +MOV R17, 29560 +ADD R17, 1 +MOV R17, [R17] +MUL R17, 16 +ADD R16, R17 +ADD R16, 13 +MOV [R16], SP +MOV R16, 28672 +MOV R17, 29560 +ADD R17, 1 +MOV R17, [R17] +MUL R17, 16 +ADD R16, R17 +ADD R16, 11 +MOV R16, [R16] +MUL R16, 512 +SUB R16, 1 +MOV SP, R16 +MOV R16, 28672 +MOV R17, 29560 +ADD R17, 1 +MOV R17, [R17] +MUL R17, 16 +ADD R16, R17 +ADD R16, 9 +MOV [R16], 21 +MOV R16, 29560 +ADD R16, 1 +MOV R16, [R16] +MOV R17, 1 +NE R16, R17 +MOV R17, 28672 +MOV R18, 29560 +ADD R18, 1 +MOV R18, [R18] +MUL R18, 16 +ADD R17, R18 +ADD R17, 3 +MOV R17, [R17] +MOV R18, 1 +NE R17, R18 +MUL R16, R17 +JZ R16, _L1 +MOV R16, 28672 +MOV R17, 29560 +ADD R17, 1 +MOV R17, [R17] +MUL R17, 16 +ADD R16, R17 +ADD R16, 13 +MOV R16, [R16] +MOV SP, R16 +MOV R16, 28672 +MOV R17, 29560 +ADD R17, 1 +MOV R17, [R17] +MUL R17, 16 +ADD R16, R17 +ADD R16, 9 +MOV [R16], 0 +IRET +JMP _L2 +_L1: +MOV R1, 1 +MOV R16, 29560 +ADD R16, 1 +MOV R16, [R16] +MOV R2, R16 +MOV R3, 59 +MOV R4, 3 +CALL 24576 +MOV R1, 1 +MOV R16, 29560 +ADD R16, 1 +MOV R16, [R16] +MOV R2, R16 +MOV R3, 60 +MOV R4, 4 +CALL 24576 +MOV R1, 1 +MOV R16, 29560 +ADD R16, 1 +MOV R16, [R16] +MOV R2, R16 +MOV R3, 62 +MOV R4, 5 +CALL 24576 +HALT +_L2: +HALT \ No newline at end of file diff --git a/Stage23/int4.spl b/Stage23/int4.spl new file mode 100644 index 0000000..127eb92 --- /dev/null +++ b/Stage23/int4.spl @@ -0,0 +1,159 @@ +[PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13] = SP; + +alias userSP R0; +userSP = SP; + +SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 11] * 512 - 1; + +alias sysCallNo R1; + +sysCallNo = [[PTBR + 2 * (userSP - 5) / 512] * 512 + (userSP - 5) % 512]; + +alias returnAddress R10; + +returnAddress = [PTBR + 2 * (userSP - 1) / 512] * 512 + (userSP - 1) % 512; + +[PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 9] = sysCallNo; + +alias fileName R2; +fileName = [[PTBR + 2 * (userSP - 4) / 512] * 512 + (userSP - 4) % 512]; + +alias i R3; +i = 0; +alias fileFound R4; +fileFound = 0; +while (i < MAX_FILE_NUM) do + if ([INODE_TABLE + i * 16 + 1] == fileName) then + fileFound = 1; + break; + endif; + i = i + 1; +endwhile; + +if (sysCallNo == 1) then // create + if (fileFound == 1) then + [returnAddress] = 0; + SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13]; + [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 9] = 0; + ireturn; + endif; + alias permission R5; + permission = [[PTBR + 2 * (userSP - 3) / 512] * 512 + (userSP - 3) % 512]; + + i = 0; + while (i < MAX_FILE_NUM) do + if ([INODE_TABLE + i * 16 + 1] == -1) then + break; + endif; + i = i + 1; + endwhile; + + if (i == MAX_FILE_NUM) then + [returnAddress] = -1; + else + alias inodeEntry R11; + inodeEntry = INODE_TABLE + i * 16; + alias userID R8; + userID = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 3]; + + [inodeEntry + 0] = DATA; + [inodeEntry + 1] = fileName; + [inodeEntry + 2] = 0; // file size + [inodeEntry + 3] = userID; + [inodeEntry + 4] = permission; + + [ROOT_FILE + i * 8 + 0] = fileName; + [ROOT_FILE + i * 8 + 1] = 9; + [ROOT_FILE + i * 8 + 2] = DATA; + [ROOT_FILE + i * 8 + 3] = [USER_TABLE + userID * 2]; + [ROOT_FILE + i * 8 + 4] = permission; + + [PROCESS_TABLE + i * 16 + 9] = 0; + [returnAddress] = 0; + endif; +endif; + +if (sysCallNo == 4) then // Delete + if (fileFound == 0) then + [returnAddress] = 0; + SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13]; + [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 9] = 0; + ireturn; + endif; + alias inodeEntry R11; + inodeEntry = INODE_TABLE + i * 16; + if ([inodeEntry + 0] != DATA) then + [returnAddress] = -1; + else + if ([inodeEntry + 4] == EXCLUSIVE && [SYSTEM_STATUS_TABLE + 1] != 1 && [inodeEntry + 3] != [PROCESS_TABLE + i * 16 + 3]) then + [returnAddress] = -1; + else + multipush(R0, R1, R2, R3, R4, R11); + R1 = 4; + R2 = i; + R3 = [SYSTEM_STATUS_TABLE + 1]; + call RESOURCE_MANAGER; + multipop(R0, R1, R2, R3, R4, R11); + + if ([FILE_STATUS_TABLE + i * 4 + 1] != -1) then // file is open + multipush(R0, R1, R2, R3, R4, R11); + R1 = 5; + R2 = i; + R3 = [SYSTEM_STATUS_TABLE + 1]; + call RESOURCE_MANAGER; + multipop(R0, R1, R2, R3, R4, R11); + [returnAddress] = -1; + else + alias blockNum R5; + blockNum = inodeEntry + 8; + alias limit R6; + limit = blockNum + 4; + while (blockNum < limit) do + if ([blockNum] == -1) then + break; + endif; + alias bufferIndex R7; + bufferIndex = [blockNum] % MAX_BUFFER; + if ([BUFFER_TABLE + bufferIndex * 4 + 0] == [blockNum] && [BUFFER_TABLE + bufferIndex * 4 + 1] == 1) then + [BUFFER_TABLE + bufferIndex * 4 + 1] = 0; + endif; + + multipush(R0, R1, R2, R3, R4, R5, R6, R7, R11); + R1 = 4; + R2 = [blockNum]; + R3 = [SYSTEM_STATUS_TABLE + 1]; + call MEMORY_MANAGER; + multipop(R0, R1, R2, R3, R4, R5, R6, R7, R11); + blockNum = blockNum + 1; + endwhile; + + alias inodePages R8; + inodePages = inodeEntry; + limit = inodePages + 16; + while (inodePages < limit) do + [inodePages] = -1; + inodePages = inodePages + 1; + endwhile; + + alias rootFile R8; + rootFile = ROOT_FILE + 8 * i; + limit = rootFile + 8; + while (rootFile < limit) do + [rootFile] = -1; + rootFile = rootFile + 1; + endwhile; + + multipush(R10); + R1 = 5; + R2 = i; + R3 = [SYSTEM_STATUS_TABLE + 1]; + call RESOURCE_MANAGER; + multipop(R10); + [returnAddress] = 0; + endif; + endif; + endif; +endif; + +SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13]; +ireturn; \ No newline at end of file diff --git a/Stage23/int4.xsm b/Stage23/int4.xsm new file mode 100644 index 0000000..13f98b9 --- /dev/null +++ b/Stage23/int4.xsm @@ -0,0 +1,532 @@ +MOV R16, 29560 +ADD R16, 1 +MOV R16, [R16] +MOV R12, R16 +MOV R16, 28672 +MOV R17, R12 +MUL R17, 16 +ADD R16, R17 +ADD R16, 13 +MOV [R16], SP +MOV R0, SP +MOV R16, 28672 +MOV R17, R12 +MUL R17, 16 +ADD R16, R17 +ADD R16, 11 +MOV R16, [R16] +MUL R16, 512 +SUB R16, 1 +MOV SP, R16 +MOV R16, 2 +MOV R17, R0 +SUB R17, 5 +MUL R16, R17 +DIV R16, 512 +ADD R16, PTBR +MOV R16, [R16] +MUL R16, 512 +MOV R2, R16 +MOV R16, R0 +SUB R16, 5 +MOD R16, 512 +MOV R3, R16 +MOV R16, R2 +ADD R16, R3 +MOV R16, [R16] +MOV R1, R16 +MOV R16, 2 +MOV R17, R0 +SUB R17, 1 +MUL R16, R17 +DIV R16, 512 +ADD R16, PTBR +MOV R16, [R16] +MUL R16, 512 +MOV R10, R16 +MOV R16, R0 +SUB R16, 1 +MOD R16, 512 +MOV R3, R16 +MOV R16, R10 +ADD R16, R3 +MOV R10, R16 +MOV R16, 28672 +MOV R17, R12 +MUL R17, 16 +ADD R16, R17 +ADD R16, 9 +MOV [R16], R1 +MOV R16, 1 +EQ R16, R1 +JZ R16, _L1 +MOV R16, 2 +MOV R17, R0 +SUB R17, 4 +MUL R16, R17 +DIV R16, 512 +ADD R16, PTBR +MOV R16, [R16] +MUL R16, 512 +MOV R2, R16 +MOV R16, R0 +SUB R16, 4 +MOD R16, 512 +MOV R3, R16 +MOV R16, R2 +ADD R16, R3 +MOV R16, [R16] +MOV R4, R16 +MOV R16, 2 +MOV R17, R0 +SUB R17, 3 +MUL R16, R17 +DIV R16, 512 +ADD R16, PTBR +MOV R16, [R16] +MUL R16, 512 +MOV R2, R16 +MOV R16, R0 +SUB R16, 3 +MOD R16, 512 +MOV R3, R16 +MOV R16, R2 +ADD R16, R3 +MOV R16, [R16] +MOV R5, R16 +MOV R6, 0 +MOV R7, 0 +_L3: +MOV R16, 60 +GT R16, R6 +JZ R16, _L4 +MOV R16, 30208 +MOV R17, R6 +MUL R17, 16 +ADD R16, R17 +ADD R16, 1 +MOV R16, [R16] +EQ R16, R4 +JZ R16, _L5 +MOV R7, 1 +JMP _L4 +JMP _L6 +_L5: +_L6: +MOV R16, R6 +ADD R16, 1 +MOV R6, R16 +JMP _L3 +_L4: +MOV R16, 1 +EQ R16, R7 +JZ R16, _L7 +MOV [R10], 0 +JMP _L8 +_L7: +MOV R6, 0 +_L9: +MOV R16, 60 +GT R16, R6 +JZ R16, _L10 +MOV R16, 30208 +MOV R17, R6 +MUL R17, 16 +ADD R16, R17 +ADD R16, 1 +MOV R16, [R16] +MOV R17, -1 +EQ R16, R17 +JZ R16, _L11 +JMP _L10 +JMP _L12 +_L11: +_L12: +MOV R16, R6 +ADD R16, 1 +MOV R6, R16 +JMP _L9 +_L10: +MOV R16, 60 +EQ R16, R6 +JZ R16, _L13 +MOV [R10], -1 +JMP _L14 +_L13: +MOV R16, 30208 +MOV R17, R6 +MUL R17, 16 +ADD R16, R17 +MOV R11, R16 +MOV R16, 28672 +MOV R17, R12 +MUL R17, 16 +ADD R16, R17 +ADD R16, 3 +MOV R16, [R16] +MOV R8, R16 +MOV R16, R11 +ADD R16, 0 +MOV [R16], 2 +MOV R16, R11 +ADD R16, 1 +MOV [R16], R4 +MOV R16, R11 +ADD R16, 2 +MOV [R16], 0 +MOV R16, R11 +ADD R16, 3 +MOV [R16], R8 +MOV R16, R11 +ADD R16, 4 +MOV [R16], R5 +MOV R16, 31744 +MOV R17, R6 +MUL R17, 8 +ADD R16, R17 +ADD R16, 0 +MOV [R16], R4 +MOV R16, 31744 +MOV R17, R6 +MUL R17, 8 +ADD R16, R17 +ADD R16, 1 +MOV [R16], 0 +MOV R16, 31744 +MOV R17, R6 +MUL R17, 8 +ADD R16, R17 +ADD R16, 2 +MOV [R16], 2 +MOV R16, 31744 +MOV R17, R6 +MUL R17, 8 +ADD R16, R17 +ADD R16, 3 +MOV R17, 31168 +MOV R18, R8 +MUL R18, 2 +ADD R17, R18 +MOV R17, [R17] +MOV [R16], R17 +MOV R16, 31744 +MOV R17, R6 +MUL R17, 8 +ADD R16, R17 +ADD R16, 4 +MOV [R16], R5 +MOV R16, 28672 +MOV R17, R12 +MUL R17, 16 +ADD R16, R17 +ADD R16, 9 +MOV [R16], 0 +MOV [R10], 0 +_L14: +_L8: +JMP _L2 +_L1: +_L2: +MOV R16, 4 +EQ R16, R1 +JZ R16, _L15 +MOV R4, 0 +MOV R16, 2 +MOV R17, R0 +SUB R17, 4 +MUL R16, R17 +DIV R16, 512 +ADD R16, PTBR +MOV R16, [R16] +MUL R16, 512 +MOV R17, R0 +SUB R17, 4 +MOD R17, 512 +ADD R16, R17 +MOV R16, [R16] +MOV R5, R16 +_L17: +MOV R16, 60 +GT R16, R4 +JZ R16, _L18 +MOV R16, 30208 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 1 +MOV R16, [R16] +EQ R16, R5 +JZ R16, _L19 +JMP _L18 +JMP _L20 +_L19: +_L20: +MOV R16, R4 +ADD R16, 1 +MOV R4, R16 +JMP _L17 +_L18: +MOV R16, 60 +EQ R16, R4 +JZ R16, _L21 +MOV [R10], 0 +JMP _L22 +_L21: +MOV R16, 30208 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +MOV R11, R16 +MOV R16, R11 +ADD R16, 0 +MOV R16, [R16] +MOV R17, 2 +NE R16, R17 +JZ R16, _L23 +MOV [R10], -1 +JMP _L24 +_L23: +MOV R16, R11 +ADD R16, 4 +MOV R16, [R16] +MOV R17, 0 +EQ R16, R17 +MOV R17, 1 +NE R17, R12 +MUL R16, R17 +MOV R17, R11 +ADD R17, 3 +MOV R17, [R17] +MOV R18, 28672 +MOV R19, R4 +MUL R19, 16 +ADD R18, R19 +ADD R18, 3 +MOV R18, [R18] +NE R17, R18 +MUL R16, R17 +JZ R16, _L25 +MOV [R10], -1 +JMP _L26 +_L25: +PUSH R0 +PUSH R1 +PUSH R2 +PUSH R3 +PUSH R4 +PUSH R5 +PUSH R10 +PUSH R11 +PUSH R12 +MOV R1, 4 +MOV R2, R4 +MOV R3, R12 +CALL 20480 +POP R12 +POP R11 +POP R10 +POP R5 +POP R4 +POP R3 +POP R2 +POP R1 +POP R0 +MOV R16, 29312 +MOV R17, R4 +MUL R17, 4 +ADD R16, R17 +ADD R16, 1 +MOV R16, [R16] +MOV R17, -1 +NE R16, R17 +JZ R16, _L27 +PUSH R0 +PUSH R1 +PUSH R2 +PUSH R3 +PUSH R4 +PUSH R5 +PUSH R10 +PUSH R11 +PUSH R12 +MOV R1, 5 +MOV R2, R4 +MOV R3, R12 +CALL 20480 +POP R12 +POP R11 +POP R10 +POP R5 +POP R4 +POP R3 +POP R2 +POP R1 +POP R0 +MOV [R10], -1 +JMP _L28 +_L27: +MOV R16, R11 +ADD R16, 8 +MOV R6, R16 +MOV R16, R6 +ADD R16, 4 +MOV R7, R16 +_L29: +MOV R16, R6 +LT R16, R7 +JZ R16, _L30 +MOV R16, R6 +MOV R16, [R16] +MOV R17, -1 +EQ R16, R17 +JZ R16, _L31 +JMP _L30 +JMP _L32 +_L31: +_L32: +MOV R16, R6 +MOV R16, [R16] +MOD R16, 4 +MOV R8, R16 +MOV R16, 30016 +MOV R17, R8 +MUL R17, 4 +ADD R16, R17 +ADD R16, 0 +MOV R16, [R16] +MOV R17, R6 +MOV R17, [R17] +EQ R16, R17 +MOV R17, 30016 +MOV R18, R8 +MUL R18, 4 +ADD R17, R18 +ADD R17, 1 +MOV R17, [R17] +MOV R18, 1 +EQ R17, R18 +MUL R16, R17 +JZ R16, _L33 +MOV R16, 30016 +MOV R17, R8 +MUL R17, 4 +ADD R16, R17 +ADD R16, 1 +MOV [R16], 0 +JMP _L34 +_L33: +_L34: +PUSH R0 +PUSH R1 +PUSH R2 +PUSH R3 +PUSH R4 +PUSH R5 +PUSH R6 +PUSH R7 +PUSH R8 +PUSH R10 +PUSH R11 +PUSH R12 +MOV R1, 4 +MOV R16, R6 +MOV R16, [R16] +MOV R2, R16 +MOV R3, R12 +CALL 22528 +POP R12 +POP R11 +POP R10 +POP R8 +POP R7 +POP R6 +POP R5 +POP R4 +POP R3 +POP R2 +POP R1 +POP R0 +MOV R16, R6 +ADD R16, 1 +MOV R6, R16 +JMP _L29 +_L30: +MOV R8, R11 +MOV R16, R8 +ADD R16, 16 +MOV R7, R16 +_L35: +MOV R16, R8 +LT R16, R7 +JZ R16, _L36 +MOV [R8], -1 +MOV R16, R8 +ADD R16, 1 +MOV R8, R16 +JMP _L35 +_L36: +MOV R16, 31744 +MOV R17, R4 +MUL R17, 8 +ADD R16, R17 +MOV R8, R16 +MOV R16, R8 +ADD R16, 8 +MOV R7, R16 +_L37: +MOV R16, R8 +LT R16, R7 +JZ R16, _L38 +MOV [R8], -1 +MOV R16, R8 +ADD R16, 1 +MOV R8, R16 +JMP _L37 +_L38: +PUSH R0 +PUSH R1 +PUSH R2 +PUSH R3 +PUSH R4 +PUSH R5 +PUSH R6 +PUSH R7 +PUSH R8 +PUSH R9 +PUSH R10 +PUSH R11 +PUSH R12 +MOV R1, 5 +MOV R2, R4 +MOV R3, R12 +CALL 20480 +POP R12 +POP R11 +POP R10 +POP R9 +POP R8 +POP R7 +POP R6 +POP R5 +POP R4 +POP R3 +POP R2 +POP R1 +POP R0 +MOV [R10], 0 +_L28: +_L26: +_L24: +_L22: +JMP _L16 +_L15: +_L16: +MOV R16, 28672 +MOV R17, R12 +MUL R17, 16 +ADD R16, R17 +ADD R16, 13 +MOV R16, [R16] +MOV SP, R16 +IRET +HALT \ No newline at end of file diff --git a/Stage23/mod0.spl b/Stage23/mod0.spl new file mode 100644 index 0000000..8923e7f --- /dev/null +++ b/Stage23/mod0.spl @@ -0,0 +1,137 @@ +alias functionNum R1; +alias currentPID R2; + +// Acquire Disk +if (functionNum == 3) then + while ([DISK_STATUS_TABLE] == 1) do + [PROCESS_TABLE + currentPID * 16 + 4] = WAIT_DISK; + multipush(R1, R2); + call MOD_5; + multipop(R1, R2); + endwhile; + [DISK_STATUS_TABLE] = 1; + [DISK_STATUS_TABLE + 4] = currentPID; + return; +endif; + +if (functionNum == 4) then // acquire inode + alias inodeNumber R2; + alias currentPID R3; + + while ([FILE_STATUS_TABLE + inodeNumber * 4 + 0] != -1) do + [PROCESS_TABLE + currentPID * 16 + 4] = WAIT_FILE; + [PROCESS_TABLE + currentPID * 16 + 5] = inodeNumber; + multipush(R1, R2, R3); + call SCHEDULER; + multipop(R1, R2, R3); + endwhile; + + // file delete check + if ([INODE_TABLE + inodeNumber * 16 + 1] == -1) then + R0 = -1; + else + [FILE_STATUS_TABLE + inodeNumber * 4 + 0] = currentPID; + R0 = 0; + endif; +endif; + +if (functionNum == 5) then // release inode + alias inodeNumber R2; + alias currentPID R3; + + if ([FILE_STATUS_TABLE + inodeNumber * 4 + 0] == currentPID) then + [FILE_STATUS_TABLE + inodeNumber * 4 + 0] = -1; + alias i R4; + i = 0; + while (i < MAX_FILE_NUM) do + if ([PROCESS_TABLE + i * 16 + 4] == WAIT_FILE && [PROCESS_TABLE + i * 16 + 5] == inodeNumber) then + [PROCESS_TABLE + i * 16 + 4] = READY; + endif; + i = i + 1; + endwhile; + R0 = 0; + else + R0 = -1; + endif; +endif; + +if (functionNum == 6) then // acquire semaphore + alias i R3; + i = 0; + while(i < MAX_SEM_COUNT && [SEMAPHORE_TABLE + 4 * i + 1] != 0) do + i = i + 1; + endwhile; + + if (i == MAX_SEM_COUNT) then + R0 = -1; + else + [SEMAPHORE_TABLE + 4 * i] = -1; + [SEMAPHORE_TABLE + 4 * i + 1] = 1; + R0 = i; + endif; + return; +endif; + +if (functionNum == 7) then // Release semaphore + alias semId R2; + alias currentPID R3; + + if (currentPID == [SEMAPHORE_TABLE + semId * 4]) then + [SEMAPHORE_TABLE + semId * 4] = -1; + alias i R4; + + i = 0; + while (i < 16) do + if ([PROCESS_TABLE + i * 16 + 4] == WAIT_SEMAPHORE && [PROCESS_TABLE + i * 16 + 5] == semId) then + [PROCESS_TABLE + i * 16 + 4] = READY; + [PROCESS_TABLE + i * 16 + 5] = -1; + endif; + i = i + 1; + endwhile; + + [SEMAPHORE_TABLE + 4 * semId + 1] = [SEMAPHORE_TABLE + 4 * semId + 1] - 1; + endif; + return; +endif; + +// Acquire Terminal +if (functionNum == 8) then + while ([TERMINAL_STATUS_TABLE] != 0) do + [PROCESS_TABLE + currentPID * 16 + 4] = WAIT_TERMINAL; + multipush(R1, R2); + + call MOD_5; + + multipop(R1, R2); + endwhile; + + [TERMINAL_STATUS_TABLE] = 1; + [TERMINAL_STATUS_TABLE + 1] = currentPID; + return; +endif; + +// Release Terminal +if (functionNum == 9) then + if (currentPID != [TERMINAL_STATUS_TABLE + 1]) then + alias returnValue R0; + returnValue = -1; + return; + else + [TERMINAL_STATUS_TABLE] = 0; + alias i R3; + i = 0; + while (i < 16) do + if ([PROCESS_TABLE + i * 16 + 4] == WAIT_TERMINAL) then + [PROCESS_TABLE + 16 * i + 4] = READY; + endif; + i = i + 1; + endwhile; + alias returnValue R0; + returnValue = 0; + return; + endif; +else + alias returnValue R0; + returnValue = -1; + return; +endif; \ No newline at end of file diff --git a/Stage23/mod0.xsm b/Stage23/mod0.xsm new file mode 100644 index 0000000..6e15400 --- /dev/null +++ b/Stage23/mod0.xsm @@ -0,0 +1,350 @@ +MOV R16, 3 +EQ R16, R1 +JZ R16, _L1 +_L3: +MOV R16, 29552 +MOV R16, [R16] +MOV R17, 1 +EQ R16, R17 +JZ R16, _L4 +MOV R16, 28672 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 5 +PUSH R1 +PUSH R2 +CALL 25600 +POP R2 +POP R1 +JMP _L3 +_L4: +MOV [29552], 1 +MOV R16, 29552 +ADD R16, 4 +MOV [R16], R2 +RET +JMP _L2 +_L1: +_L2: +MOV R16, 4 +EQ R16, R1 +JZ R16, _L5 +_L7: +MOV R16, 29312 +MOV R17, R2 +MUL R17, 4 +ADD R16, R17 +ADD R16, 0 +MOV R16, [R16] +MOV R17, -1 +NE R16, R17 +JZ R16, _L8 +MOV R16, 28672 +MOV R17, R3 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 6 +MOV R16, 28672 +MOV R17, R3 +MUL R17, 16 +ADD R16, R17 +ADD R16, 5 +MOV [R16], R2 +PUSH R1 +PUSH R2 +PUSH R3 +CALL 25600 +POP R3 +POP R2 +POP R1 +JMP _L7 +_L8: +MOV R16, 30208 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 1 +MOV R16, [R16] +MOV R17, -1 +EQ R16, R17 +JZ R16, _L9 +MOV R0, -1 +JMP _L10 +_L9: +MOV R16, 29312 +MOV R17, R2 +MUL R17, 4 +ADD R16, R17 +ADD R16, 0 +MOV [R16], R3 +MOV R0, 0 +_L10: +JMP _L6 +_L5: +_L6: +MOV R16, 5 +EQ R16, R1 +JZ R16, _L11 +MOV R16, 29312 +MOV R17, R2 +MUL R17, 4 +ADD R16, R17 +ADD R16, 0 +MOV R16, [R16] +EQ R16, R3 +JZ R16, _L13 +MOV R16, 29312 +MOV R17, R2 +MUL R17, 4 +ADD R16, R17 +ADD R16, 0 +MOV [R16], -1 +MOV R4, 0 +_L15: +MOV R16, 60 +GT R16, R4 +JZ R16, _L16 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV R16, [R16] +MOV R17, 6 +EQ R16, R17 +MOV R17, 28672 +MOV R18, R4 +MUL R18, 16 +ADD R17, R18 +ADD R17, 5 +MOV R17, [R17] +EQ R17, R2 +MUL R16, R17 +JZ R16, _L17 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 1 +JMP _L18 +_L17: +_L18: +MOV R16, R4 +ADD R16, 1 +MOV R4, R16 +JMP _L15 +_L16: +MOV R0, 0 +JMP _L14 +_L13: +MOV R0, -1 +_L14: +JMP _L12 +_L11: +_L12: +MOV R16, 6 +EQ R16, R1 +JZ R16, _L19 +MOV R3, 0 +_L21: +MOV R16, 32 +GT R16, R3 +MOV R17, 29056 +MOV R18, 4 +MUL R18, R3 +ADD R17, R18 +ADD R17, 1 +MOV R17, [R17] +MOV R18, 0 +NE R17, R18 +MUL R16, R17 +JZ R16, _L22 +MOV R16, R3 +ADD R16, 1 +MOV R3, R16 +JMP _L21 +_L22: +MOV R16, 32 +EQ R16, R3 +JZ R16, _L23 +MOV R0, -1 +JMP _L24 +_L23: +MOV R16, 29056 +MOV R17, 4 +MUL R17, R3 +ADD R16, R17 +MOV [R16], -1 +MOV R16, 29056 +MOV R17, 4 +MUL R17, R3 +ADD R16, R17 +ADD R16, 1 +MOV [R16], 1 +MOV R0, R3 +_L24: +RET +JMP _L20 +_L19: +_L20: +MOV R16, 7 +EQ R16, R1 +JZ R16, _L25 +MOV R16, 29056 +MOV R17, R2 +MUL R17, 4 +ADD R16, R17 +MOV R16, [R16] +EQ R16, R3 +JZ R16, _L27 +MOV R16, 29056 +MOV R17, R2 +MUL R17, 4 +ADD R16, R17 +MOV [R16], -1 +MOV R4, 0 +_L29: +MOV R16, 16 +GT R16, R4 +JZ R16, _L30 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV R16, [R16] +MOV R17, 10 +EQ R16, R17 +MOV R17, 28672 +MOV R18, R4 +MUL R18, 16 +ADD R17, R18 +ADD R17, 5 +MOV R17, [R17] +EQ R17, R2 +MUL R16, R17 +JZ R16, _L31 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 1 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 5 +MOV [R16], -1 +JMP _L32 +_L31: +_L32: +MOV R16, R4 +ADD R16, 1 +MOV R4, R16 +JMP _L29 +_L30: +MOV R16, 29056 +MOV R17, 4 +MUL R17, R2 +ADD R16, R17 +ADD R16, 1 +MOV R17, 29056 +MOV R18, 4 +MUL R18, R2 +ADD R17, R18 +ADD R17, 1 +MOV R17, [R17] +SUB R17, 1 +MOV [R16], R17 +JMP _L28 +_L27: +_L28: +RET +JMP _L26 +_L25: +_L26: +MOV R16, 8 +EQ R16, R1 +JZ R16, _L33 +_L35: +MOV R16, 29568 +MOV R16, [R16] +MOV R17, 0 +NE R16, R17 +JZ R16, _L36 +MOV R16, 28672 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 8 +PUSH R1 +PUSH R2 +CALL 25600 +POP R2 +POP R1 +JMP _L35 +_L36: +MOV [29568], 1 +MOV R16, 29568 +ADD R16, 1 +MOV [R16], R2 +RET +JMP _L34 +_L33: +_L34: +MOV R16, 9 +EQ R16, R1 +JZ R16, _L37 +MOV R16, 29568 +ADD R16, 1 +MOV R16, [R16] +NE R16, R2 +JZ R16, _L39 +MOV R0, -1 +RET +JMP _L40 +_L39: +MOV [29568], 0 +MOV R3, 0 +_L41: +MOV R16, 16 +GT R16, R3 +JZ R16, _L42 +MOV R16, 28672 +MOV R17, R3 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV R16, [R16] +MOV R17, 8 +EQ R16, R17 +JZ R16, _L43 +MOV R16, 28672 +MOV R17, 16 +MUL R17, R3 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 1 +JMP _L44 +_L43: +_L44: +MOV R16, R3 +ADD R16, 1 +MOV R3, R16 +JMP _L41 +_L42: +MOV R0, 0 +RET +_L40: +JMP _L38 +_L37: +MOV R0, -1 +RET +_L38: +HALT \ No newline at end of file diff --git a/Stage23/mod4.spl b/Stage23/mod4.spl new file mode 100644 index 0000000..59f87ec --- /dev/null +++ b/Stage23/mod4.spl @@ -0,0 +1,96 @@ +alias functionNum R1; +alias currentPID R2; +alias word R3; + +// Disk Store +if (functionNum == 1) then + alias pageNumber R3; + alias blockNum R4; + + multipush(R1, R2, R3, R4); + R1 = 3; + call RESOURCE_MANAGER; + multipop(R1, R2, R3, R4); + + [DISK_STATUS_TABLE + 1] = 1; + [DISK_STATUS_TABLE + 2] = pageNumber; + [DISK_STATUS_TABLE + 3] = blockNum; + + store(pageNumber, blockNum); + + [PROCESS_TABLE + currentPID * 16 + 4] = WAIT_DISK; + multipush(R1, R2, R3, R4); + call SCHEDULER; + multipop(R1, R2, R3, R4); +endif; + +// Disk Load +if (functionNum == 2) then + alias memoryPage R3; + alias diskBlock R4; + multipush(R1, R2, R3, R4); + + R1 = 3; + R2 = currentPID; + call MOD_0; + + multipop(R1, R2, R3, R4); + + [DISK_STATUS_TABLE + 1] = 0; + [DISK_STATUS_TABLE + 2] = memoryPage; + [DISK_STATUS_TABLE + 3] = diskBlock; + + load(memoryPage, diskBlock); + + [PROCESS_TABLE + currentPID * 16 + 4] = WAIT_DISK; + + call MOD_5; + + return; +endif; + +// Terminal Write +if (functionNum == 3) then + multipush(R1, R2, R3); + functionNum = 8; + + call MOD_0; + + multipop(R1, R2, R3); + + print word; + + multipush(R1, R2, R3); + + functionNum = 9; + + call MOD_0; + + multipop(R1, R2, R3); + + return; +endif; + +// Terminal Read +if (functionNum == 4) then + multipush(R1, R2, R3); + functionNum = 8; + + call MOD_0; + + multipop(R1, R2, R3); + + read; + + [PROCESS_TABLE + currentPID * 16 + 4] = WAIT_TERMINAL; + + multipush(R1, R2, R3); + + call MOD_5; + + multipop(R1, R2, R3); + + [[PTBR + 2 * (word / 512)] * 512 + (word % 512)] = [PROCESS_TABLE + currentPID * 16 + 8]; + + return; +endif; \ No newline at end of file diff --git a/Stage23/mod4.xsm b/Stage23/mod4.xsm new file mode 100644 index 0000000..20e4bd9 --- /dev/null +++ b/Stage23/mod4.xsm @@ -0,0 +1,149 @@ +MOV R16, 1 +EQ R16, R1 +JZ R16, _L1 +PUSH R1 +PUSH R2 +PUSH R3 +PUSH R4 +MOV R1, 3 +CALL 20480 +POP R4 +POP R3 +POP R2 +POP R1 +MOV R16, 29552 +ADD R16, 1 +MOV [R16], 1 +MOV R16, 29552 +ADD R16, 2 +MOV [R16], R3 +MOV R16, 29552 +ADD R16, 3 +MOV [R16], R4 +STORE R3, R4 +MOV R16, 28672 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 5 +PUSH R1 +PUSH R2 +PUSH R3 +PUSH R4 +CALL 25600 +POP R4 +POP R3 +POP R2 +POP R1 +JMP _L2 +_L1: +_L2: +MOV R16, 2 +EQ R16, R1 +JZ R16, _L3 +PUSH R1 +PUSH R2 +PUSH R3 +PUSH R4 +MOV R1, 3 +MOV R2, R2 +CALL 20480 +POP R4 +POP R3 +POP R2 +POP R1 +MOV R16, 29552 +ADD R16, 1 +MOV [R16], 0 +MOV R16, 29552 +ADD R16, 2 +MOV [R16], R3 +MOV R16, 29552 +ADD R16, 3 +MOV [R16], R4 +LOAD R3, R4 +MOV R16, 28672 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 5 +CALL 25600 +RET +JMP _L4 +_L3: +_L4: +MOV R16, 3 +EQ R16, R1 +JZ R16, _L5 +PUSH R1 +PUSH R2 +PUSH R3 +MOV R1, 8 +CALL 20480 +POP R3 +POP R2 +POP R1 +MOV R16, R3 +PORT P1, R16 +OUT +PUSH R1 +PUSH R2 +PUSH R3 +MOV R1, 9 +CALL 20480 +POP R3 +POP R2 +POP R1 +RET +JMP _L6 +_L5: +_L6: +MOV R16, 4 +EQ R16, R1 +JZ R16, _L7 +PUSH R1 +PUSH R2 +PUSH R3 +MOV R1, 8 +CALL 20480 +POP R3 +POP R2 +POP R1 +IN +MOV R16, 28672 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 8 +PUSH R1 +PUSH R2 +PUSH R3 +CALL 25600 +POP R3 +POP R2 +POP R1 +MOV R16, 2 +MOV R17, R3 +DIV R17, 512 +MUL R16, R17 +ADD R16, PTBR +MOV R16, [R16] +MUL R16, 512 +MOV R17, R3 +MOD R17, 512 +ADD R16, R17 +MOV R17, 28672 +MOV R18, R2 +MUL R18, 16 +ADD R17, R18 +ADD R17, 8 +MOV R17, [R17] +MOV [R16], R17 +RET +JMP _L8 +_L7: +_L8: +HALT \ No newline at end of file diff --git a/Stage23/mod7.spl b/Stage23/mod7.spl new file mode 100644 index 0000000..9e72e4f --- /dev/null +++ b/Stage23/mod7.spl @@ -0,0 +1,203 @@ +// exhandler +loadi(2, 15); +loadi(3, 16); + +// timer interrupt +loadi(4, 17); +loadi(5, 18); + +// write interrupt +loadi(16, 29); +loadi(17, 30); + +// int 10 +loadi(22, 35); +loadi(23, 36); + +// int 8 (fork) +loadi(18, 31); +loadi(19, 32); + +// Library +loadi(63, 13); +loadi(64, 14); + +// init +loadi(65, 7); +loadi(66, 8); + +// module 5 +loadi(50, 63); +loadi(51, 64); + +// module 0 +loadi(40, 53); +loadi(41, 54); + +// module 4 +loadi(48, 61); +loadi(49, 62); + +// console interrupt +loadi(8, 21); +loadi(9, 22); + +// int 6 +loadi(14, 27); +loadi(15, 28); + +// int 9 +loadi(20, 33); +loadi(21, 34); + +// int 11 +loadi(24, 37); +loadi(25, 38); + +// int 13 +loadi(28, 41); +loadi(29, 42); + +// int 14 +loadi(30, 43); +loadi(31, 44); + +// int 15 +loadi(32, 45); +loadi(33, 46); + +// module 1 +loadi(42, 55); +loadi(43, 56); + +// module 2 +loadi(44, 57); +loadi(45, 58); + +// inode user table +loadi(59, 3); +loadi(60, 4); + +// disk interrupt +loadi(6, 19); +loadi(7, 20); + +// int4 +loadi(10, 23); +loadi(11, 24); + +// root file +loadi(62, 5); + +// disk free list +loadi(61, 2); + +// memory free list initialization +alias i R0; +i = 0; +while (i < 128) do + if (i < 76) then + [MEMORY_FREE_LIST + i] = 1; + else + [MEMORY_FREE_LIST + i] = 0; + endif; + i = i + 1; +endwhile; + +[MEMORY_FREE_LIST + 76] = 1; +[MEMORY_FREE_LIST + 77] = 1; +[MEMORY_FREE_LIST + 78] = 1; +[MEMORY_FREE_LIST + 79] = 1; +[MEMORY_FREE_LIST + 80] = 1; +[MEMORY_FREE_LIST + 81] = 1; +[MEMORY_FREE_LIST + 82] = 1; + +PTBR = PAGE_TABLE_BASE + 20; +PTLR = 10; + +[PTBR + 0] = 63; +[PTBR + 1] = "0100"; +[PTBR + 2] = 64; +[PTBR + 3] = "0100"; +[PTBR + 4] = 78; +[PTBR + 5] = "0110"; +[PTBR + 6] = 79; +[PTBR + 7] = "0110"; +[PTBR + 8] = 65; +[PTBR + 9] = "0100"; +[PTBR + 10] = 66; +[PTBR + 11] = "0100"; +[PTBR + 12] = -1; +[PTBR + 13] = "0000"; +[PTBR + 14] = -1; +[PTBR + 15] = "0000"; +[PTBR + 16] = 76; +[PTBR + 17] = "0110"; +[PTBR + 18] = 77; +[PTBR + 19] = "0110"; + +[PROCESS_TABLE + 16 + 1] = 1; +[PROCESS_TABLE + 16 + 3] = 1; // user id +[PROCESS_TABLE + 16 + 11] = 80; +[PROCESS_TABLE + 16 + 12] = 0; +[PROCESS_TABLE + 16 + 13] = 8 * 512; +[PROCESS_TABLE + 16 + 14] = PTBR; +[PROCESS_TABLE + 16 + 15] = PTLR; +[PROCESS_TABLE + 16 + 4] = CREATED; +[76 * 512] = [65 * 512 + 1]; + +// per-process resource table for init +i = 1; +while (i < 9) do + [([PROCESS_TABLE + 16 + 11] + 1) * 512 - 2 * i] = -1; + i = i + 1; +endwhile; + +// disk map table initialization for init + +[DISK_MAP_TABLE + 10 + 2] = -1; +[DISK_MAP_TABLE + 10 + 3] = -1; +[DISK_MAP_TABLE + 10 + 4] = 7; +[DISK_MAP_TABLE + 10 + 5] = 8; +[DISK_MAP_TABLE + 10 + 6] = -1; +[DISK_MAP_TABLE + 10 + 7] = -1; +[DISK_MAP_TABLE + 10 + 8] = -1; +[DISK_MAP_TABLE + 10 + 9] = -1; + +i = 2; +while (i < 16) do + [PROCESS_TABLE + 16 * i + 4] = TERMINATED; + i = i + 1; +endwhile; + +[TERMINAL_STATUS_TABLE] = 0; +[DISK_STATUS_TABLE] = 0; +[SYSTEM_STATUS_TABLE + 0] = 0; +[SYSTEM_STATUS_TABLE + 2] = 45; +[SYSTEM_STATUS_TABLE + 3] = 0; + +// initialization of semaphore table +i = 0; +while (i < MAX_SEM_COUNT) do + [SEMAPHORE_TABLE + i * 4] = -1; + [SEMAPHORE_TABLE + i * 4 + 1] = 0; + i = i + 1; +endwhile; + +// initialization of file status table +i = 0; +while (i < MAX_FILE_NUM) do + [FILE_STATUS_TABLE + i * 4 + 0] = -1; + [FILE_STATUS_TABLE + i * 4 + 1] = -1; + i = i + 1; +endwhile; + +// initialization of buffer table +i = 0; +while (i < MAX_BUFFER) do + [BUFFER_TABLE + i * 4 + 0] = -1; + [BUFFER_TABLE + i * 4 + 1] = 0; + [BUFFER_TABLE + i * 4 + 2] = -1; + i = i + 1; +endwhile; +return; \ No newline at end of file diff --git a/Stage23/mod7.xsm b/Stage23/mod7.xsm new file mode 100644 index 0000000..f2dcd0d --- /dev/null +++ b/Stage23/mod7.xsm @@ -0,0 +1,392 @@ +MOV R16, 2 +LOADI R16, 15 +MOV R16, 3 +LOADI R16, 16 +MOV R16, 4 +LOADI R16, 17 +MOV R16, 5 +LOADI R16, 18 +MOV R16, 16 +LOADI R16, 29 +MOV R16, 17 +LOADI R16, 30 +MOV R16, 22 +LOADI R16, 35 +MOV R16, 23 +LOADI R16, 36 +MOV R16, 18 +LOADI R16, 31 +MOV R16, 19 +LOADI R16, 32 +MOV R16, 63 +LOADI R16, 13 +MOV R16, 64 +LOADI R16, 14 +MOV R16, 65 +LOADI R16, 7 +MOV R16, 66 +LOADI R16, 8 +MOV R16, 50 +LOADI R16, 63 +MOV R16, 51 +LOADI R16, 64 +MOV R16, 40 +LOADI R16, 53 +MOV R16, 41 +LOADI R16, 54 +MOV R16, 48 +LOADI R16, 61 +MOV R16, 49 +LOADI R16, 62 +MOV R16, 8 +LOADI R16, 21 +MOV R16, 9 +LOADI R16, 22 +MOV R16, 14 +LOADI R16, 27 +MOV R16, 15 +LOADI R16, 28 +MOV R16, 20 +LOADI R16, 33 +MOV R16, 21 +LOADI R16, 34 +MOV R16, 24 +LOADI R16, 37 +MOV R16, 25 +LOADI R16, 38 +MOV R16, 28 +LOADI R16, 41 +MOV R16, 29 +LOADI R16, 42 +MOV R16, 30 +LOADI R16, 43 +MOV R16, 31 +LOADI R16, 44 +MOV R16, 32 +LOADI R16, 45 +MOV R16, 33 +LOADI R16, 46 +MOV R16, 42 +LOADI R16, 55 +MOV R16, 43 +LOADI R16, 56 +MOV R16, 44 +LOADI R16, 57 +MOV R16, 45 +LOADI R16, 58 +MOV R16, 59 +LOADI R16, 3 +MOV R16, 60 +LOADI R16, 4 +MOV R16, 6 +LOADI R16, 19 +MOV R16, 7 +LOADI R16, 20 +MOV R16, 10 +LOADI R16, 23 +MOV R16, 11 +LOADI R16, 24 +MOV R16, 62 +LOADI R16, 5 +MOV R16, 61 +LOADI R16, 2 +MOV R0, 0 +_L1: +MOV R16, 128 +GT R16, R0 +JZ R16, _L2 +MOV R16, 76 +GT R16, R0 +JZ R16, _L3 +MOV R16, 29184 +ADD R16, R0 +MOV [R16], 1 +JMP _L4 +_L3: +MOV R16, 29184 +ADD R16, R0 +MOV [R16], 0 +_L4: +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L1 +_L2: +MOV R16, 29184 +ADD R16, 76 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 77 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 78 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 79 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 80 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 81 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 82 +MOV [R16], 1 +MOV R16, 29696 +ADD R16, 20 +MOV PTBR, R16 +MOV PTLR, 10 +MOV R16, PTBR +ADD R16, 0 +MOV [R16], 63 +MOV R16, PTBR +ADD R16, 1 +MOV [R16], "0100" +MOV R16, PTBR +ADD R16, 2 +MOV [R16], 64 +MOV R16, PTBR +ADD R16, 3 +MOV [R16], "0100" +MOV R16, PTBR +ADD R16, 4 +MOV [R16], 78 +MOV R16, PTBR +ADD R16, 5 +MOV [R16], "0110" +MOV R16, PTBR +ADD R16, 6 +MOV [R16], 79 +MOV R16, PTBR +ADD R16, 7 +MOV [R16], "0110" +MOV R16, PTBR +ADD R16, 8 +MOV [R16], 65 +MOV R16, PTBR +ADD R16, 9 +MOV [R16], "0100" +MOV R16, PTBR +ADD R16, 10 +MOV [R16], 66 +MOV R16, PTBR +ADD R16, 11 +MOV [R16], "0100" +MOV R16, PTBR +ADD R16, 12 +MOV [R16], -1 +MOV R16, PTBR +ADD R16, 13 +MOV [R16], "0000" +MOV R16, PTBR +ADD R16, 14 +MOV [R16], -1 +MOV R16, PTBR +ADD R16, 15 +MOV [R16], "0000" +MOV R16, PTBR +ADD R16, 16 +MOV [R16], 76 +MOV R16, PTBR +ADD R16, 17 +MOV [R16], "0110" +MOV R16, PTBR +ADD R16, 18 +MOV [R16], 77 +MOV R16, PTBR +ADD R16, 19 +MOV [R16], "0110" +MOV R16, 28672 +ADD R16, 16 +ADD R16, 1 +MOV [R16], 1 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 3 +MOV [R16], 1 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 11 +MOV [R16], 80 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 12 +MOV [R16], 0 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 13 +MOV R17, 8 +MUL R17, 512 +MOV [R16], R17 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 14 +MOV [R16], PTBR +MOV R16, 28672 +ADD R16, 16 +ADD R16, 15 +MOV [R16], PTLR +MOV R16, 28672 +ADD R16, 16 +ADD R16, 4 +MOV [R16], 3 +MOV R16, 76 +MUL R16, 512 +MOV R17, 65 +MUL R17, 512 +ADD R17, 1 +MOV R17, [R17] +MOV [R16], R17 +MOV R0, 1 +_L5: +MOV R16, 9 +GT R16, R0 +JZ R16, _L6 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 11 +MOV R16, [R16] +ADD R16, 1 +MUL R16, 512 +MOV R17, 2 +MUL R17, R0 +SUB R16, R17 +MOV [R16], -1 +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L5 +_L6: +MOV R16, 30032 +ADD R16, 10 +ADD R16, 2 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 3 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 4 +MOV [R16], 7 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 5 +MOV [R16], 8 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 6 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 7 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 8 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 9 +MOV [R16], -1 +MOV R0, 2 +_L7: +MOV R16, 16 +GT R16, R0 +JZ R16, _L8 +MOV R16, 28672 +MOV R17, 16 +MUL R17, R0 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 4 +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L7 +_L8: +MOV [29568], 0 +MOV [29552], 0 +MOV R16, 29560 +ADD R16, 0 +MOV [R16], 0 +MOV R16, 29560 +ADD R16, 2 +MOV [R16], 45 +MOV R16, 29560 +ADD R16, 3 +MOV [R16], 0 +MOV R0, 0 +_L9: +MOV R16, 32 +GT R16, R0 +JZ R16, _L10 +MOV R16, 29056 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +MOV [R16], -1 +MOV R16, 29056 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +ADD R16, 1 +MOV [R16], 0 +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L9 +_L10: +MOV R0, 0 +_L11: +MOV R16, 60 +GT R16, R0 +JZ R16, _L12 +MOV R16, 29312 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +ADD R16, 0 +MOV [R16], -1 +MOV R16, 29312 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +ADD R16, 1 +MOV [R16], -1 +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L11 +_L12: +MOV R0, 0 +_L13: +MOV R16, 4 +GT R16, R0 +JZ R16, _L14 +MOV R16, 30016 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +ADD R16, 0 +MOV [R16], -1 +MOV R16, 30016 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +ADD R16, 1 +MOV [R16], 0 +MOV R16, 30016 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +ADD R16, 2 +MOV [R16], -1 +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L13 +_L14: +RET +HALT \ No newline at end of file diff --git a/expl/assemblycode.xsm b/expl/assemblycode.xsm index 913e235..5985ea0 100644 --- a/expl/assemblycode.xsm +++ b/expl/assemblycode.xsm @@ -6,426 +6,117 @@ 0 0 0 -MOV SP,4096 -MOV BP,4097 +MOV SP,4095 +MOV BP,4096 PUSH R0 -CALL 2826 +CALL 2066 INT 10 PUSH BP MOV BP,SP PUSH R0 PUSH R0 +MOV R0,"Write" PUSH R0 +MOV R0,-2 PUSH R0 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,1 -SUB R1,R2 -MOV R0,[R1] -MOV R1,-1 -NE R0,R1 -MOV R1,1 -JZ R0,2122 -MOV R3,BP -MOV R4,2 -SUB R3,R4 -MOV R4,1 -SUB R3,R4 -MOV R2,[R3] -MOV R3,2 -ADD R3,R2 -MOV R2,[R3] -MOV R3,-1 -NE R2,R3 -MOV R1,R2 -MUL R0,R1 -JZ R0,2424 -MOV R2,BP -MOV R3,2 -SUB R2,R3 -MOV R3,1 -SUB R2,R3 -MOV R1,[R2] -MOV R3,BP -MOV R2,1 -ADD R3,R2 -MOV [R3],R1 -MOV R2,BP -MOV R3,2 -SUB R2,R3 -MOV R3,1 -SUB R2,R3 -MOV R1,[R2] -MOV R2,2 -ADD R2,R1 -MOV R1,[R2] -MOV R3,BP -MOV R2,2 -ADD R3,R2 -MOV [R3],R1 -MOV R2,BP -MOV R1,2 -ADD R2,R1 -MOV R1,[R2] -MOV R2,-1 -NE R1,R2 -JZ R1,2268 -MOV R2,BP -MOV R1,2 -ADD R2,R1 -MOV R1,[R2] -MOV R2,2 -ADD R2,R1 -MOV R1,[R2] -MOV R3,BP -MOV R2,2 -ADD R3,R2 -MOV [R3],R1 -MOV R2,BP -MOV R1,2 -ADD R2,R1 -MOV R1,[R2] -MOV R2,-1 -NE R1,R2 -JZ R1,2266 -MOV R3,BP -MOV R2,1 -ADD R3,R2 -MOV R2,[R3] -MOV R3,2 -ADD R3,R2 -MOV R2,[R3] -MOV R4,BP -MOV R3,1 -ADD R4,R3 -MOV [R4],R2 -MOV R3,BP -MOV R2,2 -ADD R3,R2 -MOV R2,[R3] -MOV R3,2 -ADD R3,R2 -MOV R2,[R3] -MOV R4,BP -MOV R3,2 -ADD R4,R3 -MOV [R4],R2 -JMP 2172 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,1 -SUB R1,R2 -MOV R0,[R1] -MOV R2,BP -MOV R1,3 -ADD R2,R1 -MOV [R2],R0 -MOV R1,BP -MOV R0,1 -ADD R1,R0 -MOV R0,[R1] -MOV R1,2 -ADD R1,R0 -MOV R0,[R1] -MOV R2,BP -MOV R1,4 -ADD R2,R1 -MOV [R2],R0 -MOV R0,-1 -MOV R2,BP -MOV R1,1 -ADD R2,R1 -MOV R1,[R2] -MOV R2,2 -ADD R2,R1 -MOV R1,[R2] -MOV R1,R2 -MOV [R1],R0 -MOV R1,BP -MOV R0,3 -ADD R1,R0 -MOV R0,[R1] -PUSH R0 -PUSH R0 -CALL 2066 -POP R0 -POP R1 -MOV R2,BP -MOV R1,3 -ADD R2,R1 -MOV [R2],R0 -MOV R1,BP -MOV R0,4 -ADD R1,R0 -MOV R0,[R1] +MOV R0,"File Name:" PUSH R0 PUSH R0 -CALL 2066 -POP R0 -POP R1 -MOV R2,BP -MOV R1,4 -ADD R2,R1 -MOV [R2],R0 -MOV R1,BP -MOV R0,4 -ADD R1,R0 -MOV R0,[R1] PUSH R0 -MOV R1,BP -MOV R0,3 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP ADD R1,R0 MOV R0,[R1] -PUSH R0 -PUSH R0 -CALL 2458 -POP R0 -POP R1 -POP R1 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,1 -SUB R1,R2 -MOV [R1],R0 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,1 -SUB R1,R2 -MOV R0,[R1] -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV [R1],R0 -POP R0 -POP R0 -POP R0 -POP R0 -MOV BP,[SP] -POP R0 -RET -PUSH BP -MOV BP,SP -PUSH R0 -MOV R0,-1 MOV R2,BP MOV R1,1 ADD R2,R1 MOV [R2],R0 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,1 -SUB R1,R2 -MOV R0,[R1] -MOV R1,-1 -EQ R0,R1 -JZ R0,2512 -MOV R2,BP -MOV R3,2 -SUB R2,R3 -MOV R3,2 -SUB R2,R3 -MOV R1,[R2] -MOV R3,BP -MOV R2,1 -ADD R3,R2 -MOV [R3],R1 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,2 -SUB R1,R2 -MOV R0,[R1] -MOV R1,-1 -EQ R0,R1 -JZ R0,2550 -MOV R2,BP -MOV R3,2 -SUB R2,R3 -MOV R3,1 -SUB R2,R3 -MOV R1,[R2] -MOV R3,BP -MOV R2,1 -ADD R3,R2 -MOV [R3],R1 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,1 -SUB R1,R2 -MOV R0,[R1] -MOV R1,-1 -NE R0,R1 -MOV R1,1 -JZ R0,2588 -MOV R3,BP -MOV R4,2 -SUB R3,R4 -MOV R4,2 -SUB R3,R4 -MOV R2,[R3] -MOV R3,-1 -NE R2,R3 -MOV R1,R2 -MUL R0,R1 -JZ R0,2802 -MOV R2,BP -MOV R3,2 -SUB R2,R3 -MOV R3,1 -SUB R2,R3 -MOV R1,[R2] -MOV R2,1 -ADD R2,R1 -MOV R1,[R2] -MOV R3,BP -MOV R4,2 -SUB R3,R4 -MOV R4,2 -SUB R3,R4 -MOV R2,[R3] -MOV R3,1 -ADD R3,R2 -MOV R2,[R3] -LE R1,R2 -JZ R1,2720 -MOV R2,BP -MOV R3,2 -SUB R2,R3 -MOV R3,1 -SUB R2,R3 -MOV R1,[R2] -MOV R3,BP -MOV R2,1 -ADD R3,R2 -MOV [R3],R1 +MOV R0,"Read" PUSH R0 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,2 -SUB R1,R2 -MOV R0,[R1] +MOV R0,-1 PUSH R0 MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,1 -SUB R1,R2 -MOV R0,[R1] -MOV R1,2 +MOV R0,2 ADD R1,R0 MOV R0,[R1] +MOV R0,R1 +MOV R0,R0 PUSH R0 PUSH R0 -CALL 2458 -POP R1 -POP R0 -POP R0 -POP R0 -MOV R3,BP -MOV R2,1 -ADD R3,R2 -MOV R2,[R3] -MOV R3,2 -ADD R3,R2 -MOV R2,[R3] -MOV R2,R3 -MOV [R2],R1 -JMP 2802 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,2 -SUB R1,R2 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 MOV R0,[R1] MOV R2,BP MOV R1,1 ADD R2,R1 MOV [R2],R0 +MOV R0,"Delete" +PUSH R0 MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,2 -SUB R1,R2 -MOV R0,[R1] -MOV R1,2 +MOV R0,2 ADD R1,R0 MOV R0,[R1] +MOV R0,R0 PUSH R0 -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV R2,1 -SUB R1,R2 -MOV R0,[R1] PUSH R0 PUSH R0 -CALL 2458 -POP R0 -POP R1 -POP R1 +PUSH R0 +CALL 0 +SUB SP,5 +MOV R0,5 +MOV R1,SP +ADD R1,R0 +MOV R0,[R1] MOV R2,BP MOV R1,1 ADD R2,R1 -MOV R1,[R2] -MOV R2,2 -ADD R2,R1 -MOV R1,[R2] -MOV R1,R2 -MOV [R1],R0 +MOV [R2],R0 MOV R1,BP MOV R0,1 ADD R1,R0 MOV R0,[R1] -MOV R1,BP -MOV R2,2 -SUB R1,R2 -MOV [R1],R0 -POP R0 -MOV BP,[SP] -POP R0 -RET -PUSH BP -MOV BP,SP -PUSH R0 +MOV R1,0 +EQ R0,R1 +JZ R0,2250 +MOV R0,"Write" PUSH R0 +MOV R0,-2 PUSH R0 +MOV R0,"Deleted" PUSH R0 -MOV R0,"Heapset" PUSH R0 -ADD SP,3 PUSH R0 CALL 0 SUB SP,5 -MOV R1,BP -MOV R0,1 +MOV R0,5 +MOV R1,SP ADD R1,R0 -MOV [R1],R0 -MOV R0,-1 -MOV [4096],R0 -MOV R0,0 +MOV R0,[R1] MOV R2,BP -MOV R1,2 +MOV R1,1 ADD R2,R1 MOV [R2],R0 +JMP 2356 MOV R1,BP -MOV R0,2 +MOV R0,1 ADD R1,R0 MOV R0,[R1] -MOV R1,64 -LT R0,R1 -JZ R0,3074 -MOV R0,"Alloc" +MOV R1,-1 +EQ R0,R1 +JZ R0,2302 +MOV R0,"Write" +PUSH R0 +MOV R0,-2 +PUSH R0 +MOV R0,"no permission" PUSH R0 -MOV R0,8 PUSH R0 -ADD SP,2 PUSH R0 CALL 0 SUB SP,5 @@ -434,142 +125,44 @@ MOV R1,SP ADD R1,R0 MOV R0,[R1] MOV R2,BP -MOV R1,3 -ADD R2,R1 -MOV [R2],R0 -MOV R0,64 -MOV R2,BP -MOV R1,2 -ADD R2,R1 -MOV R1,[R2] -SUB R0,R1 -MOV R2,BP -MOV R1,3 -ADD R2,R1 -MOV R1,[R2] -MOV R2,1 -ADD R2,R1 -MOV R1,[R2] -MOV R1,R2 -MOV [R1],R0 -MOV R0,-1 -MOV R2,BP -MOV R1,3 -ADD R2,R1 -MOV R1,[R2] -MOV R2,2 -ADD R2,R1 -MOV R1,[R2] -MOV R1,R2 -MOV [R1],R0 -MOV R0,[4096] -MOV R1,-1 -EQ R0,R1 -JZ R0,3004 -MOV R1,BP -MOV R0,3 -ADD R1,R0 -MOV R0,[R1] -MOV [4096],R0 -MOV R1,BP -MOV R0,3 -ADD R1,R0 -MOV R0,[R1] -MOV R2,BP -MOV R1,4 -ADD R2,R1 -MOV [R2],R0 -JMP 3052 -MOV R1,BP -MOV R0,3 -ADD R1,R0 -MOV R0,[R1] -MOV R2,BP -MOV R1,4 -ADD R2,R1 -MOV R1,[R2] -MOV R2,2 -ADD R2,R1 -MOV R1,[R2] -MOV R1,R2 -MOV [R1],R0 -MOV R1,BP -MOV R0,4 -ADD R1,R0 -MOV R0,[R1] -MOV R1,2 -ADD R1,R0 -MOV R0,[R1] -MOV R2,BP -MOV R1,4 -ADD R2,R1 -MOV [R2],R0 -MOV R1,BP -MOV R0,2 -ADD R1,R0 -MOV R0,[R1] MOV R1,1 -ADD R0,R1 -MOV R2,BP -MOV R1,2 -ADD R2,R1 -MOV [R2],R0 -JMP 2872 -MOV R0,[4096] -PUSH R0 -PUSH R0 -CALL 2066 -POP R0 -POP R1 -MOV [4096],R0 -MOV R0,[4096] -MOV R2,BP -MOV R1,3 ADD R2,R1 MOV [R2],R0 +JMP 2356 MOV R1,BP -MOV R0,3 +MOV R0,1 ADD R1,R0 MOV R0,[R1] -MOV R1,-1 -NE R0,R1 -JZ R0,3166 +MOV R1,-2 +EQ R0,R1 +JZ R0,2356 +PUSH R0 MOV R0,"Write" PUSH R0 MOV R0,-2 PUSH R0 -MOV R1,BP -MOV R0,3 -ADD R1,R0 -MOV R0,[R1] -MOV R1,1 -ADD R1,R0 -MOV R0,[R1] +MOV R0,"File open" +PUSH R0 +PUSH R0 PUSH R0 -ADD SP,2 CALL 0 SUB SP,5 -MOV R1,BP -MOV R0,3 -ADD R1,R0 -MOV R0,[R1] -MOV R1,2 -ADD R1,R0 -MOV R0,[R1] -MOV R2,BP -MOV R1,3 +POP R0 +MOV R1,6 +MOV R2,SP ADD R2,R1 -MOV [R2],R0 -JMP 3098 -MOV R0,1 +MOV R1,[R2] +MOV R3,BP +MOV R2,1 +ADD R3,R2 +MOV [R3],R1 +MOV R0,0 MOV R1,BP MOV R2,2 SUB R1,R2 MOV [R1],R0 POP R0 POP R0 -POP R0 -POP R0 MOV BP,[SP] POP R0 RET diff --git a/xfs-interface/inodeusertable.txt b/xfs-interface/inodeusertable.txt index 6834614..0e94179 100644 --- a/xfs-interface/inodeusertable.txt +++ b/xfs-interface/inodeusertable.txt @@ -30,13 +30,15 @@ even.xsm -1 -1 -1 --1 --1 +3 +prime.xsm +272 0 -1 -1 -1 -1 +70 -1 -1 -1 @@ -44,15 +46,15 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +3 +odd.xsm +144 0 -1 -1 -1 -1 +71 -1 -1 -1 @@ -60,31 +62,31 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +3 +exec.xsm +1516 0 -1 -1 -1 -1 +72 +73 +74 -1 -1 -1 -1 -1 --1 --1 --1 --1 --1 --1 +3 +list.xsm +508 0 -1 -1 -1 -1 +75 -1 -1 -1 @@ -92,15 +94,15 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +3 +pid.xsm +130 0 -1 -1 -1 -1 +76 -1 -1 -1 @@ -108,15 +110,15 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +3 +fork3.xsm +180 0 -1 -1 -1 -1 +77 -1 -1 -1 @@ -124,31 +126,31 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +3 +test4.xsm +990 0 -1 -1 -1 -1 +78 +79 -1 -1 -1 -1 -1 -1 --1 --1 --1 --1 --1 +3 +parent.xsm +280 0 -1 -1 -1 -1 +80 -1 -1 -1 @@ -156,15 +158,15 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +3 +child.xsm +328 0 -1 -1 -1 -1 +81 -1 -1 -1 @@ -172,47 +174,47 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +3 +con.xsm +1930 0 -1 -1 -1 -1 +82 +83 +84 +85 -1 -1 -1 -1 --1 --1 --1 --1 --1 --1 --1 +3 +seq.xsm +1150 0 -1 -1 -1 -1 +86 +87 +88 -1 -1 -1 -1 -1 --1 --1 --1 --1 --1 --1 +3 +create.xsm +274 0 -1 -1 -1 -1 +89 -1 -1 -1 @@ -220,15 +222,15 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +3 +delete.xsm +336 0 -1 -1 -1 -1 +90 -1 -1 -1 @@ -236,11 +238,11 @@ even.xsm -1 -1 -1 --1 --1 --1 --1 +2 +hari.dat 0 +1 +1 -1 -1 -1 @@ -256,8 +258,6 @@ even.xsm -1 -1 -1 -0 --1 -1 -1 -1 diff --git a/xfs-interface/rootfile.txt b/xfs-interface/rootfile.txt index 8d4d61d..377f8c2 100644 --- a/xfs-interface/rootfile.txt +++ b/xfs-interface/rootfile.txt @@ -14,105 +14,105 @@ even.xsm -1 -1 -1 --1 -0 --1 --1 --1 --1 --1 --1 --1 -0 --1 --1 --1 --1 --1 --1 --1 -0 --1 --1 --1 --1 --1 --1 --1 -0 --1 --1 --1 +prime.xsm +272 +3 -1 -1 -1 -1 -0 --1 -1 +odd.xsm +144 +3 -1 -1 -1 -1 -1 -0 +exec.xsm +1516 +3 -1 -1 -1 -1 -1 +list.xsm +508 +3 -1 -1 -0 -1 -1 -1 +pid.xsm +130 +3 -1 -1 -1 -1 -0 -1 +fork3.xsm +180 +3 -1 -1 -1 -1 -1 +test4.xsm +990 +3 -1 -0 -1 -1 -1 -1 +parent.xsm +280 +3 -1 -1 -1 -0 -1 -1 +child.xsm +328 +3 -1 -1 -1 -1 -1 -0 +con.xsm +1930 +3 -1 -1 -1 -1 -1 +seq.xsm +1150 +3 -1 -1 -0 -1 -1 -1 +create.xsm +274 +3 -1 -1 -1 -1 -0 -1 +delete.xsm +336 +3 -1 -1 -1 diff --git a/xfs-interface/stage23.sh b/xfs-interface/stage23.sh new file mode 100644 index 0000000..b902a08 --- /dev/null +++ b/xfs-interface/stage23.sh @@ -0,0 +1,27 @@ +load --os $HOME/myexpos/Stage13/os_startup.xsm +load --init $HOME/myexpos/Stage21/Assgn1/shell2.xsm +load --idle $HOME/myexpos/Stage14/idle.xsm +load --int=10 $HOME/myexpos/Stage20/exit.xsm +load --int=11 $HOME/myexpos/Stage21/int11.xsm +load --int=13 $HOME/myexpos/Stage22/int13.xsm +load --int=14 $HOME/myexpos/Stage22/int14.xsm +load --int=15 $HOME/myexpos/Stage23/int15.xsm +load --int=9 $HOME/myexpos/Stage19/int9.xsm +load --int=8 $HOME/myexpos/Stage22/fork.xsm +load --exhandler $HOME/myexpos/Stage21/exhandler.xsm +load --int=7 $HOME/myexpos/Stage15/int7.xsm +load --int=6 $HOME/myexpos/Stage16/int6.xsm +load --int=4 $HOME/myexpos/Stage23/int4.xsm +load --int=disk $HOME/myexpos/Stage18/int2.xsm +load --int=console $HOME/myexpos/Stage16/console_int.xsm +load --module 5 $HOME/myexpos/Stage20/scheduler.xsm +load --module 7 $HOME/myexpos/Stage23/mod7.xsm +load --module 0 $HOME/myexpos/Stage23/mod0.xsm +load --module 1 $HOME/myexpos/Stage22/mod1.xsm +load --module 2 $HOME/myexpos/Stage19/module_2.xsm +load --module 4 $HOME/myexpos/Stage23/mod4.xsm +load --int=timer $HOME/myexpos/Stage14/timer.xsm +rm create.xsm +load --exec $HOME/myexpos/Stage23/Assgn1/create.xsm +rm delete.xsm +load --exec $HOME/myexpos/Stage23/Assgn2/delete.xsm \ No newline at end of file From 5671fa02e4f579dde83d8e17dca5c9fd61ff81b6 Mon Sep 17 00:00:00 2001 From: dhwanish-3 <108540722+dhwanish-3@users.noreply.github.com> Date: Mon, 23 Oct 2023 21:35:52 +0530 Subject: [PATCH 2/2] Stage 22 Max memory done* --- Stage22/Assgn2/int15.spl | 11 ++ Stage22/Assgn2/int15.xsm | 34 ++++ Stage22/Assgn2/mod0.spl | 98 +++++++++++ Stage22/Assgn2/mod0.xsm | 239 ++++++++++++++++++++++++++ Stage22/Assgn2/mod5.spl | 50 ++++++ Stage22/Assgn2/mod5.xsm | 113 ++++++++++++ Stage22/Assgn2/mod7.spl | 182 ++++++++++++++++++++ Stage22/Assgn2/mod7.xsm | 341 +++++++++++++++++++++++++++++++++++++ Stage22/Assgn2/timer.spl | 36 ++++ Stage22/Assgn2/timer.xsm | 87 ++++++++++ xfs-interface/stage22_2.sh | 32 ++++ 11 files changed, 1223 insertions(+) create mode 100644 Stage22/Assgn2/int15.spl create mode 100644 Stage22/Assgn2/int15.xsm create mode 100644 Stage22/Assgn2/mod0.spl create mode 100644 Stage22/Assgn2/mod0.xsm create mode 100644 Stage22/Assgn2/mod5.spl create mode 100644 Stage22/Assgn2/mod5.xsm create mode 100644 Stage22/Assgn2/mod7.spl create mode 100644 Stage22/Assgn2/mod7.xsm create mode 100644 Stage22/Assgn2/timer.spl create mode 100644 Stage22/Assgn2/timer.xsm create mode 100644 xfs-interface/stage22_2.sh diff --git a/Stage22/Assgn2/int15.spl b/Stage22/Assgn2/int15.spl new file mode 100644 index 0000000..54b25f6 --- /dev/null +++ b/Stage22/Assgn2/int15.spl @@ -0,0 +1,11 @@ +alias taskManager R0; +taskManager = SYSTEM_STATUS_TABLE + 24; +print "contextSwitches:-"; +print [taskManager]; +print "------------"; +print "maxMemUsage:-"; +print [taskManager + 1]; +print "------------"; +print "diskAccesses:-"; +print [taskManager + 2]; +halt; \ No newline at end of file diff --git a/Stage22/Assgn2/int15.xsm b/Stage22/Assgn2/int15.xsm new file mode 100644 index 0000000..ff3915e --- /dev/null +++ b/Stage22/Assgn2/int15.xsm @@ -0,0 +1,34 @@ +MOV R16, 29560 +ADD R16, 24 +MOV R0, R16 +MOV R16, "contextSwitches:-" +PORT P1, R16 +OUT +MOV R16, R0 +MOV R16, [R16] +PORT P1, R16 +OUT +MOV R16, "------------" +PORT P1, R16 +OUT +MOV R16, "maxMemUsage:-" +PORT P1, R16 +OUT +MOV R16, R0 +ADD R16, 1 +MOV R16, [R16] +PORT P1, R16 +OUT +MOV R16, "------------" +PORT P1, R16 +OUT +MOV R16, "diskAccesses:-" +PORT P1, R16 +OUT +MOV R16, R0 +ADD R16, 2 +MOV R16, [R16] +PORT P1, R16 +OUT +HALT +HALT \ No newline at end of file diff --git a/Stage22/Assgn2/mod0.spl b/Stage22/Assgn2/mod0.spl new file mode 100644 index 0000000..3361a78 --- /dev/null +++ b/Stage22/Assgn2/mod0.spl @@ -0,0 +1,98 @@ +alias functionNum R1; +alias currentPID R2; + +// Acquire Disk +if (functionNum == 3) then + while ([DISK_STATUS_TABLE] == 1) do + [PROCESS_TABLE + currentPID * 16 + 4] = WAIT_DISK; + multipush(R1, R2); + call MOD_5; + multipop(R1, R2); + endwhile; + // disk accesses + [SYSTEM_STATUS_TABLE + 26] = [SYSTEM_STATUS_TABLE + 26] + 1; + [DISK_STATUS_TABLE] = 1; + [DISK_STATUS_TABLE + 4] = currentPID; + return; +endif; + +if (functionNum == 6) then // acquire semaphore + alias i R3; + i = 0; + while(i < MAX_SEM_COUNT && [SEMAPHORE_TABLE + 4 * i + 1] != 0) do + i = i + 1; + endwhile; + + if (i == MAX_SEM_COUNT) then + R0 = -1; + else + [SEMAPHORE_TABLE + 4 * i] = -1; + [SEMAPHORE_TABLE + 4 * i + 1] = 1; + R0 = i; + endif; + return; +endif; + +if (functionNum == 7) then // Release semaphore + alias semId R2; + alias currentPID R3; + + if (currentPID == [SEMAPHORE_TABLE + semId * 4]) then + [SEMAPHORE_TABLE + semId * 4] = -1; + alias i R4; + + i = 0; + while (i < 16) do + if ([PROCESS_TABLE + i * 16 + 4] == WAIT_SEMAPHORE && [PROCESS_TABLE + i * 16 + 5] == semId) then + [PROCESS_TABLE + i * 16 + 4] = READY; + [PROCESS_TABLE + i * 16 + 5] = -1; + endif; + i = i + 1; + endwhile; + + [SEMAPHORE_TABLE + 4 * semId + 1] = [SEMAPHORE_TABLE + 4 * semId + 1] - 1; + endif; + return; +endif; + +// Acquire Terminal +if (functionNum == 8) then + while ([TERMINAL_STATUS_TABLE] != 0) do + [PROCESS_TABLE + currentPID * 16 + 4] = WAIT_TERMINAL; + multipush(R1, R2); + + call MOD_5; + + multipop(R1, R2); + endwhile; + + [TERMINAL_STATUS_TABLE] = 1; + [TERMINAL_STATUS_TABLE + 1] = currentPID; + return; +endif; + +// Release Terminal +if (functionNum == 9) then + if (currentPID != [TERMINAL_STATUS_TABLE + 1]) then + alias returnValue R0; + returnValue = -1; + return; + else + [TERMINAL_STATUS_TABLE] = 0; + alias i R3; + i = 0; + while (i < 16) do + if ([PROCESS_TABLE + i * 16 + 4] == WAIT_TERMINAL) then + [PROCESS_TABLE + 16 * i + 4] = READY; + endif; + i = i + 1; + endwhile; + alias returnValue R0; + returnValue = 0; + return; + endif; +else + alias returnValue R0; + returnValue = -1; + return; +endif; \ No newline at end of file diff --git a/Stage22/Assgn2/mod0.xsm b/Stage22/Assgn2/mod0.xsm new file mode 100644 index 0000000..c59328a --- /dev/null +++ b/Stage22/Assgn2/mod0.xsm @@ -0,0 +1,239 @@ +MOV R16, 3 +EQ R16, R1 +JZ R16, _L1 +_L3: +MOV R16, 29552 +MOV R16, [R16] +MOV R17, 1 +EQ R16, R17 +JZ R16, _L4 +MOV R16, 28672 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 5 +PUSH R1 +PUSH R2 +CALL 25600 +POP R2 +POP R1 +JMP _L3 +_L4: +MOV R16, 29560 +ADD R16, 26 +MOV R17, 29560 +ADD R17, 26 +MOV R17, [R17] +ADD R17, 1 +MOV [R16], R17 +MOV [29552], 1 +MOV R16, 29552 +ADD R16, 4 +MOV [R16], R2 +RET +JMP _L2 +_L1: +_L2: +MOV R16, 6 +EQ R16, R1 +JZ R16, _L5 +MOV R3, 0 +_L7: +MOV R16, 32 +GT R16, R3 +MOV R17, 29056 +MOV R18, 4 +MUL R18, R3 +ADD R17, R18 +ADD R17, 1 +MOV R17, [R17] +MOV R18, 0 +NE R17, R18 +MUL R16, R17 +JZ R16, _L8 +MOV R16, R3 +ADD R16, 1 +MOV R3, R16 +JMP _L7 +_L8: +MOV R16, 32 +EQ R16, R3 +JZ R16, _L9 +MOV R0, -1 +JMP _L10 +_L9: +MOV R16, 29056 +MOV R17, 4 +MUL R17, R3 +ADD R16, R17 +MOV [R16], -1 +MOV R16, 29056 +MOV R17, 4 +MUL R17, R3 +ADD R16, R17 +ADD R16, 1 +MOV [R16], 1 +MOV R0, R3 +_L10: +RET +JMP _L6 +_L5: +_L6: +MOV R16, 7 +EQ R16, R1 +JZ R16, _L11 +MOV R16, 29056 +MOV R17, R2 +MUL R17, 4 +ADD R16, R17 +MOV R16, [R16] +EQ R16, R3 +JZ R16, _L13 +MOV R16, 29056 +MOV R17, R2 +MUL R17, 4 +ADD R16, R17 +MOV [R16], -1 +MOV R4, 0 +_L15: +MOV R16, 16 +GT R16, R4 +JZ R16, _L16 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV R16, [R16] +MOV R17, 10 +EQ R16, R17 +MOV R17, 28672 +MOV R18, R4 +MUL R18, 16 +ADD R17, R18 +ADD R17, 5 +MOV R17, [R17] +EQ R17, R2 +MUL R16, R17 +JZ R16, _L17 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 1 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +ADD R16, 5 +MOV [R16], -1 +JMP _L18 +_L17: +_L18: +MOV R16, R4 +ADD R16, 1 +MOV R4, R16 +JMP _L15 +_L16: +MOV R16, 29056 +MOV R17, 4 +MUL R17, R2 +ADD R16, R17 +ADD R16, 1 +MOV R17, 29056 +MOV R18, 4 +MUL R18, R2 +ADD R17, R18 +ADD R17, 1 +MOV R17, [R17] +SUB R17, 1 +MOV [R16], R17 +JMP _L14 +_L13: +_L14: +RET +JMP _L12 +_L11: +_L12: +MOV R16, 8 +EQ R16, R1 +JZ R16, _L19 +_L21: +MOV R16, 29568 +MOV R16, [R16] +MOV R17, 0 +NE R16, R17 +JZ R16, _L22 +MOV R16, 28672 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 8 +PUSH R1 +PUSH R2 +CALL 25600 +POP R2 +POP R1 +JMP _L21 +_L22: +MOV [29568], 1 +MOV R16, 29568 +ADD R16, 1 +MOV [R16], R2 +RET +JMP _L20 +_L19: +_L20: +MOV R16, 9 +EQ R16, R1 +JZ R16, _L23 +MOV R16, 29568 +ADD R16, 1 +MOV R16, [R16] +NE R16, R2 +JZ R16, _L25 +MOV R0, -1 +RET +JMP _L26 +_L25: +MOV [29568], 0 +MOV R3, 0 +_L27: +MOV R16, 16 +GT R16, R3 +JZ R16, _L28 +MOV R16, 28672 +MOV R17, R3 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV R16, [R16] +MOV R17, 8 +EQ R16, R17 +JZ R16, _L29 +MOV R16, 28672 +MOV R17, 16 +MUL R17, R3 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 1 +JMP _L30 +_L29: +_L30: +MOV R16, R3 +ADD R16, 1 +MOV R3, R16 +JMP _L27 +_L28: +MOV R0, 0 +RET +_L26: +JMP _L24 +_L23: +MOV R0, -1 +RET +_L24: +HALT \ No newline at end of file diff --git a/Stage22/Assgn2/mod5.spl b/Stage22/Assgn2/mod5.spl new file mode 100644 index 0000000..04b7ab1 --- /dev/null +++ b/Stage22/Assgn2/mod5.spl @@ -0,0 +1,50 @@ +alias currentPID R0; +alias process_table_entry R1; + +currentPID = [SYSTEM_STATUS_TABLE + 1]; +process_table_entry = PROCESS_TABLE + 16 * currentPID; + +multipush(BP); + +[process_table_entry + 12] = SP % 512; +[process_table_entry + 14] = PTBR; +[process_table_entry + 15] = PTLR; + +alias i R2; +alias state R3; +alias newPID R4; + +newPID = 0; +i = currentPID + 1; +while (i < 16) do + state = [PROCESS_TABLE + i * 16 + 4]; + if (state == READY || state == CREATED) then + newPID = i; + break; + endif; + i = i + 1; +endwhile; + +// context switches +[SYSTEM_STATUS_TABLE + 24] = [SYSTEM_STATUS_TABLE + 24] + 1; + +process_table_entry = PROCESS_TABLE + (newPID * 16); +SP = [process_table_entry + 11] * 512 + [process_table_entry + 12]; +PTBR = [process_table_entry + 14]; +PTLR = [process_table_entry + 15]; + +[SYSTEM_STATUS_TABLE + 1] = newPID; + +if (state == CREATED) then + SP = [process_table_entry + 13]; + BP = [[process_table_entry + 11] * 512]; + [process_table_entry + 4] = RUNNING; + [process_table_entry + 9] = 0; // mode flag + ireturn; +endif; + +[process_table_entry + 4] = RUNNING; + +multipop(BP); + +return; \ No newline at end of file diff --git a/Stage22/Assgn2/mod5.xsm b/Stage22/Assgn2/mod5.xsm new file mode 100644 index 0000000..75f2e04 --- /dev/null +++ b/Stage22/Assgn2/mod5.xsm @@ -0,0 +1,113 @@ +MOV R16, 29560 +ADD R16, 1 +MOV R16, [R16] +MOV R0, R16 +MOV R16, 28672 +MOV R17, 16 +MUL R17, R0 +ADD R16, R17 +MOV R1, R16 +PUSH BP +MOV R16, R1 +ADD R16, 12 +MOV R17, SP +MOD R17, 512 +MOV [R16], R17 +MOV R16, R1 +ADD R16, 14 +MOV [R16], PTBR +MOV R16, R1 +ADD R16, 15 +MOV [R16], PTLR +MOV R4, 0 +MOV R16, R0 +ADD R16, 1 +MOV R2, R16 +_L1: +MOV R16, 16 +GT R16, R2 +JZ R16, _L2 +MOV R16, 28672 +MOV R17, R2 +MUL R17, 16 +ADD R16, R17 +ADD R16, 4 +MOV R16, [R16] +MOV R3, R16 +MOV R16, 1 +EQ R16, R3 +MOV R17, 3 +EQ R17, R3 +ADD R16, R17 +JZ R16, _L3 +MOV R4, R2 +JMP _L2 +JMP _L4 +_L3: +_L4: +MOV R16, R2 +ADD R16, 1 +MOV R2, R16 +JMP _L1 +_L2: +MOV R16, 29560 +ADD R16, 24 +MOV R17, 29560 +ADD R17, 24 +MOV R17, [R17] +ADD R17, 1 +MOV [R16], R17 +MOV R16, 28672 +MOV R17, R4 +MUL R17, 16 +ADD R16, R17 +MOV R1, R16 +MOV R16, R1 +ADD R16, 11 +MOV R16, [R16] +MUL R16, 512 +MOV R17, R1 +ADD R17, 12 +MOV R17, [R17] +ADD R16, R17 +MOV SP, R16 +MOV R16, R1 +ADD R16, 14 +MOV R16, [R16] +MOV PTBR, R16 +MOV R16, R1 +ADD R16, 15 +MOV R16, [R16] +MOV PTLR, R16 +MOV R16, 29560 +ADD R16, 1 +MOV [R16], R4 +MOV R16, 3 +EQ R16, R3 +JZ R16, _L5 +MOV R16, R1 +ADD R16, 13 +MOV R16, [R16] +MOV SP, R16 +MOV R16, R1 +ADD R16, 11 +MOV R16, [R16] +MUL R16, 512 +MOV R16, [R16] +MOV BP, R16 +MOV R16, R1 +ADD R16, 4 +MOV [R16], 2 +MOV R16, R1 +ADD R16, 9 +MOV [R16], 0 +IRET +JMP _L6 +_L5: +_L6: +MOV R16, R1 +ADD R16, 4 +MOV [R16], 2 +POP BP +RET +HALT \ No newline at end of file diff --git a/Stage22/Assgn2/mod7.spl b/Stage22/Assgn2/mod7.spl new file mode 100644 index 0000000..ffd4268 --- /dev/null +++ b/Stage22/Assgn2/mod7.spl @@ -0,0 +1,182 @@ +// exhandler +loadi(2, 15); +loadi(3, 16); + +// timer interrupt +loadi(4, 17); +loadi(5, 18); + +// write interrupt +loadi(16, 29); +loadi(17, 30); + +// int 10 +loadi(22, 35); +loadi(23, 36); + +// int 8 (fork) +loadi(18, 31); +loadi(19, 32); + +// Library +loadi(63, 13); +loadi(64, 14); + +// init +loadi(65, 7); +loadi(66, 8); + +// module 5 +loadi(50, 63); +loadi(51, 64); + +// module 0 +loadi(40, 53); +loadi(41, 54); + +// module 4 +loadi(48, 61); +loadi(49, 62); + +// console interrupt +loadi(8, 21); +loadi(9, 22); + +// int 6 +loadi(14, 27); +loadi(15, 28); + +// int 9 +loadi(20, 33); +loadi(21, 34); + +// int 11 +loadi(24, 37); +loadi(25, 38); + +// int 13 +loadi(28, 41); +loadi(29, 42); + +// int 14 +loadi(30, 43); +loadi(31, 44); + +// int 15 +loadi(32, 45); +loadi(33, 46); + +// module 1 +loadi(42, 55); +loadi(43, 56); + +// module 2 +loadi(44, 57); +loadi(45, 58); + +// inode user table +loadi(59, 3); +loadi(60, 4); + +// disk interrupt +loadi(6, 19); +loadi(7, 20); + +// disk free list +loadi(61, 2); + +// memory free list initialization +alias i R0; +i = 0; +while (i < 128) do + if (i < 76) then + [MEMORY_FREE_LIST + i] = 1; + else + [MEMORY_FREE_LIST + i] = 0; + endif; + i = i + 1; +endwhile; + +[MEMORY_FREE_LIST + 76] = 1; +[MEMORY_FREE_LIST + 77] = 1; +[MEMORY_FREE_LIST + 78] = 1; +[MEMORY_FREE_LIST + 79] = 1; +[MEMORY_FREE_LIST + 80] = 1; +[MEMORY_FREE_LIST + 81] = 1; +[MEMORY_FREE_LIST + 82] = 1; + +PTBR = PAGE_TABLE_BASE + 20; +PTLR = 10; + +[PTBR + 0] = 63; +[PTBR + 1] = "0100"; +[PTBR + 2] = 64; +[PTBR + 3] = "0100"; +[PTBR + 4] = 78; +[PTBR + 5] = "0110"; +[PTBR + 6] = 79; +[PTBR + 7] = "0110"; +[PTBR + 8] = 65; +[PTBR + 9] = "0100"; +[PTBR + 10] = 66; +[PTBR + 11] = "0100"; +[PTBR + 12] = -1; +[PTBR + 13] = "0000"; +[PTBR + 14] = -1; +[PTBR + 15] = "0000"; +[PTBR + 16] = 76; +[PTBR + 17] = "0110"; +[PTBR + 18] = 77; +[PTBR + 19] = "0110"; + +[PROCESS_TABLE + 16 + 1] = 1; +[PROCESS_TABLE + 16 + 11] = 80; +[PROCESS_TABLE + 16 + 12] = 0; +[PROCESS_TABLE + 16 + 13] = 8 * 512; +[PROCESS_TABLE + 16 + 14] = PTBR; +[PROCESS_TABLE + 16 + 15] = PTLR; +[PROCESS_TABLE + 16 + 4] = CREATED; +[76 * 512] = [65 * 512 + 1]; + +// per-process resource table for init +i = 1; +while (i < 9) do + [([PROCESS_TABLE + 16 + 11] + 1) * 512 - 2 * i] = -1; + i = i + 1; +endwhile; + +// disk map table initialization for init + +[DISK_MAP_TABLE + 10 + 2] = -1; +[DISK_MAP_TABLE + 10 + 3] = -1; +[DISK_MAP_TABLE + 10 + 4] = 7; +[DISK_MAP_TABLE + 10 + 5] = 8; +[DISK_MAP_TABLE + 10 + 6] = -1; +[DISK_MAP_TABLE + 10 + 7] = -1; +[DISK_MAP_TABLE + 10 + 8] = -1; +[DISK_MAP_TABLE + 10 + 9] = -1; + +i = 2; +while (i < 16) do + [PROCESS_TABLE + 16 * i + 4] = TERMINATED; + i = i + 1; +endwhile; + +[TERMINAL_STATUS_TABLE] = 0; +[DISK_STATUS_TABLE] = 0; +[SYSTEM_STATUS_TABLE + 0] = 0; +[SYSTEM_STATUS_TABLE + 2] = 45; +[SYSTEM_STATUS_TABLE + 3] = 0; +[SYSTEM_STATUS_TABLE + 24] = 0; // context switches +[SYSTEM_STATUS_TABLE + 25] = 0; // max memory usage +[SYSTEM_STATUS_TABLE + 26] = 0; // disk accesses + +// initialization of semaphore table +i = 0; +while (i < MAX_SEM_COUNT) do + [SEMAPHORE_TABLE + i * 4] = -1; + [SEMAPHORE_TABLE + i * 4 + 1] = 0; + i = i + 1; +endwhile; + +return; \ No newline at end of file diff --git a/Stage22/Assgn2/mod7.xsm b/Stage22/Assgn2/mod7.xsm new file mode 100644 index 0000000..2b9ffa2 --- /dev/null +++ b/Stage22/Assgn2/mod7.xsm @@ -0,0 +1,341 @@ +MOV R16, 2 +LOADI R16, 15 +MOV R16, 3 +LOADI R16, 16 +MOV R16, 4 +LOADI R16, 17 +MOV R16, 5 +LOADI R16, 18 +MOV R16, 16 +LOADI R16, 29 +MOV R16, 17 +LOADI R16, 30 +MOV R16, 22 +LOADI R16, 35 +MOV R16, 23 +LOADI R16, 36 +MOV R16, 18 +LOADI R16, 31 +MOV R16, 19 +LOADI R16, 32 +MOV R16, 63 +LOADI R16, 13 +MOV R16, 64 +LOADI R16, 14 +MOV R16, 65 +LOADI R16, 7 +MOV R16, 66 +LOADI R16, 8 +MOV R16, 50 +LOADI R16, 63 +MOV R16, 51 +LOADI R16, 64 +MOV R16, 40 +LOADI R16, 53 +MOV R16, 41 +LOADI R16, 54 +MOV R16, 48 +LOADI R16, 61 +MOV R16, 49 +LOADI R16, 62 +MOV R16, 8 +LOADI R16, 21 +MOV R16, 9 +LOADI R16, 22 +MOV R16, 14 +LOADI R16, 27 +MOV R16, 15 +LOADI R16, 28 +MOV R16, 20 +LOADI R16, 33 +MOV R16, 21 +LOADI R16, 34 +MOV R16, 24 +LOADI R16, 37 +MOV R16, 25 +LOADI R16, 38 +MOV R16, 28 +LOADI R16, 41 +MOV R16, 29 +LOADI R16, 42 +MOV R16, 30 +LOADI R16, 43 +MOV R16, 31 +LOADI R16, 44 +MOV R16, 32 +LOADI R16, 45 +MOV R16, 33 +LOADI R16, 46 +MOV R16, 42 +LOADI R16, 55 +MOV R16, 43 +LOADI R16, 56 +MOV R16, 44 +LOADI R16, 57 +MOV R16, 45 +LOADI R16, 58 +MOV R16, 59 +LOADI R16, 3 +MOV R16, 60 +LOADI R16, 4 +MOV R16, 6 +LOADI R16, 19 +MOV R16, 7 +LOADI R16, 20 +MOV R16, 61 +LOADI R16, 2 +MOV R0, 0 +_L1: +MOV R16, 128 +GT R16, R0 +JZ R16, _L2 +MOV R16, 76 +GT R16, R0 +JZ R16, _L3 +MOV R16, 29184 +ADD R16, R0 +MOV [R16], 1 +JMP _L4 +_L3: +MOV R16, 29184 +ADD R16, R0 +MOV [R16], 0 +_L4: +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L1 +_L2: +MOV R16, 29184 +ADD R16, 76 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 77 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 78 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 79 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 80 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 81 +MOV [R16], 1 +MOV R16, 29184 +ADD R16, 82 +MOV [R16], 1 +MOV R16, 29696 +ADD R16, 20 +MOV PTBR, R16 +MOV PTLR, 10 +MOV R16, PTBR +ADD R16, 0 +MOV [R16], 63 +MOV R16, PTBR +ADD R16, 1 +MOV [R16], "0100" +MOV R16, PTBR +ADD R16, 2 +MOV [R16], 64 +MOV R16, PTBR +ADD R16, 3 +MOV [R16], "0100" +MOV R16, PTBR +ADD R16, 4 +MOV [R16], 78 +MOV R16, PTBR +ADD R16, 5 +MOV [R16], "0110" +MOV R16, PTBR +ADD R16, 6 +MOV [R16], 79 +MOV R16, PTBR +ADD R16, 7 +MOV [R16], "0110" +MOV R16, PTBR +ADD R16, 8 +MOV [R16], 65 +MOV R16, PTBR +ADD R16, 9 +MOV [R16], "0100" +MOV R16, PTBR +ADD R16, 10 +MOV [R16], 66 +MOV R16, PTBR +ADD R16, 11 +MOV [R16], "0100" +MOV R16, PTBR +ADD R16, 12 +MOV [R16], -1 +MOV R16, PTBR +ADD R16, 13 +MOV [R16], "0000" +MOV R16, PTBR +ADD R16, 14 +MOV [R16], -1 +MOV R16, PTBR +ADD R16, 15 +MOV [R16], "0000" +MOV R16, PTBR +ADD R16, 16 +MOV [R16], 76 +MOV R16, PTBR +ADD R16, 17 +MOV [R16], "0110" +MOV R16, PTBR +ADD R16, 18 +MOV [R16], 77 +MOV R16, PTBR +ADD R16, 19 +MOV [R16], "0110" +MOV R16, 28672 +ADD R16, 16 +ADD R16, 1 +MOV [R16], 1 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 11 +MOV [R16], 80 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 12 +MOV [R16], 0 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 13 +MOV R17, 8 +MUL R17, 512 +MOV [R16], R17 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 14 +MOV [R16], PTBR +MOV R16, 28672 +ADD R16, 16 +ADD R16, 15 +MOV [R16], PTLR +MOV R16, 28672 +ADD R16, 16 +ADD R16, 4 +MOV [R16], 3 +MOV R16, 76 +MUL R16, 512 +MOV R17, 65 +MUL R17, 512 +ADD R17, 1 +MOV R17, [R17] +MOV [R16], R17 +MOV R0, 1 +_L5: +MOV R16, 9 +GT R16, R0 +JZ R16, _L6 +MOV R16, 28672 +ADD R16, 16 +ADD R16, 11 +MOV R16, [R16] +ADD R16, 1 +MUL R16, 512 +MOV R17, 2 +MUL R17, R0 +SUB R16, R17 +MOV [R16], -1 +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L5 +_L6: +MOV R16, 30032 +ADD R16, 10 +ADD R16, 2 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 3 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 4 +MOV [R16], 7 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 5 +MOV [R16], 8 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 6 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 7 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 8 +MOV [R16], -1 +MOV R16, 30032 +ADD R16, 10 +ADD R16, 9 +MOV [R16], -1 +MOV R0, 2 +_L7: +MOV R16, 16 +GT R16, R0 +JZ R16, _L8 +MOV R16, 28672 +MOV R17, 16 +MUL R17, R0 +ADD R16, R17 +ADD R16, 4 +MOV [R16], 4 +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L7 +_L8: +MOV [29568], 0 +MOV [29552], 0 +MOV R16, 29560 +ADD R16, 0 +MOV [R16], 0 +MOV R16, 29560 +ADD R16, 2 +MOV [R16], 45 +MOV R16, 29560 +ADD R16, 3 +MOV [R16], 0 +MOV R16, 29560 +ADD R16, 24 +MOV [R16], 0 +MOV R16, 29560 +ADD R16, 25 +MOV [R16], 0 +MOV R16, 29560 +ADD R16, 26 +MOV [R16], 0 +MOV R0, 0 +_L9: +MOV R16, 32 +GT R16, R0 +JZ R16, _L10 +MOV R16, 29056 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +MOV [R16], -1 +MOV R16, 29056 +MOV R17, R0 +MUL R17, 4 +ADD R16, R17 +ADD R16, 1 +MOV [R16], 0 +MOV R16, R0 +ADD R16, 1 +MOV R0, R16 +JMP _L9 +_L10: +RET +HALT \ No newline at end of file diff --git a/Stage22/Assgn2/timer.spl b/Stage22/Assgn2/timer.spl new file mode 100644 index 0000000..779d05c --- /dev/null +++ b/Stage22/Assgn2/timer.spl @@ -0,0 +1,36 @@ +// Store user SP to UPTR in process table -> 13 th word +[PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13] = SP; + +// Set SP to start of Kernel stack +SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 11] * 512 - 1; + +multipush(R2); + +alias prevMemUsage R2; +prevMemUsage = SYSTEM_STATUS_TABLE + 25; +if (128 - [SYSTEM_STATUS_TABLE + 2] > [prevMemUsage]) then + [prevMemUsage] = 128 - [SYSTEM_STATUS_TABLE + 2]; +endif; + +multipop(R2); + +backup; + +// obtaining PID of the currently executing process +alias currentPID R0; +currentPID = [SYSTEM_STATUS_TABLE + 1]; + +alias process_table_entry R1; +process_table_entry = PROCESS_TABLE + currentPID * 16; + +[process_table_entry + 4] = READY; + +call MOD_5; + +restore; + +SP = [PROCESS_TABLE + 16 * [SYSTEM_STATUS_TABLE + 1] + 13]; +[PROCESS_TABLE + 16 * [SYSTEM_STATUS_TABLE + 1] + 12] = 0; +[PROCESS_TABLE + 16 * [SYSTEM_STATUS_TABLE + 1] + 9] = 0; + +ireturn; \ No newline at end of file diff --git a/Stage22/Assgn2/timer.xsm b/Stage22/Assgn2/timer.xsm new file mode 100644 index 0000000..ff4de10 --- /dev/null +++ b/Stage22/Assgn2/timer.xsm @@ -0,0 +1,87 @@ +MOV R16, 28672 +MOV R17, 29560 +ADD R17, 1 +MOV R17, [R17] +MUL R17, 16 +ADD R16, R17 +ADD R16, 13 +MOV [R16], SP +MOV R16, 28672 +MOV R17, 29560 +ADD R17, 1 +MOV R17, [R17] +MUL R17, 16 +ADD R16, R17 +ADD R16, 11 +MOV R16, [R16] +MUL R16, 512 +SUB R16, 1 +MOV SP, R16 +PUSH R2 +MOV R16, 29560 +ADD R16, 25 +MOV R2, R16 +MOV R16, 128 +MOV R17, 29560 +ADD R17, 2 +MOV R17, [R17] +SUB R16, R17 +MOV R17, R2 +MOV R17, [R17] +GT R16, R17 +JZ R16, _L1 +MOV R16, 128 +MOV R17, 29560 +ADD R17, 2 +MOV R17, [R17] +SUB R16, R17 +MOV [R2], R16 +JMP _L2 +_L1: +_L2: +POP R2 +BACKUP +MOV R16, 29560 +ADD R16, 1 +MOV R16, [R16] +MOV R0, R16 +MOV R16, 28672 +MOV R17, R0 +MUL R17, 16 +ADD R16, R17 +MOV R1, R16 +MOV R16, R1 +ADD R16, 4 +MOV [R16], 1 +CALL 25600 +RESTORE +MOV R16, 28672 +MOV R17, 16 +MOV R18, 29560 +ADD R18, 1 +MOV R18, [R18] +MUL R17, R18 +ADD R16, R17 +ADD R16, 13 +MOV R16, [R16] +MOV SP, R16 +MOV R16, 28672 +MOV R17, 16 +MOV R18, 29560 +ADD R18, 1 +MOV R18, [R18] +MUL R17, R18 +ADD R16, R17 +ADD R16, 12 +MOV [R16], 0 +MOV R16, 28672 +MOV R17, 16 +MOV R18, 29560 +ADD R18, 1 +MOV R18, [R18] +MUL R17, R18 +ADD R16, R17 +ADD R16, 9 +MOV [R16], 0 +IRET +HALT \ No newline at end of file diff --git a/xfs-interface/stage22_2.sh b/xfs-interface/stage22_2.sh new file mode 100644 index 0000000..e5909f6 --- /dev/null +++ b/xfs-interface/stage22_2.sh @@ -0,0 +1,32 @@ +load --os $HOME/myexpos/Stage13/os_startup.xsm +load --init $HOME/myexpos/Stage21/Assgn1/shell2.xsm +load --idle $HOME/myexpos/Stage14/idle.xsm +load --int=10 $HOME/myexpos/Stage20/exit.xsm +load --int=11 $HOME/myexpos/Stage21/int11.xsm +load --int=13 $HOME/myexpos/Stage22/int13.xsm +load --int=14 $HOME/myexpos/Stage22/int14.xsm +load --int=15 $HOME/myexpos/Stage22/Assgn2/int15.xsm +load --int=9 $HOME/myexpos/Stage19/int9.xsm +load --int=8 $HOME/myexpos/Stage22/fork.xsm +load --exhandler $HOME/myexpos/Stage21/exhandler.xsm +load --int=7 $HOME/myexpos/Stage15/int7.xsm +load --int=6 $HOME/myexpos/Stage16/int6.xsm +load --int=disk $HOME/myexpos/Stage18/int2.xsm +load --int=console $HOME/myexpos/Stage16/console_int.xsm +load --module 5 $HOME/myexpos/Stage22/Assgn2/mod5.xsm +load --module 7 $HOME/myexpos/Stage22/Assgn2/mod7.xsm +load --module 0 $HOME/myexpos/Stage22/Assgn2/mod0.xsm +load --module 1 $HOME/myexpos/Stage22/mod1.xsm +load --module 2 $HOME/myexpos/Stage19/module_2.xsm +load --module 4 $HOME/myexpos/Stage18/module_4.xsm +load --int=timer $HOME/myexpos/Stage22/Assgn2/timer.xsm +rm test4.xsm +load --exec $HOME/myexpos/Stage22/Assgn1/test4.xsm +rm parent.xsm +load --exec $HOME/myexpos/Stage22/Assgn2/parent.xsm +rm child.xsm +load --exec $HOME/myexpos/Stage22/Assgn2/child.xsm +rm con.xsm +load --exec $HOME/myexpos/Stage22/Assgn3/con.xsm +rm seq.xsm +load --exec $HOME/myexpos/Stage22/Assgn3/seq.xsm \ No newline at end of file