From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg) Newsgroups: comp.os.msdos.djgpp Subject: Re: AT&T inline asm in DJGPP... Date: 1 Dec 2002 13:36:38 GMT Organization: Ericsson Erisoft AB, Sweden Lines: 63 Message-ID: References: NNTP-Posting-Host: lws256.lu.erisoft.se X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com lewi9908 (lewi9908 AT ghc DOT ctc DOT edu) wrote: : I am am working on the mix ASM/C model and here is my current try... : Ker.asm : [BITS 32] : global _OutputText : _OutputText: ... : And here is the ker.cpp : extern void OutputText(char* pOutStr, int iVideoMemIndex); : int main() : { : OutputText("Hello, world!", 22); : return 0; : } : Now the problems... : 1) When linking I get an error - "...undefined reference to : '_OutputText(char* , int);". Now I am new to global/extern so I don't know : what is wrong... Name ker.cpp ker.c. Otherwise you'll have C++ name mangling. Or declare OutputText as "extern C". : 2) Next in the lines... : StartLoop: : and byte ptr [edx], 0x0 ;Check for Null char : jz PrintDone : mov byte ptr [ebx], byte ptr [edx] : add byte ptr [ebx], 0x1 ... : PrintDone: : every mov, and(the instruction), and(the conjuction) add line gives me an : error -"...comma or end of line expected" now I don't know what I did wrong : there either... I'm not sure which assembler you use. But what about "and byte [edx], 0x0" or "and [ byte edx ], 0x0"? Some other observations: Doesn't the code above zero [edx] and (if jump not taken) loads [ebx] with [edx] which is zero and then add one to it? (But I might have mixed up source and destination.) If so, then why not "mov byte [ebx], 0x1"? mov (memory reference), (memory reference) isn't allowed on IA32. Right, MartinS