Skip to content

Commit

Permalink
Merge pull request #2 from dhwanish-3/stage18
Browse files Browse the repository at this point in the history
Stage18 complete
  • Loading branch information
dhwanish-3 authored Sep 24, 2023
2 parents c54b44f + d5c9e47 commit 9b1dd72
Show file tree
Hide file tree
Showing 18 changed files with 1,576 additions and 19 deletions.
7 changes: 7 additions & 0 deletions Stage17/module_2.xsm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ CALL 25600
POP R1
JMP _L3
_L4:
MOV R16, 29560
ADD R16, 3
MOV R17, 29560
ADD R17, 3
MOV R17, [R17]
SUB R17, 1
MOV [R16], R17
MOV R2, 76
_L5:
MOV R16, 29184
Expand Down
5 changes: 5 additions & 0 deletions Stage17/module_7.spl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ while (i < 128) do
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;
[SYSTEM_STATUS_TABLE + 0] = 0;
Expand Down
15 changes: 15 additions & 0 deletions Stage17/module_7.xsm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ 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
Expand Down
14 changes: 14 additions & 0 deletions Stage18/init.expl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
int main() {
decl
int temp;
str m;
str fileName;
enddecl
begin
m = "Enter : ";
temp = exposcall("Write", -2, m);
temp = exposcall("Read", -1, fileName);
temp = exposcall("Exec", fileName);
return 0;
end
}
100 changes: 100 additions & 0 deletions Stage18/init.xsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
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,"Enter : "
MOV R2,BP
MOV R1,2
ADD R2,R1
MOV [R2],R0
MOV R0,"Write"
PUSH R0
MOV R0,-2
PUSH R0
MOV R1,BP
MOV R0,2
ADD R1,R0
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,"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,"Exec"
PUSH R0
MOV R1,BP
MOV R0,3
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 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
25 changes: 25 additions & 0 deletions Stage18/int2.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
breakpoint;

[PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13] = SP;
SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 11] * 512 - 1;

backup;

[DISK_STATUS_TABLE] = 0;

alias i R2;
i = 1;
while (i < 16) do
if ([PROCESS_TABLE + i * 16 + 4] == WAIT_DISK) then
[PROCESS_TABLE + i * 16 + 4] = READY;
endif;
i = i + 1;
endwhile;

restore;

SP = [PROCESS_TABLE + [SYSTEM_STATUS_TABLE + 1] * 16 + 13];

breakpoint;

ireturn;
63 changes: 63 additions & 0 deletions Stage18/int2.xsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
BRKP
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
BACKUP
MOV [29552], 0
MOV R2, 1
_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 R17, 5
EQ R16, R17
JZ R16, _L3
MOV R16, 28672
MOV R17, R2
MUL R17, 16
ADD R16, R17
ADD R16, 4
MOV [R16], 1
JMP _L4
_L3:
_L4:
MOV R16, R2
ADD R16, 1
MOV R2, R16
JMP _L1
_L2:
RESTORE
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
BRKP
IRET
HALT
Loading

0 comments on commit 9b1dd72

Please sign in to comment.