okay i'm feeling up to a little bit more
of this
os dev here that was my videos folder as
you saw so
i got my water ready i think i'm okay to
go for a little bit longer
uh there's an asterisk at the end
because that could mean you know five
days straight or it could mean 30
minutes we'll see
but i did say i wanted to get the delete
file shell command done i want to get
other one other commands done as well
but i wanted to start with that one so
let's go ahead and try and
i am recording that's good let's go
ahead and try and implement
the delete file so let's try and do that
so i did set up a del okay
i'm going to forget about that so let's
copy that word
okay i'll push
so put this here okay
let's just copy all of that
so instead of command shutdown i want to
make it command
delete file
so i didn't want to do that i wanted to
do that
not go to shutdown we will go to delete
file we'll make a new
thing for that which will be i don't
know where down here somewhere
shut down it in let's do it before then
we'll do it uh let's do it after
clear screen sure
which means i'll copy it to begin with
delete a file from the disk
we'll call it delete file
which i think is what i what i called it
i call it yes yes i did that's good
we can make it a separate include file
yeah we'll call delete
fi well i want to call it that now
call delete file and then we'll jump get
input so let's call this
dell
or call this dell i don't know we'll
call it dell file whatever
can't name this thing the things the
same name unfortunately it's annoying
but that's all right so let's make a new
file for delete file
let's do that it will be back here and
include
i guess disk what do we have it include
actually what what
what all we got in there don't have a
tree command now
include disk we have load so be on this
we have load file and save file we'll
put delete file in there so let's
touch include disk
delete file.inc cool and then we'll
open that up
as well as save file because again i
forget things
so i'm gonna take in one parm for this
put one file name to delete
that's the only one we're gonna do now
delete file
we'll do our things here push bp well
this will be included in the kernel
but i'll probably pass
the parm which is the second token which
will be the file name here
i'll probably still pass that like we're
doing here and push it
i guess i could access it from the
tokens array
but that wouldn't be very clear if i'm
doing this in a separate file it would
be like where is that coming from so
i'll probably do the same thing here
i'll do push and popping that's what i
wanted to do anyway
so let's continue doing this move bpsp
wherever we want to put the par and
we'll assume the file name let's just
put it into
i don't know we'll do bx to start off
for now we'll just do px
this will be bx
ep plus four
turn to caller i'll put it as a dot
ax vp minus two
um assuming things were normal
we'll just move a zero in there
success normal return okay
i know i'm typing this out instead of
copy and pasting i'm just
getting my typing experience in right
uh pop bx that was the only one we
pushed
all right move spbp
and pop bp
a good old return return to caller
what we're gonna have to do is probably
load
i guess we'll assume it's not loaded to
memory but we'll load the file table to
memory
we'll search each file table entry each
16 byte entry for the file name
and if it finds it we're going to i
guess we'll load an
area of memory equal to the file size
we'll
basically null byte it will load zeros
we'll zero all that out and then save
that to the disk
so whatever you know space that that
file or program took up we're gonna make
all zeros
and then i'm thinking i'm gonna change
the file name and that file table entry
to like free space or something so then
later if we look and we see free space
and be like okay we can write to that
we can put a file there without without
issue so
that's my you know my simple file system
implementation for this that's what i
want to do
i'll try and work towards that now
copy with a y there we go we put a p
there we go
so cx is not going to be 10 that's
assuming si
set up um let's do that we'll do
s i
might as well we should we should be
pushing and popping di because we're
messing with it inside of this
but we're not because we're bad people
so we're gonna keep being bad people
put it there okay
which we don't want that multiple times
so
delete file name
file name delete whatever delete file
name that's
bad name but whatever
got to use bad label names 6x won't
necessarily be 10
um depending on spaces and things we
could pass the length of the name
okay let's say we have two parms
changing everything on the fly
that's okay
so let's do second part will be length
of file name sure so
push s i push bx
pop them in reverse order
file name to delete will be the first i
guess
and then we'll move bp plus six
length of file we'll assume this is
going to be the length
which would be a word value
so bx to cx and there we go that'll move
file name length bytes from si which
will be the file name into di
which is our variable so that'll save
off the file name okay
hopefully hopefully it saves it all
i'm not gonna do this but i'm just gonna
copy this stuff you know we'll just
we'll just copy paste this
right we'll do that
um if we found the file we want to
delete it
so we're not really doing all this but
it will be writing
that's okay underlines yanked you'll
love to see it okay search file table
for file name that's all good
we don't need to worry about the
starting sector
don't care about that
compare file names is what we're going
to be doing
so the starting bytes will be starting
by file name in the file table we'll
compare that to si which will be
file name to delete i'll jump to compare
stick except instead of saving we'll put
delete
so we're terrible people and we don't
have good label names
otherwise we'll go to the next entry
that's easy enough
push d i sure so di will be the start
save start of file name
cx10 well this can be
i forgot i was like did we save off the
length into a variable no we didn't
that's okay we could save the file size
like we did over here
but i didn't do that so far because we
haven't needed to so far so length of
file name is mbx sorry
delete file size it'll be
a byte so this will be
we'll do delete file name length that's
what i want this to be
super long variable name of course
of course you gotta have super long
variable names
otherwise you're not a legit programmer
everyone knows that copy file name
length to variable
i'll probably want to make that a word
don't we
since it's a word value
we can move bx into
or we can do it this way delete file
name length
that's all we have to do there we go
into that byte
we want to move that into cx
we can move bx into here but i figure if
we're going to change it somewhere i
might as well use the variable for this
makes it a little bit easier to read i
think
the length of filename will move into cx
and we'll be comparing against
si and yeah and the file table okay
and compare
file name saving check file name save
because i'll need to be deletes
these all need to be delete check file
name delete that's what i put there
anyway
pair file names delete
check file name delete
i don't need this i just need to jump
equal
otherwise it's not going to be equal
it'll move on anyway that's redundant i
don't need that
it's equal we'll go here otherwise it'll
do this yeah i don't that's redundant i
don't need that
well they call this micro optimization
is that what this is
this more yak shaving i don't know but
it works
at 16 go back to check okay yeah that's
fine restart check
saving will be delete
actually we don't need a label here
that's the only time this shows up so
there we go
thing over here right just got to make
sure
yep
found file saving we're going to call
this found file delete as you do
oh yeah we're creating a new file by
default when we save so that's why these
are to-do's
because i was like if we found it it
wouldn't be a new file but it's because
in save file we're making a new one
anyway yeah
forgot about that so we're not making a
new file on this one it definitely
exists
definitely exists
so we don't need to create a new one we
already found it
d i should point to the start so d i
should point to the name
right if we compare them all
do that okay file name saving we want to
change
well we want to change the name that we
write to the disk
and we do want to move side to di but si
we're going to rename our file name here
we have the delete file name we want to
set it to a new one but we have to
we have to set it up in a memory
assemble time
so we can put it here um i'll call it
free space
because our file name i kind of want it
to be like
this free space
one two three four five six seven eight
because that's exactly ten long
see genius exactly ten long
to i can set the si to that right yeah
let's let's do that
so we want to write the 10 bytes free
space
into our file table entry so that's what
we do cool
the file type um bin or
text we don't have file type
so i'll put it here
we don't have file type right now it
could be either it could just be blanks
it'll just be blanks one two three
that'd be blanks of course instead of
needing to do that we could just
let's move al space let's do that then
we don't need to do this right this will
be file type
yeah i'm writing the file table entry
and then i'm writing the file
data yeah which this will all be zeros
okay yep running the file table entry
first so right new right changed i guess
i'll put changed
changed file table entry first
okay file type will be all blanks
directory entry will be zero
the last saved sector starting sector
will be
zero and the file size
well we'll be the same the file size
will be the same i guess we do want that
the same
probably want to get the file size don't
we
because the file size will be the same
it'll just be nulled out it'll be all
zeros but we don't we want to make sure
the same amount of space is still
reserved for future stuff
so yeah we'll we'll put file size there
as well
all right so where do we get the file
size
it's just a byte i guess when we find
the file
before we pop the i well we can pop the
i yeah that's fine
i wouldn't find the file we can get the
size so this is still esdi
that day yeah so esdi plus
15 that's the last byte right so should
be 15.
yeah file sizes by 15. so we're starting
it
we're starting at the beginning so plus
one two three four five six seven eight
nine
ten twelve thirteen fourteen
fifteen so yeah move that to al
and we'll move
al into the delete file size label
that variable there we go
bx shouldn't really matter here actually
okay so that'll write the file table
which will be changed that'll be good
we'll just write error there if it
happens otherwise write file data
so this will be blank
oh no not that
would be right blank file data
i made a success first that's
interesting
i'll do that down here
the error we'll put down here this would
be a one
or two well as long as it's not zero
it's an error one must be error
error occurred
right file data error occurred
so we need to set up a memory location
to write so let's do that
setup memory location
um it's right now data2
we need a guaranteed free space and
memory i guess to write
to oh yeah we would yeah we would we
need a space as big as the file but
filled with zeros
when we run programs they're loaded to
eight thousand
when the editors ran it's loaded to
eight thousand so i don't wanna use
eight thousand
nine thousand is for the stack kernel is
at
two thousand the file table is at one
thousand
well since this is going to run in the
kernel and i normally load programs
to memory location 8000
i'm going to load it to 8 000. in the
editor i'm doing other stuff with the
current
file we're editing loaded to 1000 but
the kernel programs are loaded to 8000
so that's where i'm going to put this
i'm going to move ax 800h
send that to es segment address file to
right this will be 8 thousand
all right xor bx x
um put it there
okay the file size is how many
sectors the file is
how many hexadecimal sectors number of
sectors to write yeah that's in file
size so file sizes and sectors
let's also delete file size so we want
to
zero out all the memory before we write
it
how do we do that well we have the file
size in sectors that's how much it's
going to take up
so let's xor di to set it also we'll set
esdi to the start of 8000
as well
okay and so xor ax
set it to zero
cx will be
our file size which is in bytes
multiplied by 512
right yeah
so
do this cl will move by
delete file size
that into cl and then if hopefully i can
do this
this might be a legal instruction i
don't know we're going to try to
multiply
cx by 512 and put that into cx so it'll
contain file size and bytes
and that's how many times we want to
store
bytes to this memory location esdi
eight thousand okay right
nulls um
to memory location put right
i don't know zeroed out data if that
makes sense
to disk or the nulled out data that we
just made
check number so we do need to get the
the sector that it starts at though we
do need to get that as well
let's rename this to delete starting
sector
and that'll be a bite
i'll just export down here
there we go
stuff over here will uh want to put
there
okay and that should write
all the sectors at memory location and
espx which will be
800 0 which would be 8 000.
i'll write all those zeros to the disk
so we need to get the starting sector
and then we should be good i think
so three yyyy
get starting sector
to be 14 this will be delete
starting sector that's what i called it
right yeah
cool cool beans okay
i think this will be okay so we should
put in delete file and then if we
recheck the file table like with the
directory command and the kernel
um it should show free space and zeroed
out
stuff okay and the new file table entry
so let's see what we need to change
because cannot call delete file
undefined symbol this is in kernel 404
cannot call delete file because it's not
included yes i did not
include it here so of course you can't
call it
because it don't exist yet dude all
right include
disk delete
file dot inc
so by file size and ao undefined simple
file size that is true
[Music]
found it it's deletes
delete file inc one two three undefined
symbol return to color saving that's
also true
so we can do one two three capital g and
we go to the line
i'm saying this out loud so that i
remember
turn to caller saving yes it's just not
return to caller
and there we go so
let's see what happens so currently we
have
dir editor calculator let's say hey i
hate calculator
we haven't done anything with it in this
series because i hate calculators so
let's just get rid of it so
let's try d e l d e l space
um
o c-a-l-c-u-l-a-t-o-r enter
so it looks like nothing happened there
and uh and that's you know not great of
course
of course it does nothing because we
can't really do that
stuff yeah i forgot to push the
arguments and everything
okay so we need to get instead of
calling delete file
we push the stuff first all right
push arguments on stack before call
dummy
why would i expected that to work
i don't know why then we need to clean
up the stack
clean up stack after call so
and also check return code for errors
all right so clean up stack that's easy
we can add four to the stack pointer
right this doesn't matter right now but
we'll compare to zero
we want to push stuff first we want to
push
um the token that we got
the length we should have
in the token length array so we need to
go through the tokens array
just put this here push file name
all right
file name length okay
just for placeholders but we should have
these in the tokens
and tokens length arrays these will be
filled out
but it'll be the second token
which will be at position 10 in the
tokens array
so we'll move
um i don't know for lack of better
register we'll move si
to tokens
and we'll add 10 to get the first token
let's set another variable we don't have
enough variables yet we need more
we need like a 50 000 and we're not
there yet
so file i know i named these camel case
but i'm going to do snake case so you
can sue me for that file name
token file name aha that won't be
ever confusing like it is right now uh
times 10 db 0
that is it move di
token file name move cx
so here i'm going to push i guess push
word
you can push token file name it'll push
the address of the name
which should be all right cx will be
it won't exactly be 10 it'll be less
than 10 for some
what is the exact length it would be in
token's length
plus one which is a word
so yeah word
token's length plus one
will actually be plus two plus two two
for a word value the first token would
be it
would be at position zero in the length
array since they're all words
the second one would be at position two
so push cx for this
all right and call the leap file clean
up the stack
check return code for errors we'll do
that later maybe i'll probably not do it
because i'm lazy we'll see
and no assemble error is always good so
we don't like calculator
what happens if we enter it in right and
don't make any mistakes
c-a-l-c-u-l-a-t-o-r enter
so it just hangs which is interesting
i'll just i'll do that i'll make sure
it's a word by doing that i don't think
that's the issue though
but maybe it never finds the name
[Music]
oh maybe not it might not find the name
nope it keeps checking
it does not go to the end that is why
third si otherwise add the no otherwise
it's compared to zero
are we at the end of the file table if
so we need to
not check i need to go to dot return to
caller need to do this
all right
actually no let's go it's uh
next name we're not at the end of the
file table
we'll go and check the next name
otherwise we are at the end of the file
table we have not found the name we're
looking for
we're gonna say there is an error and
we'll jump to
return to caller which is way down there
this dot is not going to work
so we need to rename this awesome
delete return to caller
so bad
okay
just needs to be a jump not jump equal
there we go
that's fine otherwise we'll go to the
next name
okay delete return to caller
does not have a dot no it doesn't that's
true
there we go
okay now let's see if it hangs delete
well let's check directory delete
c-a-l-c-u-l-a-t-o-r
oh put some garbage gobbledygook because
we're not setting es
in ds correctly maybe we're not
resetting or something i don't think we
are
that would make sense let's try to
reboot though
reboot did not work so that's good
stuff enters all right i found another
way in qemu is uh you can do reset
and that'll also reload hey so i just
realized
i have the kernel open on the right here
i just realized that i'm calling delete
file not using the file name so i have
token file name set up
token file name is set up you know down
there but i'm not even filling it out
i'm just setting di if i move the length
i need to
do this move the byte move from s i
tokens array position into the file name
that's what i'm pushing
i'm a dork anyway not that that was our
issue but that was an
issue that i needed to do so that should
at least be
a little bit fixed maybe probably not
um yeah and then we'll have to change
we'll do this again
okay i don't think that was the issue
oh now we're over that limit that's
always good
the kernel is now one more
which means save file needs to be
changed this will be 560.
this needs to be
five five not six that's five
starts at seven now
r seven 9r8
r9
all right other files i will definitely
need to change i know
i think save file i'll have to change as
well
eventually hopefully i don't have to
change these but i do i think there was
a six in here somewhere
i thought it was this file yeah to start
writing it
no file table will be at it's after the
kernel i should place it before the
kernel and then i won't have to worry
about this as much
definitely but that is all right
and yeah file table is not there so
print file table doesn't work directory
doesn't work
of course yeah
yeah starting sector 7.
still a bunch of garbage a bunch more
garbage
did not delete calculator so i got
errors okay i'm going to still look for
these errors i'll get back when i
maybe find something okay so
i think i found the issue i'm gonna show
you that it does work now and then i'll
explain and go
through but see on a fresh new thing
here
well i have free space never mind let's
delete another one let's delete
the editor and hope we don't do it
delete editor we get a prompt i need to
put a new line before it comes back
but we deleted it we get free space we
get no extension
entry is zero start sector is now zero
for these
and sizes you know however many zeros we
got so it seems to be working
uh at first glance so that's good so
what did i do let's do that again
i changed a few things hopefully i
remember them all but i might not
i know in the boot sector and then in
all of the
just run this source
so in the boot sect asm
and then in the load and save file files
as well as delete
whenever it was referencing the file
table i moved it to sector seven
instead of six because the kernel took
up five sectors i had to change that and
the other files
you know i had to load the file table at
sector seven now because it follows the
boot sector still on the disk and then i
changed
you know where we print out the file
table inside of a print file table
you know it's looking for sector seven
load and save file file tables looking
for sector seven so that's all i did
first off so some other smaller things
which hopefully i marked all of them
down
we'll see is that in i gave them little
new labels here so i'd know
so in the kernel
when we moved to the next position this
was increment bx
but i changed the token's length array
to be words and words are two bytes and
not one byte so instead of increment
you can either put increment bx twice or
you can do add bx2
which takes up one more byte if you did
increment bx two times it would take up
one less byte but i'm not worried about
that right now so
add bx2 because each length is actually
one word
all right here this was move cx byte
token's length i changed it to move cx
word
token's length i don't remember if i
changed anything here so just you know
pause and check i guess if i did or not
but
so the other thing was in disk
and delete yep and delete here so i
don't remember how these were but
i think these were messed up i don't
know i changed it when we push the
commands
when we call from the kernel the base
pointer is going to be
equal to you know the current address
pushed onto the stack and then the jump
command
and those are both words so that will be
two sets of two bytes that'll be four
bytes
so the first farm that we push will be
at bp plus four but since the stat grows
down
um the first part that we push for an
argument to this
file or program or whatever this command
on the stack is going to be at the
higher position
bp plus six on the length of file name
we push
second since the stat grows down it'll
be at two bytes lower than the file name
so the length will be at bp plus four
get rid of those okay what else um
oh yeah i didn't have i didn't have this
before after i was repeat moving
into the file name s i and d i both
increment
so s i would not be set to the start
anymore of the file
of the file name so i'm just resetting
that here
i added these two lines to reset si to
the start of the file name
um okay so before sorry i'm jumping
around a lot um
under found file delete label i think
this pop was there before that's fine
here where we're doing the file type
this was a move before this was move
sb that moves si into di we're using al
we want that to be store to move al into
di
so at si this needs to be in al
file table um then we had to change the
sector like i said the file table sector
file table is now at sector seven
because the kernel takes up five sectors
now
anything else in here okay um this was
wrong i had to reverse this order i
think this was s hi then bx
this needs to be opposite from the start
which is now push
push si push bx so since the stack is
last in first out we need to
pop bx and then si that's what i'm doing
here
i think that was wrong before and i
changed that
and i believe that's all that i changed
there's no more new things here
i didn't need to run make again but i
did because i got rid of the labels so
we have calculator so if we do del space
calculator press enter it goes back
i can clear the screen run this again
and
calculator is now free space heyo if
there's an error i do want to write an
error maybe i'll put that as a to-do
item but
that's it when we return we should print
a new line before
the prompt though so let's put that in
right quick
just because it looks a little bit
better before we do get input
well i'll tell you what we're going to
do this is bad but i don't
care right now so
whatever
zero e zero a we are going to change
this
but i wanted to print out a new line
first so
zero zero d we we are going to change
that
of course but i just want to make sure
it works first
it didn't move it to the start that's
interesting i did move it there
wonder oh hey
i'm very tired
hey y'all not ah big dummy okay
so deleter there we go oh so good
that new line but we can delete things
now willy-nilly all like
and uh it's not very good for protecting
memory but oh well we're assuming the
user and programmer knows what they're
doing they can just delete stuff
but anyway delete works for you know
basic implementation right now so i'm
going to mark that down
next time i get back to this i can make
a rename file command
rename command ren and uh yeah i'll get
back to it then thanks for watching i do
appreciate it
[Music]
you