Mail Archives: djgpp/2002/01/29/14:13:14
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 -