TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bill Birrell
from: Jasen Betts
date: 2004-04-18 08:38:16
subject: Squares

Hi Bill.

16-Apr-04 11:06:00, Bill Birrell wrote to Jasen Betts


  >> repz scasb  ;// most of the
 BB> ^^^^
  >> mov ax,cx

  >> works line strlen

 BB> Are you sure about this? The repe scasb instructions depend for
 BB> direction on the direction flag. It can be disastrous,
 BB> particularly in ISRs to take it for granted like this (pushf, CLD
 BB> or STD, ... popf is required to be certain).

oops!

 BB> Similarly the CX or ECX register must be non-zero for the instructions to
continue
 BB> till the discarded subtraction of ES:[(E)DI] from AX resets the
 BB> zero flag. It decrements CX or ECX so it counts down, not up (like
 BB> djnz).

double oops!   ("djnz" is Z80 "loop" is the 8086 equivalent.)

 BB> It may increment or decrement ES:EDI or ES:DI according to
 BB> the direction flag. This looks as if you are looking for the first
 BB> byte not to match AX, rather than the first to match it

triple oops!

it should have been something like

 ...
mov CX,0xFFFF
cld
repne scasb
 ...

etc...

 BB> I think I'll stick to size_t strlen(const char *s) till you
 BB> clarify things. I know where I am with that

yeah, ne too.

 -=> Bye <=-

---
* Origin: Black Holes were created when God divided by zero! (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.