home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Tu-Basic / GETDIR.ASM next >
Assembly Source File  |  1987-04-01  |  2KB  |  60 lines

  1.  
  2. ; This  routine expects two pointers to be passed on the stack.  The first
  3. ; points to  a Turbo Basic integer which indicates which drive to look at.
  4. ; The second is a pointer to a Turbo Basic string descriptor which in turn
  5. ; points to the string which will store the directory returned by DOS. The
  6. ; string must have been allocates 64 characters in length or this  routine
  7. ; will cause string memory to become corrupt.
  8. ;
  9. ;      STACK after saving BP
  10. ;   │ 32 bit(segment and offset) │
  11. ;   │ to TB integer representing │ <----- BP + 0Ah
  12. ;   │ which drive to look at     │
  13. ;   ├────────────────────────────┤
  14. ;   │ 32 bit(segment and offset) │
  15. ;   │ to TB string representing  │ <----- BP + 6
  16. ;   │ current path          │
  17. ;   ├────────────────────────────┤
  18. ;   │    return address that       │
  19. ;   │    TB will go to after       │ <----- BP + 2
  20. ;   │   completion of routine     │
  21. ;   ├────────────────────────────┤
  22. ;   │         saved BP              │ <----- BP
  23. ;   │                           │
  24. ;   └────────────────────────────┘
  25.  
  26.  
  27. DosCall  equ  21h    ; equates for assembler routine
  28. GetDir   equ  47h
  29.  
  30. program segment    ; begin program segment
  31.   assume cs:program
  32.  
  33.   push  bp      ; save bp
  34.   mov   bp, sp
  35.   push  es      ; save es because we'll use it for pointer manipulation
  36.   push  ds      ; ditto
  37.  
  38.   les   di, [bp + 6h]    ; load pointer to string descriptor into es:di
  39.   mov   dx, ds:[0]    ; get the beginning of the string segment from ds:[0]
  40.   push  dx
  41.   pop   ds        ; make ds point to string segment
  42.   mov   si, es:[di + 2]    ; get offset into string segment from es:[di + 2]
  43.  
  44.   les   di, [bp + 0Ah] ; load pointer to TB integer into es:di
  45.   mov   dx, es:[di]    ; load which drive to look at into dx
  46.  
  47.   ; now ds:si points to the appropriate location for the DOS Get Directory
  48.   ; call and dl contains the drive to look at
  49.   mov   ah, GetDir
  50.   int   DosCall
  51.  
  52.   pop   ds
  53.   pop   es      ; restore registers
  54.   pop   bp
  55.  
  56. program ends    ; end program segment
  57.  
  58. end
  59.  
  60.