Skip to content

Commit

Permalink
Stage 13
Browse files Browse the repository at this point in the history
  • Loading branch information
0xadeeb committed Sep 9, 2022
1 parent deae8d1 commit 8078a1c
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 101 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
!*l/samples
!*l/*l_progs/*.*l
!*l/samples/*.*l
!*l/*l_progs/asg*
!*l/*l_progs/asg*/*.*l
26 changes: 26 additions & 0 deletions expl/expl_progs/asg12/idle.expl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//int main()
//{
// decl
// int a;
// enddecl
// begin
// while(1==1) do
// a=1;
// endwhile;
// return 0;
// end
//}
int main()
{
decl
int temp,num;
enddecl
begin
num=101;
while ( num <= 200 ) do
temp = exposcall ( "Write" , -2, num );
num = num + 1;
endwhile;
return 0;
end
}
2 changes: 1 addition & 1 deletion expl/expl_progs/idle.expl
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ int main()
endwhile;
return 0;
end
}
}
14 changes: 14 additions & 0 deletions expl/expl_progs/init.expl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
int main()
{
decl
int temp,num;
enddecl
begin
num=1;
while ( num <= 100 ) do
temp = exposcall ( "Write" , -2, num );
num = num + 1;
endwhile;
return 0;
end
}
14 changes: 14 additions & 0 deletions expl/expl_progs/numbers.expl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
int main()
{
decl
int temp,num;
enddecl
begin
num=1;
while ( num <= 100 ) do
temp = exposcall ( "Write" , -2, num );
num = num + 1;
endwhile;
return 0;
end
}
68 changes: 68 additions & 0 deletions spl/spl_progs/boot_module.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Load library codes from disk
loadi(63, 13);
loadi(64, 14);

// Load Timer Interrupt
loadi(4, 17);
loadi(5, 18);

// Load INT7
loadi(16, 29);
loadi(17, 30);

// Load idle program
loadi(69, 11);
loadi(70, 12);

// Load Init program
loadi(65, 7);
loadi(66, 8);

// Intrupts
loadi(22, 35);
loadi(23, 36);
loadi(2, 15);
loadi(3, 16);

// Process table of init program
[PROCESS_TABLE + 1 * 16 + 1] = 1;
[PROCESS_TABLE + 1 * 16 + 4] = CREATED;
[PROCESS_TABLE + 1 * 16 + 11] = 80;
[PROCESS_TABLE + 1 * 16 + 12] = 0;
[PROCESS_TABLE + 1 * 16 + 13] = 8 * 512;
[PROCESS_TABLE + 1 * 16 + 14] = PAGE_TABLE_BASE + 20;
[PROCESS_TABLE + 1 * 16 + 15] = 10;

//Init Program
//Library
[PAGE_TABLE_BASE + 1 * 20 + 0] = 63;
[PAGE_TABLE_BASE + 1 * 20 + 1] = "0100";
[PAGE_TABLE_BASE + 1 * 20 + 2] = 64;
[PAGE_TABLE_BASE + 1 * 20 + 3] = "0100";

//Heap
[PAGE_TABLE_BASE + 1 * 20 + 4] = 78;
[PAGE_TABLE_BASE + 1 * 20 + 5] = "0110";
[PAGE_TABLE_BASE + 1 * 20 + 6] = 79;
[PAGE_TABLE_BASE + 1 * 20 + 7] = "0110";

//Code
[PAGE_TABLE_BASE + 1 * 20 + 8] = 65;
[PAGE_TABLE_BASE + 1 * 20 + 9] = "0100";
[PAGE_TABLE_BASE + 1 * 20 + 10] = 66;
[PAGE_TABLE_BASE + 1 * 20 + 11] = "0100";
[PAGE_TABLE_BASE + 1 * 20 + 12] = -1;
[PAGE_TABLE_BASE + 1 * 20 + 13] = "0000";
[PAGE_TABLE_BASE + 1 * 20 + 14] = -1;
[PAGE_TABLE_BASE + 1 * 20 + 15] = "0000";

//Stack
[PAGE_TABLE_BASE + 1 * 20 + 16] = 76;
[PAGE_TABLE_BASE + 1 * 20 + 17] = "0110";
[PAGE_TABLE_BASE + 1 * 20 + 18] = 77;
[PAGE_TABLE_BASE + 1 * 20 + 19] = "0110";

// Set IP in top of the stack
[76 * 512] = [65 * 512 + 1];

return;
125 changes: 33 additions & 92 deletions spl/spl_progs/os_startup.spl
Original file line number Diff line number Diff line change
@@ -1,114 +1,55 @@
// Init program PID
[SYSTEM_STATUS_TABLE + 1] = 1;
// Load Boot module (Module 7)
loadi(54, 67);
loadi(55, 68);

call BOOT_MODULE;

PTBR = PAGE_TABLE_BASE;
PTLR = 10;

// Process table of idle program
[PROCESS_TABLE + 1] = 0;
[PROCESS_TABLE + 4] = CREATED;
[PROCESS_TABLE + 4] = RUNNING;
[PROCESS_TABLE + 11] = 82;
[PROCESS_TABLE + 12] = 0;
[PROCESS_TABLE + 13] = 8 * 512;
[PROCESS_TABLE + 14] = PAGE_TABLE_BASE;
[PROCESS_TABLE + 14] = PTBR;
[PROCESS_TABLE + 15] = 10;

// Process table of init program
[PROCESS_TABLE + 16 + 1] = 1;
[PROCESS_TABLE + 16 + 4] = RUNNING;
[PROCESS_TABLE + 16 + 11] = 80;
[PROCESS_TABLE + 16 + 12] = 0;
[PROCESS_TABLE + 16 + 13] = 8 * 512;
[PROCESS_TABLE + 16 + 14] = PAGE_TABLE_BASE + 20;
[PROCESS_TABLE + 16 + 15] = 10;

// Load library codes from disk
loadi(63,13);
loadi(64,14);

// Load Timer Interrupt
loadi(4, 17);
loadi(5, 18);

// Load INT7
loadi(16,29);
loadi(17,30);

// Load idle program
loadi(69,11);
loadi(70,12);

// Load Init program
loadi(65,7);
loadi(66,8);

// Intrupts
loadi(22,35);
loadi(23,36);
loadi(2, 15);
loadi(3, 16);

// Idle
//Library
[PAGE_TABLE_BASE + 0] = -1;
[PAGE_TABLE_BASE + 1] = "0000";
[PAGE_TABLE_BASE + 2] = -1;
[PAGE_TABLE_BASE + 3] = "0000";
[PTBR + 0] = 63;
[PTBR + 1] = "0100";
[PTBR + 2] = 64;
[PTBR + 3] = "0100";

//Heap
[PAGE_TABLE_BASE + 4] = -1;
[PAGE_TABLE_BASE + 5] = "0000";
[PAGE_TABLE_BASE + 6] = -1;
[PAGE_TABLE_BASE + 7] = "0000";
[PTBR + 4] = -1;
[PTBR + 5] = "0000";
[PTBR + 6] = -1;
[PTBR + 7] = "0000";

//Code
[PAGE_TABLE_BASE + 8] = 69;
[PAGE_TABLE_BASE + 9] = "0100";
[PAGE_TABLE_BASE + 10] = 70;
[PAGE_TABLE_BASE + 11] = "0100";
[PAGE_TABLE_BASE + 12] = -1;
[PAGE_TABLE_BASE + 13] = "0000";
[PAGE_TABLE_BASE + 14] = -1;
[PAGE_TABLE_BASE + 15] = "0000";
[PTBR + 8] = 69;
[PTBR + 9] = "0100";
[PTBR + 10] = 70;
[PTBR + 11] = "0100";
[PTBR + 12] = -1;
[PTBR + 13] = "0000";
[PTBR + 14] = -1;
[PTBR + 15] = "0000";

//Stack
[PAGE_TABLE_BASE + 16] = 81;
[PAGE_TABLE_BASE + 17] = "0110";
[PAGE_TABLE_BASE + 18] = -1;
[PAGE_TABLE_BASE + 19] = "0110";
[PTBR + 16] = 81;
[PTBR + 17] = "0110";
[PTBR + 18] = -1;
[PTBR + 19] = "0000";

//IP in top of the stack
[81 * 512] = [69 * 512 + 1];

//Init Program
//Library
[PAGE_TABLE_BASE + 20 + 0] = 63;
[PAGE_TABLE_BASE + 20 + 1] = "0100";
[PAGE_TABLE_BASE + 20 + 2] = 64;
[PAGE_TABLE_BASE + 20 + 3] = "0100";

//Heap
[PAGE_TABLE_BASE + 20 + 4] = 78;
[PAGE_TABLE_BASE + 20 + 5] = "0110";
[PAGE_TABLE_BASE + 20 + 6] = 79;
[PAGE_TABLE_BASE + 20 + 7] = "0110";

//Code
[PAGE_TABLE_BASE + 20 + 8] = 65;
[PAGE_TABLE_BASE + 20 + 9] = "0100";
[PAGE_TABLE_BASE + 20 + 10] = 66;
[PAGE_TABLE_BASE + 20 + 11] = "0100";
[PAGE_TABLE_BASE + 20 + 12] = -1;
[PAGE_TABLE_BASE + 20 + 13] = "0000";
[PAGE_TABLE_BASE + 20 + 14] = -1;
[PAGE_TABLE_BASE + 20 + 15] = "0000";

//Stack
[PAGE_TABLE_BASE + 20 + 16] = 76;
[PAGE_TABLE_BASE + 20 + 17] = "0110";
[PAGE_TABLE_BASE + 20 + 18] = 77;
[PAGE_TABLE_BASE + 20 + 19] = "0110";
// Set IP in top of the stack
[76 * 512] = [65 * 512 + 1];

PTBR = PAGE_TABLE_BASE + 20;
PTLR = 10;
// Idle program PID
[SYSTEM_STATUS_TABLE + 1] = 0;

SP = 8 * 512;

Expand Down
15 changes: 9 additions & 6 deletions spl/spl_progs/sample_timer.spl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// NOTE: Do not use registers Ri or any of thier aliases before backup or after restore!!
[PROCESS_TABLE + ([SYSTEM_STATUS_TABLE + 1] * 16) + 13] = SP;
SP = [PROCESS_TABLE + ([SYSTEM_STATUS_TABLE + 1] * 16) + 11] * 512 - 1;
backup;

breakpoint;
alias currentPID R0;
currentPID = [SYSTEM_STATUS_TABLE+1];

Expand All @@ -28,15 +28,18 @@ new_process_table = PROCESS_TABLE + newPID * 16;
SP = [new_process_table + 11] * 512 + [new_process_table + 12] ;
PTBR = [new_process_table + 14];
PTLR = [new_process_table + 15];
breakpoint;

[SYSTEM_STATUS_TABLE + 1] = newPID;

if ([new_process_table + 4] == READY) then
restore;
if([new_process_table + 4] == CREATED) then
[new_process_table + 4] = RUNNING;
SP = [new_process_table + 13];
ireturn;
endif;

SP = [PROCESS_TABLE + ( [SYSTEM_STATUS_TABLE + 1] * 16) + 13];
[PROCESS_TABLE + ( [SYSTEM_STATUS_TABLE + 1] * 16) + 4] = RUNNING;
[new_process_table + 4] = RUNNING;

restore;

SP = [PROCESS_TABLE + ( [SYSTEM_STATUS_TABLE + 1] * 16) + 13];
ireturn;
4 changes: 2 additions & 2 deletions tools/aliases.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/zsh
# Will have to source this in ~/.zshrc
#!/usr/bin/env
# Will have to source this in shell rc file

osPath=$HOME/myexpos

Expand Down

0 comments on commit 8078a1c

Please sign in to comment.