delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/17/15:54:57

From: "=?ISO-8859-1?Q?F=E1bio_Diales_da_Rocha?=" <crismafabio AT mail DOT telepac DOT pt>
To: "Djgpp Mailing List" <djgpp AT delorie DOT com>
Subject: External asm functions
Date: Fri, 17 Oct 1997 20:44:02 +0100
MIME-Version: 1.0
Message-ID: <19971017205129.AAA25529@host>

	I've downloaded DJGPP a month ago. After several frustating attempts i'v
decided to stick to Intel sintax using NASM to compile external asm
functions to COFF format. 
	The only problem is that I've never used external asm functions, so I beg
you for help.
	This is a sample function that comes with NASM in cofftest.asm:

GLOBAL _lrotate	

_lrotate:		
	  push ebp
	  mov ebp,esp
	  mov eax,[ebp+8]
	  mov ecx,[ebp+12]
.label	  rol eax,1		
	  loop .label		
	  mov esp,ebp
	  pop ebp
	  ret

	These are the declarations in the sample cofftest.c:

extern int lrotate(long, int);
	
	These are my questions *g*

Do I need to declare _lrotate as global in order to have access to it in my
C code?
If I got it right we need to jump ebp by 8 due to:
	The size of ebp itself (4)
	The size of the pushed previous ebp (4)
Is this right or did i confuse something?
Since the second value is only a int why is it moved to ecx and not cx?
Won't this store junk at the high order bytes of ecx?
Why are esp and ebp swaped? Are the parameters stored based to esp and not
ebp?
Where is the value returned? Eax?
How do i link the 2 files (cofftest.asm and cofftest.c)? Is this done by a
special parameter to gcc (if so, any way of doing this straight from
RHIDE?) or do the files have to have the same name?

	Tks in advance,
						Asmarin Farious

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019