The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: Glenn9999 on November 17, 2008, 02:46:57 AM

Title: Pascal/ASM interface question
Post by: Glenn9999 on November 17, 2008, 02:46:57 AM
This could be an ASM question, this could be a Pascal question, I don't know.  But anyhow, it seems I'm doing something wrong somewhere along the line in trying to interface with one of my ASM routines (mainly trying to convert and pass an ASCIIZ string - like I said in another thread, it's nutty).  Anyway, here is the code.


program volinfo; uses lfn;
  type
    LVolInfo = record
      FSName: array[1..32] of char;    { file system name }
      MaxFileName: Word;
      MaxFilePath: Word;
      FSFlags: Word;                   { file system flags }
    end;
  var
    VInfo: LVolInfo;
    i: integer;
    drivespec: string;
    dpchr: PChar;
    DOSError: Word;

  procedure LGetVolInfo(RootName: PChar; var volinfo: LVolInfo); Assembler;
   { LFN GetvolumeInformation
     Input: AX = 71A0h  DS:DX = ASCIIZ root Name ("C:\")
            ES:DI = ASCIIZ file system name   CX = size of ES:DI
    Output: BX = file system flags  CX = maximum size file name
            DX = maximum size file path  CF if error, AX = error code
            7100h if not supported

     FSFlags: 0 - case sensitive searches
              1 - preserves case in directory entries
              2 - uses Unicode characters
              14 - supports DOS LFN functions
              15 - volume is compressed
   }
   asm
     PUSH  DS
     MOV   AX, 71A0h
     LDS   DX, RootName             { set DS:DX to RootName }
     LES   DI, VolInfo              { set ES:DI to VolInfo  }
     INT   21h

     POP   DS
     MOV   ES:[DI].LVolInfo.FSFlags, BX
     MOV   ES:[DI].LVolInfo.MaxFileName, CX
     MOV   ES:[DI].LVolInfo.MaxFilePath, DX

     SBB   BX, BX
     AND   AX, BX
     MOV   [DosError], AX
   end;


  begin
    drivespec := 'C:\' + #0;
    dpchr := PChar(@drivespec[1]);
    LGetVolInfo(dpchr, VInfo);
    writeln;
    writeln('Drive Info');
    write('File System Name: ');

    i := 1;
    while VInfo.FSName[i] <> #0 do
      begin
        write(VInfo.FSName[i]);
        inc(i);
      end;
    writeln;

    writeln('Max File Name: ', VInfo.MaxFileName);
    writeln('Max File Path: ', VInfo.MaxFilePath);
  end.


It works perfectly fine if I were to change the procedure call to:


LGetVolInfo('C:\', VInfo);


But I'm stuck on figuring out how to pass a variable in that field to get what I need.  Any thoughts?
Title: Re: Pascal/ASM interface question
Post by: Glenn9999 on November 17, 2008, 04:03:54 AM
Nevermind, I figured it out.  :dazzled: :red