diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2020-04-21 19:27:27 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2020-04-21 19:27:27 +0000 |
commit | a33ae23dc19309d38f046c335816194e86cf0ccd (patch) | |
tree | fa676a34b8948cfc73e7627eb365ef786152a638 /rtl/z80 | |
parent | 0c4f0ee66bd73bb1a211aa824eb8c04d69f73112 (diff) | |
download | fpc-a33ae23dc19309d38f046c335816194e86cf0ccd.tar.gz |
+ implemented Move() using inline asm
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/z80@44972 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'rtl/z80')
-rw-r--r-- | rtl/z80/z80.inc | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/rtl/z80/z80.inc b/rtl/z80/z80.inc index 299bb2839b..169c18af51 100644 --- a/rtl/z80/z80.inc +++ b/rtl/z80/z80.inc @@ -21,37 +21,44 @@ procedure fpc_cpuinit;{$ifdef SYSTEMINLINE}inline;{$endif} {$define FPC_SYSTEM_HAS_MOVE} -procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE']; -{var - pdest,psrc,pend : pbyte;} -begin -(* if (@dest=@source) or (count<=0) then - exit; - if (@dest<@source) or (@source+count<@dest) then - begin - { Forward Move } - psrc:=@source; - pdest:=@dest; - pend:=psrc+count; - while psrc<pend do - begin - pdest^:=psrc^; - inc(pdest); - inc(psrc); - end; - end - else - begin - { Backward Move } - psrc:=@source+count; - pdest:=@dest+count; - while psrc>@source do - begin - dec(pdest); - dec(psrc); - pdest^:=psrc^; - end; - end;*) +procedure Move(const source;var dest;count:SizeInt);assembler;[public, alias: 'FPC_MOVE']; +label + skip, forward_move; +asm + ld c, (count) + ld b, (count+1) + bit 7, b + jp NZ, skip + ld a, b + or a, c + jp Z, skip + + ld l, (source) + ld h, (source+1) + ld e, (dest) + ld d, (dest+1) + + ld a, d + cp a, h + jp C, forward_move + ld a, e + cp a, l + jp C, forward_move + + { backward move } + add hl, bc + dec hl + ex de, hl + add hl, bc + dec hl + ex de, hl + lddr + jp skip + +forward_move: + ldir + +skip: end; |