NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: macaswell on November 17, 2010, 07:06:13 PM
-
Okay, I'm making an OS, Casnix OS (search "casnix" on google). My list_directory function, or ls function, is broken, and I can't find what I changed that broke it.
Can someone look at the code below and help me determine if it's a variable in the ls function, or an external variable that could cause this.
list_directory:
mov cx, 0 ; Counter
call os_get_file_list
mov si, dirlist ; external var
mov ah, 0Eh ; BIOS teletype function
.repeat:
lodsb ; Start printing filenames
cmp al, 0 ; Quit if end of string
je .done
cmp al, ',' ; If comma in list string, don't print it
jne .nonewline
pusha
call os_print_newline ; But print a newline instead
popa
jmp .repeat
.nonewline:
int 10h
jmp .repeat
.done:
call os_print_newline
jmp get_cmd
This compiles okay (its part of the CLI module in my kernel), but when I run my OS and get to the command line and type in the command ls
Casnix OS/I version 1.0.1
Built-in commands: ls, cat, ......
$ ls
# prints a new line here, but not the files
$
On the boot disk, there are atleast 8 files, and I can view them in my filemanager.
So, again; Can you help me find the error?
-
I would check the al value, it could be that your os_get_file_list returns EOS (ie end of string)
-
My list_directory function, or ls function, is broken, and I can't find what I changed that broke it.
Compare it with a version that worked then.
Can someone look at the code below and help me determine if it's a variable in the ls function, or an external variable that could cause this.
Check separately whether os_get_file_list does what you expect it to. Is the dirlist variable filled by that code? Is the ds register set to point at dirlist correctly? (Do you have a debugger?) Pretty much guessing here, but I might take another look if that doesn't solve your problem.
I would check the al value, it could be that your os_get_file_list returns EOS (ie end of string)
No, the condition that checks for EOS is behind the lodsb instruction that loads al with the first/next byte of the string. So, if the dirlist buffer is filled by os_get_file_list the condition will check the buffer's first byte. The function's return al value is discarded.
-
Int 10h/0Eh expects "video page" in bh. That's the only thing in the posted code that I see (or don't see) that could be a problem. You probably wouldn't see the newline either, if that were the problem(?). Possibly ds not right(?). I suspect the "external variable" (in -f bin mode???) "dirlist" isn't being filled right(?).
Hard to help you debug this stuff "blind"! I googled "casnix" (help you get your hit-count up) - I see the "download" button, but still no files! I realize you're still adding functionallity - that's the point of putting it on svn, so others can see your changes (and "help", IF you wish to give others write access). I can be found at fbkotler at myfairpoint dot net (or users.sf.net). I'll look at it, but no promises that I can find anything, of course. I think you've posted enough messages to be able to attach a file here, too... but perhaps not the best thing for a "work in progress".
The generic answer to "Why doesn't my code work?" is "Because something you believe to be true is not true." You just have to figure out which thing that is! :)
Best,
Frank
-
No, the condition that checks for EOS is behind the lodsb instruction that loads al with the first/next byte of the string. So, if the dirlist buffer is filled by os_get_file_list the condition will check the buffer's first byte. The function's return al value is discarded.
function (I presume, since there is only a code snippet) fills memory in dirlist, so if dirlist[0] = 0 you'll get new line printed, that is all.
-
I didn't think about using svn while adding functionality...
I will check code from the OS (MikeOS) that inspired me to create my own with nasm.
And the thing about interrupts is useful information.
Also, does someone have a link(s) to a tutorial or something that has this informations, and about the colors in binary and hex, bg and fg? When I search stuff like this up, the closest information like this I can find without very extensive searching (and tweaking) is for assembly running on an OS, as opposed to system development.
Thanks
-
I found (1) error in the ls function:
I forgot to move dirlist into ax
mov cx, 0
mov ax, dirlist
call os_get_file_list
Hopefully that's it
-
yup.