Oh Sir Colin of Burgess, who is so wise in the ways of GNUisms…
I come to you with an assembly function that I want to include in
a C source file, but I know not how to do so. Could you take a swack
at converting this bad boy for me, and perhaps explaining a little bit
about what some of that cryptic “a=” stuff is all about? (I did try to
do a little research, but have scarce little to go on).
Basically, I want to scan a 64K block of memory, and return 0 if it’s all
0xFF, and anything but zero if any byte of it is not 0xFF. SCAS is the
ideal instruction, and a psuedocode(?) thingie would be:
int is_ff( void *p )
movw %ds, %ax
movw %ax, %es # Is this even necessary?
movl $0xFFFFFFFF, %eax # Pattern to check for
movl $p, %edi # Get starting address
movl $16384, %ecx # Number of dwords to scan
repe; scasl # Scan for pattern mismatch
jz all_ff # Branch if everything is 0xFF
xor %eax, %eax # Return FALSE (else will be 0xFFFFFFFF)
Thank you in advance, and probably once again when I get it working.
-Warren “can’t touch this (or it’ll blow up)” Peece