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

Programming, for all ages and all languages.
Post Reply
proxima
Posts: 1
Joined: Fri Feb 14, 2014 9:31 pm

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

Post 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
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

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

Post 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.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

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

Post 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.
User avatar
mathematician
Member
Member
Posts: 437
Joined: Fri Dec 15, 2006 5:26 pm
Location: Church Stretton Uk

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

Post 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).
Last edited by mathematician on Sat Feb 15, 2014 8:04 am, edited 1 time in total.
The continuous image of a connected set is connected.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

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

Post 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.
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

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

Post 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.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

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

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply