flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > How to get list of disks and files?

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 368
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 24 Aug 2022, 17:40
How to get list of disks and files on x64 MenuetOS?

Assembly code is welcome.

_________________
smaller is better
Post 24 Aug 2022, 17:40
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 273
Ville 25 Aug 2022, 13:47
The following example displays first ten entries in selected directory:

Code:

display_file_entries:

    mov   r15 , 0   ; file to return
    mov   [dispy],dword 60

  newfile:

    mov   [dispx],dword 20
    add   [dispy],dword 12

    mov   rdi , datareturn
    mov   rcx , datareturnend-datareturn
    mov   rax , 0
    cld
    rep   stosb

    ; Read entry
    mov   rax , 58   ; file system
    mov   rbx , 3    ; read directory entry
    mov   rcx , r15  ; file num to return
    mov   rdx , 1    ; filecount (fixed)
    mov   r8  , datareturn
    mov   r9  , path1
    int   0x60      

    cmp   rax , 0 ; past last entry ?
    jne   filedone

    ; File name
    mov   rax , 4                            
    mov   rbx , filename                 
    mov   rcx , [dispx]                   
    mov   rdx , [dispy]                   
    mov   rsi , 0x000000                
    mov   r9  , 1                            
    int   0x60
    add   [dispx],dword 20*6

    ; Filesize
    mov   rbx , 8 shl 16 
    mov   rcx , [filesize]
    call  displaynum

    ; Filetime
    mov   rbx , 2 shl 16
    mov   rcx , [filetime]
    shr   rcx , 16
    and   rcx , 0xff
    call  displaynum
    mov   rbx , 2 shl 16
    mov   rcx , [filetime]
    shr   rcx , 8
    and   rcx , 0xff
    call  displaynum
    mov   rbx , 2 shl 16
    mov   rcx , [filetime]
    and   rcx , 0xff
    call  displaynum

    ; Filedate
    mov   rbx , 2 shl 16
    mov   rcx , [filedate]
    and   rcx , 0xff
    call  displaynum
    mov   rbx , 2 shl 16
    mov   rcx , [filedate]
    shr   rcx , 8
    and   rcx , 0xff
    call  displaynum
    mov   rbx , 4 shl 16
    mov   rcx , [filedate]
    shr   rcx , 16
    and   rcx , 0xffff
    call  displaynum

    add   r15 , 1
    cmp   r15 , 10
    jb    newfile

  filedone:   

    ret

displaynum:

    mov   rax , 47
    mov   rdx , [dispx]
    shl   rdx , 32
    add   rdx , [dispy]
    mov   rsi , 0
    int   0x60

    shr   rbx , 16
    imul  rbx , 6
    add   rbx , 6
    add   [dispx],rbx

    ret

dispx: dq 0x0
dispy: dq 0x0

path1: db  '/fd/1',0
path2: db  '',0
path3: db  '/fd/1/driver',0
path4: db  '/usb/1',0
path5: db  '/cd/1/source',0

datareturn:

     reserved: rb 8
     filename: rb 256
     filesize: rb 8
     filedate: rb 8
     filetime: rb 8
     fileattr: rb 8

datareturnend:


    
Post 25 Aug 2022, 13:47
View user's profile Send private message Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 368
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 26 Aug 2022, 19:06
Thanks.

_________________
smaller is better
Post 26 Aug 2022, 19:06
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.