Results 1 to 7 of 7

Thread: Convert this to C/C++

  1. #1

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    Angry

    Can someone please convert this to inline assembler(For use with BorlandC or C code? It's needed quite urgently.

    Code:
    public _setbxdx 
    .MODEL SMALL ;whatever 
    .CODE 
    
    set_struc struc 
        dw ? ;old bp  
        dd ? ;return addr (always far call) 
        p_bx dw ? ;reg bx value 
        p_dx dw ? ;reg dx value 
    set_struc ends 
    
    ;HELP CONVERT THIS FUNCTION TO C/C++!!!
    _setbxdx proc far ; must be FAR 
        push bp 
        mov bp,sp 
        mov bx,[bp]+p_bx 
        mov dx,[bp]+p_dx 
        pop bp 
        ret 
    _setbxdx endp 
    END
    in C, the function prototype is "far setbxdx(int, int);"

    I can get most of of the conversion, but I want it to work with the "REGS" structure. I've already posted this in the ASM forum, but it's in more depth here.

    I need this urgently!
    Last edited by Warmaster199; Mar 21st, 2001 at 04:09 PM.
    Designer/Programmer of the Comtech Operating System(CTOS)

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    www.softseek.com

    Look in their programming section and it may have one.

  3. #3

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    Sorry, I didn't find anything there
    Designer/Programmer of the Comtech Operating System(CTOS)

  4. #4

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    This is important! I need help soon!
    Designer/Programmer of the Comtech Operating System(CTOS)

  5. #5
    Guest
    I see you pushing bp.. what is in bp at the time of this?

    also, can I see what you have converted so far.. maybe i can help...

    Knight

  6. #6
    Guest

    Talking

    Here, try this...

    void setbxdx(int a_bx, int a_dx)
    {
    __asm
    {
    mov bx, a_bx
    mov dx, a_dx
    }
    }

    Knight Vision

  7. #7

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    It has to have a return of the FAR type. That's why it pushes/pops bp to return it(I think). I got this code from some code from www.VESA.org It's from their VBE3.0 Specifications. This is to help in switching the videocard's memory banks by a method called Direct-Banking.

    Cybrg641 has helped me and has converted it to this:
    Code:
    FAR setbxdx(int, int);
    //-----------------------------------------------------------------
    struct set_struc
    {
       WORD Oldbp;    // old bp
       DWORD rAddr;   // return addr
       WORD p_bx;     // reg bx value
       WORD p_dx;     // reg dx value
    };
    //-----------------------------------------------------------------
    FAR setbxdx(int p_bx, int p_dx)
    {   
        asm {
          push bp
          mov bp, sp
          mov bx, [bp] + p_bx
          mov dx, [bp] + p_dx
          pop bp
         }
       return 0;
    }
    It looks good to me... What do you guys say?
    Designer/Programmer of the Comtech Operating System(CTOS)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width