Skip to content

Commit 87bb16a

Browse files
committed
Penambahan milestone 3
Penambahan source code milestone 3
1 parent 7986b60 commit 87bb16a

36 files changed

+4405
-70
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
**TBA** \
55
Repository ini akan digunakan sebagai duplikat public dari repository private yang terdapat pada GitHub Classroom informatika19 \
6-
Log : 3 April 2021, Upload v2.0.0
7-
Log : 23 April 2021, Penambahan README.md milestone 3
6+
Log : 3 April 2021, Upload v2.0.0 \
7+
Log : 23 April 2021, Penambahan README.md milestone 3 \
8+
Log : 27 April 2021, Penambahan milestone 3 dan branch baru
89

910
## Anggota:
1011
Nama | NIM

makefile

+183-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,190 @@
11
# 13519214 - Makefile
2-
all: diskimage bootloader kernel createfilesystem insertfilesystem
2+
all: basekernel shellpackage extrapackage createrecursiontest logoinsert
3+
4+
basekernel: diskimage bootloader kernel createfilesystem insertfilesystem
35

46
clean:
57
# -- Cleaning output files --
6-
@rm out/fs/*;
8+
@rm out/fs/*
79
@rm out/*
10+
@rm out/asm/*
11+
@rm out/shell/*
812

913
test: kernelgcc
1014

1115
cleantest: cleangcc
1216

17+
shellpackage: basekernel fileloader mash insertls insertcd insertmkdir \
18+
insertcat insertcp insertmv insertln insertrm
19+
20+
21+
extrapackage: shellpackage insertfile insertwc insertstrings insertmim \
22+
insertwhereis insertsnok insertprintf
23+
24+
mash:
25+
if [ ! -d "out/shell" ]; then mkdir out/shell; fi
26+
@bcc -ansi -c -o out/shell/mash.o src/mash.c
27+
@bcc -ansi -c -o out/shell/std_stringio.o src/std_stringio.c
28+
@bcc -ansi -c -o out/shell/std_fileio.o src/std_fileio.c
29+
@bcc -ansi -c -o out/shell/shell_common.o src/shell_common.c
30+
@bcc -ansi -c -o out/shell/std_opr.o src/std_opr.c
31+
if [ ! -d "out/shell/asm" ]; then mkdir out/shell/asm; fi
32+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
33+
@ld86 -o out/mash -d out/shell/*.o out/shell/asm/interrupt.o
34+
@cd out; ./loadFile mangga.img mash 0
35+
36+
insertls:
37+
if [ ! -d "out/shell/ls" ]; then mkdir out/shell/ls; fi
38+
@bcc -ansi -c -o out/shell/ls/ls.o src/ls.c
39+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
40+
@ld86 -o out/ls -d out/shell/ls/*.o out/shell/std_fileio.o \
41+
out/shell/std_stringio.o out/shell/shell_common.o \
42+
out/shell/std_opr.o out/shell/asm/interrupt.o
43+
@cd out; ./loadFile mangga.img ls 0
44+
45+
insertcd:
46+
if [ ! -d "out/shell/cd" ]; then mkdir out/shell/cd; fi
47+
@bcc -ansi -c -o out/shell/cd/cd.o src/cd.c
48+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
49+
@ld86 -o out/cd -d out/shell/cd/*.o out/shell/std_fileio.o \
50+
out/shell/std_stringio.o out/shell/shell_common.o \
51+
out/shell/std_opr.o out/shell/asm/interrupt.o
52+
@cd out; ./loadFile mangga.img cd 0
53+
54+
insertmkdir:
55+
if [ ! -d "out/shell/mkdir" ]; then mkdir out/shell/mkdir; fi
56+
@bcc -ansi -c -o out/shell/mkdir/mkdir.o src/mkdir.c
57+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
58+
@ld86 -o out/mkdir -d out/shell/mkdir/*.o out/shell/std_fileio.o \
59+
out/shell/std_stringio.o out/shell/shell_common.o \
60+
out/shell/std_opr.o out/shell/asm/interrupt.o
61+
@cd out; ./loadFile mangga.img mkdir 0
62+
63+
insertcat:
64+
if [ ! -d "out/shell/cat" ]; then mkdir out/shell/cat; fi
65+
@bcc -ansi -c -o out/shell/cat/cat.o src/cat.c
66+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
67+
@ld86 -o out/cat -d out/shell/cat/*.o out/shell/std_fileio.o \
68+
out/shell/std_stringio.o out/shell/shell_common.o \
69+
out/shell/std_opr.o out/shell/asm/interrupt.o
70+
@cd out; ./loadFile mangga.img cat 0
71+
72+
insertcp:
73+
if [ ! -d "out/shell/cp" ]; then mkdir out/shell/cp; fi
74+
@bcc -ansi -c -o out/shell/cp/cp.o src/cp.c
75+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
76+
@ld86 -o out/cp -d out/shell/cp/*.o out/shell/std_fileio.o \
77+
out/shell/std_stringio.o out/shell/shell_common.o \
78+
out/shell/std_opr.o out/shell/asm/interrupt.o
79+
@cd out; ./loadFile mangga.img cp 0
80+
81+
insertmv:
82+
if [ ! -d "out/shell/mv" ]; then mkdir out/shell/mv; fi
83+
@bcc -ansi -c -o out/shell/mv/mv.o src/mv.c
84+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
85+
@ld86 -o out/mv -d out/shell/mv/*.o out/shell/std_fileio.o \
86+
out/shell/std_stringio.o out/shell/shell_common.o \
87+
out/shell/std_opr.o out/shell/asm/interrupt.o
88+
@cd out; ./loadFile mangga.img mv 0
89+
90+
insertln:
91+
if [ ! -d "out/shell/ln" ]; then mkdir out/shell/ln; fi
92+
@bcc -ansi -c -o out/shell/ln/ln.o src/ln.c
93+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
94+
@ld86 -o out/ln -d out/shell/ln/*.o out/shell/std_fileio.o \
95+
out/shell/std_stringio.o out/shell/shell_common.o \
96+
out/shell/std_opr.o out/shell/asm/interrupt.o
97+
@cd out; ./loadFile mangga.img ln 0
98+
99+
insertrm:
100+
if [ ! -d "out/shell/rm" ]; then mkdir out/shell/rm; fi
101+
@bcc -ansi -c -o out/shell/rm/rm.o src/rm.c
102+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
103+
@ld86 -o out/rm -d out/shell/rm/*.o out/shell/std_fileio.o \
104+
out/shell/std_stringio.o out/shell/shell_common.o \
105+
out/shell/std_opr.o out/shell/asm/interrupt.o
106+
@cd out; ./loadFile mangga.img rm 0
107+
108+
insertfile:
109+
if [ ! -d "out/shell/file" ]; then mkdir out/shell/file; fi
110+
@bcc -ansi -c -o out/shell/file/file.o src/file.c
111+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
112+
@ld86 -o out/file -d out/shell/file/*.o out/shell/std_fileio.o \
113+
out/shell/std_stringio.o out/shell/shell_common.o \
114+
out/shell/std_opr.o out/shell/asm/interrupt.o
115+
@cd out; ./loadFile mangga.img file 0
116+
117+
insertwc:
118+
if [ ! -d "out/shell/wc" ]; then mkdir out/shell/wc; fi
119+
@bcc -ansi -c -o out/shell/wc/wc.o src/wc.c
120+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
121+
@ld86 -o out/wc -d out/shell/wc/*.o out/shell/std_fileio.o \
122+
out/shell/std_stringio.o out/shell/shell_common.o \
123+
out/shell/std_opr.o out/shell/asm/interrupt.o
124+
@cd out; ./loadFile mangga.img wc 0
125+
126+
insertstrings:
127+
if [ ! -d "out/shell/strings" ]; then mkdir out/shell/strings; fi
128+
@bcc -ansi -c -o out/shell/strings/strings.o src/strings.c
129+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
130+
@ld86 -o out/strings -d out/shell/strings/*.o out/shell/std_fileio.o \
131+
out/shell/std_stringio.o out/shell/shell_common.o \
132+
out/shell/std_opr.o out/shell/asm/interrupt.o
133+
@cd out; ./loadFile mangga.img strings 0
134+
135+
insertmim:
136+
if [ ! -d "out/shell/mim" ]; then mkdir out/shell/mim; fi
137+
@bcc -ansi -c -o out/shell/mim/mim.o src/mim.c
138+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
139+
@ld86 -o out/mim -d out/shell/mim/*.o out/shell/std_fileio.o \
140+
out/shell/std_stringio.o out/shell/shell_common.o \
141+
out/shell/std_opr.o out/shell/asm/interrupt.o
142+
@cd out; ./loadFile mangga.img mim 0
143+
144+
insertsnok:
145+
if [ ! -d "out/shell/snok" ]; then mkdir out/shell/snok; fi
146+
@bcc -ansi -c -o out/shell/snok/snok.o src/snok.c
147+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
148+
@ld86 -o out/snok -d out/shell/snok/*.o out/shell/std_fileio.o \
149+
out/shell/std_stringio.o out/shell/shell_common.o \
150+
out/shell/std_opr.o out/shell/asm/interrupt.o
151+
@cd out; ./loadFile mangga.img snok 0
152+
153+
insertwhereis:
154+
if [ ! -d "out/shell/whereis" ]; then mkdir out/shell/whereis; fi
155+
@bcc -ansi -c -o out/shell/whereis/whereis.o src/whereis.c
156+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
157+
@ld86 -o out/whereis -d out/shell/whereis/*.o out/shell/std_fileio.o \
158+
out/shell/std_stringio.o out/shell/shell_common.o \
159+
out/shell/std_opr.o out/shell/asm/interrupt.o
160+
@cd out; ./loadFile mangga.img whereis 0
161+
162+
insertprintf:
163+
if [ ! -d "out/shell/printf" ]; then mkdir out/shell/printf; fi
164+
@bcc -ansi -c -o out/shell/printf/printf.o src/printf.c
165+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
166+
@ld86 -o out/printf -d out/shell/printf/*.o out/shell/std_fileio.o \
167+
out/shell/std_stringio.o out/shell/shell_common.o \
168+
out/shell/std_opr.o out/shell/asm/interrupt.o
169+
@cd out; ./loadFile mangga.img printf 0
170+
171+
createrecursiontest:
172+
if [ ! -d "out/shell/recursion_test" ]; then mkdir out/shell/recursion_test; fi
173+
@bcc -ansi -c -o out/shell/recursion_test/recursion_test.o src/recursion_test.c
174+
@nasm -f as86 src/asm/interrupt.asm -o out/shell/asm/interrupt.o
175+
@ld86 -o out/recursion_test -d out/shell/recursion_test/*.o out/shell/std_fileio.o \
176+
out/shell/std_stringio.o out/shell/shell_common.o \
177+
out/shell/std_opr.o out/shell/asm/interrupt.o
178+
@cd out; ./loadFile mangga.img recursion_test 0
13179

180+
logoinsert:
181+
@cp other/logo.hoho out/logo.hoho
182+
@cd out; ./loadFile mangga.img logo.hoho 255
14183

15184
# Main recipes
16185
diskimage:
17186
# -- Initial mangga.img --
187+
if [ ! -d "out" ]; then mkdir out; fi
18188
@dd if=/dev/zero of=out/mangga.img bs=512 count=2880 status=noxfer
19189

20190
bootloader:
@@ -25,21 +195,23 @@ bootloader:
25195
kernel:
26196
# -- Source Compilation --
27197
@bcc -ansi -c -o out/kernel.o src/kernel.c
28-
@bcc -ansi -c -o out/std.o src/std.c
198+
@bcc -ansi -c -o out/std_stringio.o src/std_stringio.c
199+
@bcc -ansi -c -o out/std_fileio.o src/std_fileio.c
29200
@bcc -ansi -c -o out/screen.o src/screen.c
30-
@bcc -ansi -c -o out/shell.o src/shell.c
31201
@bcc -ansi -c -o out/output.o src/output.c
32-
@bcc -ansi -c -o out/opr.o src/opr.c
202+
@bcc -ansi -c -o out/std_opr.o src/std_opr.c
33203
@nasm -f as86 src/asm/kernel.asm -o out/kernel_asm.o
34-
@ld86 -o out/kernel -d out/*.o
204+
if [ ! -d "out/asm" ]; then mkdir out/asm; fi
205+
@nasm -f as86 src/asm/interrupt.asm -o out/asm/interrupt.o
206+
ld86 -o out/kernel -d out/*.o out/asm/interrupt.o
35207
# ------------ Compiled kernel stat ------------
36-
# Max Kernel Size : 15872 bytes (31 sectors, 1 sector = 512 bytes)
208+
# Max Kernel Size : 8192 bytes (16 sectors, 1 sector = 512 bytes)
37209
@stat --printf="Kernel Size : %s bytes\n" out/kernel
38210
# ----------------------------------------------
39211
@dd if=out/kernel of=out/mangga.img bs=512 conv=notrunc seek=1 status=noxfer
40212

41213
createfilesystem:
42-
[ -d out/fs ] || mkdir out/fs;
214+
if [ ! -d "out/fs" ]; then mkdir out/fs; fi
43215
@./other/fscreate out/fs/map.img out/fs/files.img out/fs/sectors.img
44216

45217
insertfilesystem:
@@ -49,10 +221,12 @@ insertfilesystem:
49221
@dd if=out/fs/sectors.img of=out/mangga.img bs=512 count=1 seek=259 conv=notrunc status=noxfer
50222

51223
filesystemcreator:
224+
if [ ! -d "other" ]; then mkdir other; fi
52225
@gcc -Wall -Wextra -O3 -o other/fscreate other/filesystem_create.c
226+
chmod +x other/fscreate
53227

54228
fileloader:
55-
@gcc -Wall -Wextra -O3 -o other/loadFile other/fileloader.c
229+
@gcc -Wall -Wextra -O3 -o out/loadFile other/fileloader.c
56230

57231

58232
# Test recipes

src/asm/bootloader.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
bits 16
88
KSEG equ 0x1000 ;Lokasi kernel = 0x10000
9-
KSIZE equ 31 ;Ukuran kernel = 31 sektor
9+
KSIZE equ 16 ;Ukuran kernel = 16 sektor
1010
KSTART equ 1 ;Lokasi kernel = sektor 1
1111

1212
;boot loader starts at 0 in segment 0x7c00

src/asm/interrupt.asm

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
global _interrupt
2+
3+
;int interrupt (int number, int AX, int BX, int CX, int DX)
4+
_interrupt:
5+
push bp
6+
mov bp,sp
7+
mov ax,[bp+4] ;get the interrupt number in AL
8+
push ds ;use self-modifying code to call the right interrupt
9+
mov bx,cs
10+
mov ds,bx
11+
mov si,intr
12+
mov [si+1],al ;change the 00 below to the contents of AL
13+
pop ds
14+
mov ax,[bp+6] ;get the other parameters AX, BX, CX, and DX
15+
mov bx,[bp+8]
16+
mov cx,[bp+10]
17+
mov dx,[bp+12]
18+
19+
intr: int 0x00 ;call the interrupt (00 will be changed above)
20+
21+
mov ah,0 ;we only want AL returned
22+
pop bp
23+
ret

src/asm/kernel.asm

+41-21
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,32 @@
55
;kernel.asm contains assembly functions that you can use in your kernel
66

77
global _putInMemory
8-
global _interrupt
8+
; global _interrupt
99
global _makeInterrupt21
1010
global _getRawCursorPos
1111
global _getFullKeyPress
12+
global _launchProgram
1213
extern _handleInterrupt21
1314

15+
16+
; void launchProgram(int segment)
17+
_launchProgram:
18+
mov bp,sp
19+
mov bx,[bp+2]
20+
mov ax,cs
21+
mov ds,ax
22+
mov si,jump
23+
mov [si+3],bx
24+
mov ds,bx
25+
mov ss,bx
26+
mov es,bx
27+
mov sp,0xfff0
28+
mov bp,0xfff0
29+
30+
jump: jmp 0x0000:0x0000
31+
; TODO : Extra, forkexec, currently no memory left for kernel modification
32+
; outline : save address, put on stack, do jump again
33+
1434
;void putInMemory (int segment, int address, char character)
1535
_putInMemory:
1636
push bp
@@ -26,26 +46,26 @@ _putInMemory:
2646
ret
2747

2848
;int interrupt (int number, int AX, int BX, int CX, int DX)
29-
_interrupt:
30-
push bp
31-
mov bp,sp
32-
mov ax,[bp+4] ;get the interrupt number in AL
33-
push ds ;use self-modifying code to call the right interrupt
34-
mov bx,cs
35-
mov ds,bx
36-
mov si,intr
37-
mov [si+1],al ;change the 00 below to the contents of AL
38-
pop ds
39-
mov ax,[bp+6] ;get the other parameters AX, BX, CX, and DX
40-
mov bx,[bp+8]
41-
mov cx,[bp+10]
42-
mov dx,[bp+12]
43-
44-
intr: int 0x00 ;call the interrupt (00 will be changed above)
45-
46-
mov ah,0 ;we only want AL returned
47-
pop bp
48-
ret
49+
; _interrupt:
50+
; push bp
51+
; mov bp,sp
52+
; mov ax,[bp+4] ;get the interrupt number in AL
53+
; push ds ;use self-modifying code to call the right interrupt
54+
; mov bx,cs
55+
; mov ds,bx
56+
; mov si,intr
57+
; mov [si+1],al ;change the 00 below to the contents of AL
58+
; pop ds
59+
; mov ax,[bp+6] ;get the other parameters AX, BX, CX, and DX
60+
; mov bx,[bp+8]
61+
; mov cx,[bp+10]
62+
; mov dx,[bp+12]
63+
;
64+
; intr: int 0x00 ;call the interrupt (00 will be changed above)
65+
;
66+
; mov ah,0 ;we only want AL returned
67+
; pop bp
68+
; ret
4969

5070
;void makeInterrupt21()
5171
;this sets up the interrupt 0x21 vector

src/basic-header/std_opr.h

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// 13519214 - Basic operation
2+
3+
int div(int a, int b);
4+
5+
int mod(int a, int n);

0 commit comments

Comments
 (0)