Windows 16bit C Calling 32Bit ASM 
Author Message
 Windows 16bit C Calling 32Bit ASM

   I am a C programmer but am very interested in assembly for speed and
the ability to use a flat memory model for holding images over 16MB and
without doing huge pointer math. From C using 16:16 Selector/Offset
scheme how do I call am assembly routine using 16:32 to modify my image.
Please help!!!!!!!
   Mike Resar



Mon, 03 Nov 1997 03:00:00 GMT  
 Windows 16bit C Calling 32Bit ASM


Quote:
>   I am a C programmer but am very interested in assembly for speed and
>the ability to use a flat memory model for holding images over 16MB and
>without doing huge pointer math. From C using 16:16 Selector/Offset
>scheme how do I call am assembly routine using 16:32 to modify my image.
>Please help!!!!!!!

As I understand, all you have to do is to allow 80386 instructions and use
specification 'USE16' for the code segment in assembly. Otherwise the
assembler tries to make it 32-bit and linker complains. After that use 32-bit
offsets to your data in your assembly program.

Hey All, correct me if I'm wrong.

Quote:
>   Mike Resar


Victor.




Tue, 04 Nov 1997 03:00:00 GMT  
 Windows 16bit C Calling 32Bit ASM
Quote:



>>   I am a C programmer but am very interested in assembly for speed and
>>the ability to use a flat memory model for holding images over 16MB and
>>without doing huge pointer math. From C using 16:16 Selector/Offset
>>scheme how do I call am assembly routine using 16:32 to modify my image.
>>Please help!!!!!!!

>As I understand, all you have to do is to allow 80386 instructions and use
>specification 'USE16' for the code segment in assembly. Otherwise the
>assembler tries to make it 32-bit and linker complains. After that use 32-bit
>offsets to your data in your assembly program.

>Hey All, correct me if I'm wrong.

That's correct. However, there is another way to do it: generate a 32 bit-assembly segment
 with the USE32 directive. This segment must contain only 32 bit segments, you can't group it
with other segments. The 16bit linker will not complain, but the segments isn't loaded by Windows
as 32bit. So, at load time you must use DPMI-functions to adjust the segment-attributes to 32bit.

Now you can call the assembler function(s) from C, but you must be sure that the asm-function
does a 16bit return! Also special care must be taken if you use extended directives of TASM, such as
the C language support: it is not easy to let TASM generate correct code for 16bit-callers (but it is
possible. I used macros for ENTER/LEAVE, adjusting stack-ptrs).

Success
  n u



Thu, 06 Nov 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem O2/2 warp 32bit cobol calling 16bit c

2. windows 16bit api call

3. Windows 16bit C Calling

4. Problem: Changing from 16bit to 32bit

5. Going from 16bit to 32bit

6. 16bit to 32bit conversion

7. 32bit runtime errors - 16bit runs fim

8. 32bit vs 16bit

9. Detecting 16bit or 32bit OS

10. Help: 16bit or 32bit-dll

11. Clarion - 32bit application slower than 16bit

 

 
Powered by phpBB® Forum Software