title: Listing directory content in assembly?
body: <p>I want to print the current working directory and its content. The program will be done in x86, 16bit Intel syntax, DOS Assembly using interrupts. The assembler I will use will be Turbo assembler. Here is my code so far(not much): </p>
  
  <pre><code>ASSUME  cs:code,    ds:data
  data segment
  buffer  db  64  dup  (0) ; buffer for the current directory name
  data ends
  code segment
  start:
  mov     ax,     data ;
  mov     ds,     ax   ; move data segment into ds, es registers
  mov     es,     ax   ;
  
  mov     dl,     0             ; default drive 
  mov     si,     offset buffer ; put current directory in buffer
  mov     ah,     47h  ; GET CURRENT DIRECTORY
  int     21h                  
  
  ; appending '$' to buffer end
      ; search until 0 found
  mov     cx,     64  ; search over all buffer 
  cld                                 ; starting from the beginning  
      end_string:                         
  lodsb                               ; get current byte in al register
  cmp     al,     0   ; compare it with 0
  jne     continue                    ; if not equal jump to continue label
  mov     al,     36  ; if equal copy 36('$' - ASCII) in al
  mov     di,     si  ; set destination index to source index
  sub     di,     1           ; decrement di 
  stosb                               ; store in es:di the value contained in al
  mov     cx,     1   ; stop looping by setting cx to 1
      continue: 
      loop end_string
      ; print string obtained 
  mov     dx,     offset buffer  ; ds:dx - string start
  mov     ah,     09h            ; WRITE STRING TO STANDARD OUTPUT
  int     21h
  
  mov     ax,     4c00h          ; end program with exit code 0
  int     21h
      code ends
      end start   
  </code></pre>
  
  <p>I managed to get it running and display the current working directory. But now I don't know how to get his child directories and the files contained in the directory. So my question is : how do I get them? </p>