Mail Archives: djgpp/2000/03/24/17:53:10
Alexei A. Frounze wrote:
>Yes, I tried. I have *really* working program.
I believe you.
You might have been lucky, your example is wrong. Adding the following
lines at the top of your example to make it compilable.
/* just guesses */
extern unsigned short VGA_sel;
extern char *VGAAddr; /* unsigned char would be preferable */
extern long scanline_width;
#define y2addr(y) ((y)*scanline_width)
and compile it with gcc -O -S, I get the following output:
[Comments are mine again]
.file "a.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
.p2align 2
.globl _putpixel
_putpixel:
pushl %ebp
movl %esp,%ebp
pushl %ebx
; there should be a push %edi here
movl 8(%ebp),%ebx ;ebx=x
movl 12(%ebp),%edx ;edx=y
movl 16(%ebp),%ecx ;cl=color
movb %cl,%al ;al=color
cmpl $0,_VGAAddr
je L3
imull _scanline_width,%edx
movl _VGAAddr,%eax
addl %ebx,%eax
movb %cl,(%edx,%eax)
jmp L4
.p2align 4,,7
L3:
/APP
pushw %es
movw _VGA_sel, %ax ;overwrite al!
movw %ax, %es
movl %edx, %edi
shl $6, %edi
movl %edi, %eax
shl $2, %eax
addl %eax, %edi
addl %ebx, %edi
movb %al, %al ;Huh, gcc thinks al is still color
stosb
popw %es
/NO_APP
L4:
;There should be a popl %edi here
popl %ebx
movl %ebp,%esp
popl %ebp
ret
I suggest to read (or reread) in the gcc manual about inline assembly.
-- Regards, Dieter
- Raw text -