git-svn-id: branches/z80@44910 -
@@ -57,19 +57,33 @@ end;
{$define FPC_SYSTEM_HAS_FILLCHAR}
Procedure FillChar(var x;count:SizeInt;value:byte);
-var
- pdest,pend : pbyte;
- v : ptruint;
+label
+ skip, loop;
begin
- if count <= 0 then
- exit;
- pdest:=@x;
- pend:=pdest+count;
- while pdest<pend do
- begin
- pdest^:=value;
- inc(pdest);
- end;
+ asm
+ ld c, (count)
+ ld b, (count+1)
+ bit 7, b
+ jp NZ, skip
+
+ ld a, b
+ or a, c
+ jp Z, skip
+ ld e, (value)
+ ld a, 0
+ ld l, (x)
+ ld h, (x+1)
+loop:
+ ld (hl), e
+ inc hl
+ dec bc
+ cp a, c
+ jp NZ, loop
+ cp a, b
+skip:
+ end;
end;