delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/01/29/14:13:14

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-Id: <5.0.2.1.2.20020129194221.009e8990@pop.gmx.net>
X-Sender: martinSteuer AT gmx DOT de@pop.gmx.net
X-Mailer: QUALCOMM Windows Eudora Version 5.0.2
Date: Tue, 29 Jan 2002 20:11:29 +0100
To: djgpp AT delorie DOT com
From: Martin Steuer <martinSteuer AT gmx DOT de>
Subject: Re: Inline assembly.
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

Joel Saunders <jbs30000 AT aol DOT com> wrote:

 >I changed the inline assembly to this:
 >__asm__("movl _My_Name, %esi
 >movl _Screen_PTR, %edi
 >movl $7, %ecx
 >movsb
 >");

You forgot to think on the attribute byte in textmemory, every second byte 
in the textmode 3h is an attribute byte. And a second problem i can see is 
that movsb will only be executed once, because you didn't prefix it with a 
rep. So i'd do it like this:

__asm__("movl _My_Name, %esi\n
	movl _Screen_PTR, %edi\n
	movl $7, %ecx \n
	movb $7, %ah\n
	writeStr:\n
	orl %ecx,%ecx\n
	jz ready\n
	decl %ecx\n
	movb (%esi),%al\n
	movw %ax,(%edi)\n
	incl %esi \n
	add $2,%edi\n
	jmp writeStr\n
	ready:\n"
	:
	:
	: "ax", "cx", "si", "di"
);

This example uses an "unrolled" form of movs-type instructions but it is 
somewhat different because it just loads 1 byte and stores 2 bytes. And it 
preserves registers using AT&T's extended syntax.
The 'movb $7, %ah' sets the attribute byte of the text memory to the 
standard colors (forground grey, background black).

Hope it helps,
Martin

- Raw text -


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