-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.c
More file actions
65 lines (51 loc) · 2.13 KB
/
kernel.c
File metadata and controls
65 lines (51 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <stdint.h>
#include "limits.h"
#include <stdint.h>
void run_test();
void k_printstr(char *string, int row, int col);
void print_border(int start_row, int start_col, int width, int height);
void k_clearscr(int start_row, int start_col, int width, int height);
int main() {
k_clearscr(0, 0, 80, 25); //call the function to clear the screen // written by you in C
print_border(0, 0, 80, 25); //call the function to print the border // written by you in C
run_test(); //call run_test() // written by the professor
//loop that spins for approximately INT_MAX (found in limits.h) iterations
for (int i = 0; i < INT_MAX; i++) { //loop INT_MAX times
}
k_clearscr(0, 0, 80, 25); //call the function to clear the screen
//add another loop that fills the screen with stars.
//print a row of 80 stars('*') at line i, row 0
for (int i = 0; i < 25; i++) { //loop i from 0 to 24
for(int j = 0; j < 80; j++){
k_printstr("*", i, j); //void k_printstr(char *s, int row, int col);
}
}
//end loop
while (1) {
}//loop forever // Its done, but the OS has nowhere which to return!
}
// but they must call k_printstr() to get their work done
void print_border(int start_row, int start_col, int width, int height) {
k_printstr("\xC9", start_row, start_col);
k_printstr("\xBB", start_row, start_col+width-1);
k_printstr("\xC8", start_row+height-1, start_col);
k_printstr("\xBC", start_row + height-1, start_col+width-1);
for (int i = start_col + 1; i < start_col + width - 1; i++) {
k_printstr("\xCD", start_row, i);
k_printstr("\xCD", start_row + height -1, i);
}
for (int i = start_row + 1; i < start_row + height - 1; i++) {
k_printstr("\xBA", i, start_col);
k_printstr("\xBA", i, start_col + width - 1);
}
}
// Note that k_clearscr() can also clear a portion of the screen
void k_clearscr(int start_row, int start_col, int width, int height) {
for (int i = start_row; i < height+start_row; i++) {
for (int j = start_col; j < start_col+width; j++) {
k_printstr(" ", i, j);
}
}
}
// calls k_printstr() twenty five times passing it a string of the required number of spaces