CP Phase1
CP Phase1
Roll No : 58
Course Project Phase 1
Q. Design and implement Operating System Phase 1 to perform following task:
i. CPU/ Machine Simulation
ii. Supervisor Call through interrupt
Code:
#include <stdio.h>
#include <string.h>
char M[100][4];
char R[4];
char IR[4];
int IC = 0;
char buffer[41];
int SI = 0;
void init() {
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 4; j++) {
M[i][j] = ' ';
}
}
for (int i = 0; i < 4; i++) {
R[i] = ' ';
IR[i] = ' ';
}
IC = 0;
SI = 0;
}
void StoreRegister() {
int address = (IR[2] - '0') * 10 + (IR[3] - '0');
for (int i = 0; i < 4; i++) {
M[address][i] = R[i];
}
}
int main() {
FILE *input = fopen("input_phase1.txt", "r");
FILE *output = fopen("output_phase2.txt", "w");
Load(input, output);
fclose(input);
fclose(output);
return 0;
}
Input:
$AMJ000100030001
GD10PD10H
$DTA
Hello
$END0001
$AMJ000100050001
GD10PD10GD20PD20H
$DTA
Hello
SY D Students
$END0001
Output: