delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/11/30/21:30:03

From: "lewi9908" <lewi9908 AT ghc DOT ctc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: AT&T inline asm in DJGPP...
Date: Sat, 30 Nov 2002 18:29:04 -0800
Organization: Posted via Supernews, http://www.supernews.com
Message-ID: <uuit0ko46e2k55@corp.supernews.com>
References: <uuhr3lgi6qsc7f AT corp DOT supernews DOT com>
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
X-Complaints-To: abuse AT supernews DOT com
Lines: 82
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I am am working on the mix ASM/C model and here is my current try...

Ker.asm
[BITS 32]

 global _OutputText

_OutputText:
 push ebp                                      ;Setup stack for function
 mov ebp,esp

 ;char* HoldCurrentIndexCharPointer;
 ;char* SrcIndex;
 sub esp, byte +0x8                         ;Add a local varibles to stack

 mov edx, [ebp+0x8]                   ;The 1st passed function param is a
pointer to text
 mov [ebp-0x4], edx                       ;so set
HoldCurrentIndexCharPointer to the same address

 mov ebx, [ebp+0x12]                  ;The 2nd passed function param is an
index where to put the char in viedo memory
 mov eax, 0xb8000                         ;so set SrcIndex to 0xb8000 plus
the index
 add eax, ebx
 mov [ebp-0x8], eax

StartLoop:
 and byte ptr [edx], 0x0                  ;Check for Null char
 jz short PrintDone
 mov byte ptr [ebx], byte ptr [edx]
 add byte ptr [ebx], 0x1
 add byte ptr [edx], 0x1
 mov byte ptr [ebx], 0x4f                ;Add new colors later
 add byte ptr [ebx], 0x1

 jmp short StartLoop

PrintDone:
 mov esp,ebp
 pop ebp
 retn

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...
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
 add byte ptr [edx], 0x1
 mov byte ptr [ebx], 0x4f                ;Add new colors later
 add byte ptr [ebx], 0x1

 jmp short StartLoop

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...

Any help...


- Raw text -


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