Mail Archives: djgpp/1998/05/11/23:34:55
At 08:47 5/11/1998 GMT, Dark Angel wrote:
>
>I have learned the basics of inline asm, and now i think it's time to move
>on.
>
>I want to write asm (only asm, not C) functions, compile them to generate
>an .o file and then use it with djgpp.
>
>In turbo C, i used to create the obj file with tasm, and then included it
>in my project file list.
>
>Does DJGPP works the same way? Should i compile the .s file, and then
>include the .o file in the project list? Is this the way it works?
I don't know the details of how RHIDE does it, but that's basically the way
it works. If you use a .S (capital S) file name, you can even get it passed
through the C preprocessor for some macro facilities.
You can also use NASM, which has a syntax closer to that of TASM.
Alternatively, there is JAS, which is closer yet.
>This is only part of the problem. I am already thinking about including asm
>files on my applications, and i don't even know how to write a complete asm
>program.
>
>I am not an experienced asm programmer, so there are a lot of things that i
>don't understand(not the instructions part) like the headers, passing
>parameters from C to the routine writen in asm, that kind of stuff i don't
>know.
You can figure out a lot of this by looking at code compiled with -S. I'll
try to sum up some of that in a nutshell:
* Parameters are pushed right-to-left, followed by the CALL instruction.
Each normally occupies 4 bytes, except in cases like floating point and
structure passing.
* You must save the ds, es, ss, ebx, esi, edi, and ebp registers. Do not
remove your args from the stack upon return.
* The return value goes in eax.
>With tasm, i wrote a lot of functions that i used on my programs, but they
>were kind of copied from other's.
>The main file looked like this:
[snipped]
>Well i don't have idea of what that means, but i copied that and it worked,
>i only changed the filenames to include, with my own functions.
>
>Does asm with DJGPP look like this?
Hardly. It is quite different.
>Is there documentation that i can get that can explain me what that stuff
>means (_DATA, _TEXT, assume, bla, bla)?
None of that applies to GNU AS / protected mode, but the `as' manual
(available through Info, or RHIDE's online help) will tell you all about the
assembler. It assumes some familiarity with assembly programming, however.
>As for the functions i wrote them like this (they were also copied and
>changed to suite my needs, so there are things i don't understand):
>
> PutImage struc
> dw ? //what for?
> dd ? //what for?
> posx dw ? //this i know
> posy dw ?
> addr dd ?
>
> PutImage ends
>
>Whell that is the parameter part, that i can figure out
>
>_PutImage proc far
>
> push bp //there are always some push's at the begining. What for?
> mov bp, sp
>
> instructions
>
>_PutImage endp
>
>
>I used this and it worked, but now i'm facing an all new asm: AT&T asm!!
>This doesn't work!
>
>Any help on this will be welcomed.
>Sorry to bother again
>
>P.S. The asm was in fact copied, but it was copied from a book by Peder
>Jungck.
>He said that the source code could be used by others. There is no piracy
>in here.
>
>
>Thanks, Jorge Lima from Dark Angel Soft, Portugal
>
Nate Eldredge
nate AT cartsys DOT com
- Raw text -