www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/02/17:45:13

From: "lewi9908" <lewi9908 AT ghc DOT ctc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: AT&T inline asm in DJGPP...
Date: Mon, 2 Dec 2002 14:33:23 -0800
Organization: Posted via Supernews, http://www.supernews.com
Message-ID: <uunnttaavscea0@corp.supernews.com>
References: <200212020026 DOT gB20QDV26749 AT speedy DOT ludd DOT luth DOT se> <uulf7s7lb5c55b AT corp DOT supernews DOT com> <asf91n$kv1$1 AT antares DOT lu DOT erisoft DOT se>
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: 94
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Looking back at the example I noticed I didn't have SECTION .text. Now the
page I gave the link to eariler said nothing about this it does say varibles
written in asm to be used by C need to be in the .data section so I added
the line and tried it out and it linked correctly.

However, the text doesn't print even with

extern "C" void OutputText(char* pOutStr, int iVideoMemIndex);

int main()
{
    OutputText("Hello, world!", 22);

    //Continue on by overriding text written by OutputText()
    char* screen = (char*)0xb8000 + 22;
    const char* msg = "Hello, world!";

    while (*msg)
    {
       *screen++ = *msg++;
       *screen++ = 0x4f;
    }

    //for(;;);
    return 0;
}

So for now I have the asm code below(it shows the section location, retn
after _outputText label, and current text printing asm that appear to have a
run-time bug)

[BITS 32]

GLOBAL _OutputText

SECTION .text

_OutputText:
 retn        ;Added to skip asm so text will appear again...

 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:
 mov byte al, [edx] ;Check for null char
 test al,al
 jz short PrintDone

 mov byte al, [edx]
 mov byte [ebx], al
 add byte [ebx], 0x1
 add byte [edx], 0x1
 mov byte [ebx], 0x4f ;Add new colors later
 add byte [ebx], 0x1

 jmp short StartLoop

PrintDone:
 mov esp,ebp
 pop ebp
 retn

I am a little busy now but I will work with the loop a little tonight see if
I take out the loop and execute the loop once so I can test at least one
char goes thur loop...

Note: the loop is suppose to be like

while (*msg)
    {
       *screen++ = *msg++;
       *screen++ = 0x4f;
    }

but in asm. Also screen pointer is ebx and msg pointer is edx...

So it look like we are almost home with this...

Any more help...


- Raw text -


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