Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Calling an Int from C

LucDalLucDal Member Posts: 2
Hi i dont know how to do to pass an address in real mode to an interruption in C. For example the int13 subfunction 0x48 ask for the address of the buffer in DS:SI registers. Well what i do is to create an structure and pass the address of it, but it doesnt work.
To be more especific what i wanna do is to call a bios int to get disk parameters and the int subfuction ask me an address where i wanna recive the disk info, something like this:

/* Begin Code */

struct DiskInfo {

int Var1;
int var2; //Etc...

}

void main (void)

{

asm {

mov ah, 0x48 //Int13 subfunction number
mov dl, 0x80 //Drive number (c:)
mov si, &DiskInfo //Buffer ---> This is the problematic part *
}

}

/* End Code */

* Here i store the Structure base address to si register, but it doesnt return me the values!!
can someone help me???

Thanks

Comments

  • blitzblitz Member Posts: 620
    : Hi i dont know how to do to pass an address in real mode to an interruption in C. For example the int13 subfunction 0x48 ask for the address of the buffer in DS:SI registers. Well what i do is to create an structure and pass the address of it, but it doesnt work.
    : To be more especific what i wanna do is to call a bios int to get disk parameters and the int subfuction ask me an address where i wanna recive the disk info, something like this:
    :
    : /* Begin Code */
    :
    : struct DiskInfo {
    :
    : int Var1;
    : int var2; //Etc...
    :
    : }
    :
    : void main (void)
    :
    : {
    :
    : asm {
    :
    : mov ah, 0x48 //Int13 subfunction number
    : mov dl, 0x80 //Drive number (c:)
    : mov si, &DiskInfo //Buffer ---> This is the problematic part *
    : }
    :
    : }
    :
    : /* End Code */
    :
    : * Here i store the Structure base address to si register, but it doesnt return me the values!!
    : can someone help me???
    :
    : Thanks
    :

    First you need a variable of type DiskInfo: :-)
    [code]
    DiskInfo disk_info;
    [/code]
    then use the LEA instruction or the OFFSET operator, something like this:
    [code]
    mov si, OFFSET disk_info
    lea si, disk_info
    [/code]
  • Justin BibJustin Bib USAMember Posts: 0

    { http://forcoder.org } free video tutorials and ebooks about || Assembly R Objective-C C C# Swift JavaScript Ruby Go Visual Basic PL/SQL Python MATLAB C++ Scratch Visual Basic .NET Java Perl PHP Delphi Clojure Crystal Apex LabVIEW D Scala SAS Kotlin Hack Ada Alice Erlang Logo VBScript Dart Bash ABAP COBOL FoxPro Lua Rust F# Julia Transact-SQL Lisp Awk ML Scheme Fortran Prolog || __________

Sign In or Register to comment.