The MASM Forum Archive 2004 to 2012

Project Support Forums => The GeneSys Development System => Topic started by: Vortex on July 16, 2006, 09:38:01 PM

Title: Mixed C and Assembly Examples
Post by: Vortex on July 16, 2006, 09:38:01 PM
Hi friends,

Should we put some simple examples mixing asm with C ? What are your opinions?
Title: Re: Examples
Post by: PBrennick on July 16, 2006, 09:49:49 PM
Vortex,
This is a good idea as some of our users will be migrating from that discipline.  I would encourage you to work on this because I have not programmed in C in a lot of years (never in win32).

Paul
Title: Re: Examples
Post by: Vortex on July 17, 2006, 08:08:29 AM
Hi Paul,

OK, I will work on examples mixing asm and C

As you said, this should encourage users coming with a background of the C language.
Title: Re: Examples
Post by: James Ladd on July 17, 2006, 09:50:32 PM
I would like to see some 'C' code that dynamically loads and uses a routine from a DLL writting in ASM.
I'd also like to see the reverse.

This shows two things most people coming or going to assembler/C would want to know or do.

I'll leave the inline asm in C thing to you as I dont see a need - at least not right now.
Title: Re: Examples
Post by: Vortex on July 17, 2006, 10:11:06 PM
Hi James,

Thanks for your suggestion,  I will code an example matching your descriptions.
Title: Re: Mixed C and Assembly Examples
Post by: PBrennick on July 20, 2006, 02:23:09 PM
Vortex has written four mixed C & asm examples.  They are attached.

Paul


[attachment deleted by admin]
Title: Re: Mixed C and Assembly Examples
Post by: Vortex on July 20, 2006, 06:06:31 PM
QuoteI would like to see some 'C' code that dynamically loads and uses a routine from a DLL writting in ASM.

Hi James,

Here is the BmpfromDLL example rewritten in C. It loads dynamically a DLL and uses a routine.

[attachment deleted by admin]
Title: Re: Mixed C and Assembly Examples
Post by: James Ladd on July 20, 2006, 10:36:53 PM
Thanks guys, this is great.

One sugestion I have is to make the filenames more meaningful so if you have a lot of them
in a folder its easy to tell what they are about.

For example BmpFromDLL is great, but C-calling-Dll-in-Asm is even better, especially for the begginer.

Another suggestion id make is to have a document that describes each piece of the library and does a
summary of it. I know this isnt as much fun as writing code, but it makes the difference between a
used library and a geat library.

Rgs, James.
Title: Re: Mixed C and Assembly Examples
Post by: PBrennick on July 21, 2006, 01:10:05 AM
James,
Thank you for your comments.  These are all good ideas and I have begun that concept using the EXPORT names.  In my opinion that is more important than the source file name as the majority of users only want to know the name of functions so I am working hard on that one.  Filenames, I'll think about it and talk to Vortex.  Right now, neither one of us has a life because we have dedicated ourselves to this project.  The response has been overwelming.  For that reason, docs will come when the fire is not so high.

For example, the last 24 hours, I have done hardly nothing as I need a rest.  This just creates a backlog, though.

Thank you,
Paul
Title: Re: Mixed C and Assembly Examples
Post by: James Ladd on July 21, 2006, 02:05:24 AM
Paul,
Please take things easy. Good things take time and Im sure all will understand the need for a
work / life balance.
I have been promising stuff for a while and it's happening just not a quickly as I would like.
I suggest you also take your time and rest properly.
Title: Re: Mixed C and Assembly Examples
Post by: Vortex on July 21, 2006, 07:27:48 AM
Hi James,

Thanks for your suggestion about filenames. Did you check the readme files coming with the examples? They explain briefly the aim of each example.
Title: Re: Mixed C and Assembly Examples
Post by: Vortex on August 22, 2006, 07:04:01 PM
Here is a demo using msvcrt.dll :

.386
.model flat, stdcall
option casemap : none
     
include     \GeneSys\include\kernel32.inc
include     \GeneSys\include\msvcrt.inc

includelib  \GeneSys\lib\kernel32.lib
includelib  \GeneSys\lib\msvcrt.lib



.data
text1       db 'Please type your name : ',0
text2       db 'Hello %s , nice to meet you :) ',0
format1     db '%s',0

.data?
buffer      db 100 dup(?)

.code

start:

    invoke  printf,ADDR format1,ADDR text1
    invoke  scanf,ADDR format1,ADDR buffer
    invoke  _strupr,ADDR buffer
    invoke  printf,ADDR text2,ADDR buffer
    invoke  ExitProcess,0

END start

[attachment deleted by admin]