News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Mixed C and Assembly Examples

Started by Vortex, July 16, 2006, 09:38:01 PM

Previous topic - Next topic

Vortex

Hi friends,

Should we put some simple examples mixing asm with C ? What are your opinions?

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website

Vortex

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.

James Ladd

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.

Vortex

Hi James,

Thanks for your suggestion,  I will code an example matching your descriptions.

PBrennick

Vortex has written four mixed C & asm examples.  They are attached.

Paul


[attachment deleted by admin]
The GeneSys Project is available from:
The Repository or My crappy website

Vortex

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]

James Ladd

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.

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website

James Ladd

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.

Vortex

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.

Vortex

#11
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]