Page 1 of 1

How Do I List Files And Folders In Assembly In My Bootloader

Posted: Fri Feb 14, 2014 11:47 pm
by proxima
hi.
i followed this instruction to build my bootloader:
http://www.codeproject.com/Articles/280 ... pplication

but the thing i want to do is that in the bootloader i want to list(show) the files and the folders in my C drive(or any other drive)(without any menu or user input just show)

i searched a lot and found that one of the bios intrrupts(0x13) can help me do this but because i'm not really familiar with the assembly language i'm stuck now.

is anyone know how to do this so he can help about it?

thanks
this is my code so far(notice that it only shows a little message on the screen not what i want,i want to change it):

Code: Select all

[BITS 16]
[ORG 0x0000]
 
; code located at 0000:7C00, adjust segment registers
          cli
          mov     ax, 0x07C0
          mov     ds, ax
          mov     es, ax
          mov     fs, ax
          mov     gs, ax
 
; create stack
          mov     ax, 0x0000
          mov     ss, ax
          mov     sp, 0xFFFF
          sti
 
; post message
          mov     si,msgHello
          call    DisplayMessage
          mov     si, msgEnd
          call    DisplayMessage
          hlt
 

; Display Message
DisplayMessage:
          lodsb                                       ; load next character
          or      al, al                              ; test for NUL character
          jz      .DONE
          mov     ah, 0x0E                            ; BIOS teletype
          mov     bh, 0x00                            ; display page 0
          mov     bl, 0x07                            ; text attribute
          int     0x10                                ; invoke BIOS
          jmp     DisplayMessage
     .DONE:
          ret
 
; data section
msgHello  db 0x0D, 0x0A, "Hello World", 0x0D, 0x0A, 0x00
msgEnd  db 0x0D, 0x0A, "That's all folks!!!", 0x0D, 0x0A, 0x00
 
;ASM Signature
          TIMES 510-($-$$) DB 0
          DW 0xAA55

Re: How Do I List Files And Folders In Assembly In My Bootlo

Posted: Sat Feb 15, 2014 1:25 am
by Bender
Read the Microsoft FAT Document if you want to use the FAT file system
Also, you didn't give us what file system you want to use.
Linuxes use EXT(N) File System, DOS-like Systems use FAT,
Windows NT Uses NTFS.
The INT 0x13 interrupt can only help you to load/write sectors off a floppy/HDD. It's you to parse the information, and then display it.
The INT 0x13 knows nothing about what's a file or a directory. It's again you who will define what a file is.
As for any source code request it's a bad place to ask. That too for something trivial like this.
And:
If you're NOT familiar with assembly, leave OSDev, Assembly is a requirement for OSDev, Brush up your assembly skills by creating user space programs in assembly, or maybe some simple DOS Games etc. And then come back to OSDev.

Re: How Do I List Files And Folders In Assembly In My Bootlo

Posted: Sat Feb 15, 2014 2:29 am
by VolTeK
proxima wrote:i searched a lot and found that one of the bios intrrupts(0x13) can help me do this but because i'm not really familiar with the assembly language i'm stuck now.
Well there you go, you just solved your own problem.

-That isn't yours.
-You didn't write anything "so far".
-Come back when you meet the prerequisites of the forum.

Re: How Do I List Files And Folders In Assembly In My Bootlo

Posted: Sat Feb 15, 2014 4:12 am
by mathematician
The same as you would in an application. You need to write a recursive function which lists the files in each of the directories in turn. The difference is that you haven't got a nice C or C++ function to return the file names to you. Therefore you will have to read them directly from the disk sectors where they are stored, and to find those sectors you will need to parse the file system.

If you are not already familiar with the file system you are using, you will have to get hold of some technical documentation, which describes, in detail, exactly how it stores information on disk (and good luck if the file system is NTFS).

Re: How Do I List Files And Folders In Assembly In My Bootlo

Posted: Sat Feb 15, 2014 6:23 am
by Antti
proxima wrote:i followed this instruction to build my bootloader
The instructions you followed are not good. It makes me sad that instructions/tutorials like this are published. There are few flaws that even so called advanced hobbyists seem to introduce time after time.

Re: How Do I List Files And Folders In Assembly In My Bootlo

Posted: Sat Feb 15, 2014 7:10 am
by Bender
The instructions you followed are not good. It makes me sad that instructions/tutorials like this are published. There are few flaws that even so called advanced hobbyists seem to introduce time after time.
I agree. The standard of most coders (except a few who I know) on sites like Code project are way lower than required for system programming.
@OP: Reading such tutorials will confuse you.
Although most will recommend the Intel Manual for assembly,
I feel it's a little bloated. :wink:
IMO Intel Manuals are the ultimate resource for an experienced x86 coder however it's too complicated for beginners as it covers the A-Z of the processor, and there are concepts which you wouldn't need when you're in your first steps.
I feel the FASM Manual should give a nice start. I learnt most of the assembly from there.

Re: How Do I List Files And Folders In Assembly In My Bootlo

Posted: Sun Feb 16, 2014 5:42 am
by Love4Boobies
Criticisms aside, the machine has no concept of files or directories, processes or threads, user interfaces, sockets, etc. This is precisely what an OS does so you need to program these abstractions yourself.