idk what i added

This commit is contained in:
2025-12-30 22:52:30 +00:00
parent 0222a7adb9
commit e0809f84dc
10 changed files with 491 additions and 112 deletions

View File

@@ -62,8 +62,7 @@ os_format_fat_filename:
pusha
call os_upper_case
call os_string_length ; Stores the length of the string in cl
mov bl, 11
sub bl, cl ; 11 - string_length
xor ch,ch ; Clear ch to reset it to 0
.character_loop:
lodsb
cmp al, 0
@@ -71,10 +70,18 @@ os_format_fat_filename:
cmp al, 2Eh ; 2Eh
je .add_spaces ; This will end up back at .character_loop
stosb
inc ch
jmp .character_loop
.add_spaces: ; Add the number of spaces as bl holds
mov al, ' ' ; 20h = space
; Work out the number of spaces in between
; the name and extension.
; 8 - name_length(ch)
xor bl, bl
sub bl, ch
add bl, 7
.spaces_loop:
stosb
cmp bl, 0
@@ -85,6 +92,58 @@ os_format_fat_filename:
popa
ret
; Does the inverse of the previous
; Converts a fat filename back to human readable
; eg. 'KERNEL BIN' -> 'KERNEL.BIN'
; input: si points to fat filename (11 bytes)
; output:
; di points to the unformatted filename
; [file_name_length] stores the length of the filename
string_unformat_fat_filename:
pusha
xor ax,ax
xor dx,dx
mov cx, 11 ; Counter
.name_loop:
lodsb
stosb
dec cx
inc dx
cmp cx, 3
jne .name_loop
push si
mov si, di
.space_loop:
dec si
lodsb
dec si
dec dx
cmp al, 20h ; Space
je .space_loop
jmp .insert_stop
.insert_stop:
mov di, si
inc di
inc dx
pop si
mov al, 2Eh
stosb
mov cx, 3
.extension_loop:
lodsb
stosb
dec cx
inc dx
cmp cx, 0
jne .extension_loop
.finish:
inc dx
mov [file_name_length], dx
popa
ret
; Convert a string to all upper/lower case
; INPUT: si pointing to a string
; OUPUT: the same string in memory will now be capitalised/decapitalised