Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
TASM/TASM32 Question Posted by xkgdiam on 23 Nov 2003 at 1:04 PM
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




Report
Re: TASM/TASM32 Question Posted by AsmGuru62 on 23 Nov 2003 at 2:45 PM
:
: 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
: 

:
:
:
:
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:
void foo ()
{
  // COPY/PASTE here your code from ASM function
  // and then try to compile it and resolve all issues...
}


Report
Re: TASM/TASM32 Question Posted by xkgdiam on 23 Nov 2003 at 7:40 PM
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 ?



Report
Re: TASM/TASM32 Question Posted by AsmGuru62 on 24 Nov 2003 at 7:19 AM
:
: 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 ?
: 
: 

:
:
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:

66BA3409  MOV DX, 0934h
ED        IN  EAX, DX

The very same will be achieved by this:
__emit__ (0x66, 0xBA, 0x34, 0x09, 0xED);
I just hope that BCC32 has this __emit__() command.

Report
Re: Disassembler error Posted by xkgdiam on 24 Nov 2003 at 5:42 PM
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


Report
Re: Disassembler error Posted by AsmGuru62 on 25 Nov 2003 at 7:48 AM
:
: 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
: 
: 

:
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:
PUSH EAX
PUSH AX

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.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.