Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

TASM/TASM32 Question

[code]
Is a question about compiling with TASM/TASM32
AsmGuru62 or any other tasm(an),
please take a look here :

http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=1&MsgID=226380&Setting=A9996F1301
[/code]



Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : [code]
    : Is a question about compiling with TASM/TASM32
    : AsmGuru62 or any other tasm(an),
    : please take a look here :
    :
    : http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=1&MsgID=226380&Setting=A9996F1301
    : [/code]
    :
    :
    :
    :
    [blue]I see... unfortunately, the question of linking ASM code and C++ code never comes up in my coding, because I consider this practice futile. Most of speeding up the code in C++ can be done using inline ASM inside C++ compiler.

    Having said that, I can see that one does not want to lose the ASM code which is developed already. In such case try to just make a wrapper for the code you have, like:
    [code]
    void foo ()
    {
    // COPY/PASTE here your code from ASM function
    // and then try to compile it and resolve all issues...
    }
    [/code]
    [/blue]
  • xkgdiamxkgdiam Posts: 111Member
    [code]
    i try that you said, take a look here :

    #include "stdio.h"

    int main(int argc,char *argv[]){
    asm{
    mov dx,934h
    in eax,dx
    }
    }

    the disassembler says :
    +++++++++++++++++++ ASSEMBLY CODE LISTING ++++++++++++++++++
    //********************** Start of Code in Object .text **************
    Program Entry Point = 0040100C (ASMTEST.EXE File Offset:0000960C)
    :00401000 55 push ebp
    :00401001 8BEC mov ebp, esp
    :00401003 66BA3409 mov dx, 0934
    :00401007 ED in ax, dx
    :00401008 33C0 xor eax, eax
    :0040100A 5D pop ebp
    :0040100B C3 ret

    don't accept EAX , i'm using BCC32 version 5.5 tlink v5 or ilink32 v7
    and link as win32 console

    in your opinion is safe to create a dll for direct I/O using C++,
    or i must use ASM code instead ?
    and last is this correct ?

    in eax,dx =?= in ax,dx
    in ax,dx ; do i read i long in this way ?

    [/code]

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : [code]
    : i try that you said, take a look here :
    :
    : #include "stdio.h"
    :
    : int main(int argc,char *argv[]){
    : asm{
    : mov dx,934h
    : in eax,dx
    : }
    : }
    :
    : the disassembler says :
    : +++++++++++++++++++ ASSEMBLY CODE LISTING ++++++++++++++++++
    : //********************** Start of Code in Object .text **************
    : Program Entry Point = 0040100C (ASMTEST.EXE File Offset:0000960C)
    : :00401000 55 push ebp
    : :00401001 8BEC mov ebp, esp
    : :00401003 66BA3409 mov dx, 0934
    : :00401007 ED in ax, dx
    : :00401008 33C0 xor eax, eax
    : :0040100A 5D pop ebp
    : :0040100B C3 ret
    :
    : don't accept EAX , i'm using BCC32 version 5.5 tlink v5 or ilink32 v7
    : and link as win32 console
    :
    : in your opinion is safe to create a dll for direct I/O using C++,
    : or i must use ASM code instead ?
    : and last is this correct ?
    :
    : in eax,dx =?= in ax,dx
    : in ax,dx ; do i read i long in this way ?
    :
    : [/code]
    :
    :
    [blue]I see... You have weird (or rather wrong) code generation there... strange...

    There is a command allowing to inject the code bytes straight into C/C++ code WITHOUT compiler interpreting them in any way - sometimes I found it very useful. For example: your code translates into following bytes:
    [code][b]
    66BA3409 MOV DX, 0934h
    ED IN EAX, DX
    [/b][/code]
    The very same will be achieved by this:
    [code]__emit__ (0x66, 0xBA, 0x34, 0x09, 0xED);
    [/code]I just hope that BCC32 has this [b]__emit__()[/b] command.
    [/blue]
  • xkgdiamxkgdiam Posts: 111Member
    [code]
    i try that too,
    the problem is the disassembler's output
    i have W32Dasm v8.93

    :00407F09 ED in ax, dx
    :00407EBF 66ED in ax, dx

    different opcodes but same commands

    [/code]
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : [code]
    : i try that too,
    : the problem is the disassembler's output
    : i have W32Dasm v8.93
    :
    : :00407F09 ED in ax, dx
    : :00407EBF 66ED in ax, dx
    :
    : different opcodes but same commands
    :
    : [/code]
    :
    [blue]I do not consider it a mistake - Turbo Debugger gives the same opcodes. The CPU can be in Real Mode where all is 16 bits and in Protected mode where all is 32 bits. The opcode 0x66 provides a switch between operand sizes. Try that in 32-bit mode:
    [code]
    PUSH EAX
    PUSH AX
    [/code]
    And you will see that this 0x66 opcode also prefixes the 'real' opcode for "PUSH AX". I know, it is confusing, but that is how CPU can perform mixed code with registers both 16 bit and 32 bit in size. So, your instruction is correct.[/blue]
Sign In or Register to comment.