Skip to content

Commit

Permalink
Merge pull request #9 from dhwanish-3/stage21+
Browse files Browse the repository at this point in the history
Stage 23 + 2 Assgns + rootfile can being modified
  • Loading branch information
dhwanish-3 authored Oct 21, 2023
2 parents 6f07c1a + ba54d07 commit e5d23a3
Show file tree
Hide file tree
Showing 18 changed files with 2,685 additions and 581 deletions.
14 changes: 14 additions & 0 deletions Stage23/Assgn1/create.expl
Original file line number Diff line number Diff line change
@@ -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
}
137 changes: 137 additions & 0 deletions Stage23/Assgn1/create.xsm
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions Stage23/Assgn2/delete.expl
Original file line number Diff line number Diff line change
@@ -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
}
168 changes: 168 additions & 0 deletions Stage23/Assgn2/delete.xsm
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions Stage23/int15.spl
Original file line number Diff line number Diff line change
@@ -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;
Loading

0 comments on commit e5d23a3

Please sign in to comment.