diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-09-20 07:41:24 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-09-20 07:41:24 -0700 |
commit | 340bad4b919afbeed75da577a18e4e9d760b54c0 (patch) | |
tree | 81f4d34289c68eb88407eb37ec9474994ac8355c | |
parent | a065812f7718a33b09cb653949436dc1ab544756 (diff) | |
download | mc-340bad4b919afbeed75da577a18e4e9d760b54c0.tar.gz |
Add memops for Plan 9
-rw-r--r-- | lib/std/bld.sub | 1 | ||||
-rw-r--r-- | lib/std/memops-impl+plan9-x64.s | 44 |
2 files changed, 45 insertions, 0 deletions
diff --git a/lib/std/bld.sub b/lib/std/bld.sub index 6609263..39b730b 100644 --- a/lib/std/bld.sub +++ b/lib/std/bld.sub @@ -67,6 +67,7 @@ lib std {inc=.} = memops.myr memops-impl.myr memops-impl+posixy-x64.s + memops-impl+plan9-x64.s # platform specific files env+plan9.myr diff --git a/lib/std/memops-impl+plan9-x64.s b/lib/std/memops-impl+plan9-x64.s new file mode 100644 index 0000000..4ffc5e9 --- /dev/null +++ b/lib/std/memops-impl+plan9-x64.s @@ -0,0 +1,44 @@ +/* +std.memblit : (dst : byte#, src : byte#, len : std.size -> void) +std.memfill : (dst : byte#, val : byte, len : std.size -> void) +*/ +TEXT std$memblit+0(SB),$0 + CMPQ DI,SI + JZ .done + JG .fwdcpy + MOVQ SI,AX + SUBQ DI,AX + CMPQ AX,CX + JG .revcpy +.fwdcpy: + MOVQ DX,CX + SHRQ $3,CX + REP; MOVSQ + MOVQ DX,CX + ANDQ $7,CX + REP; MOVSB + JMP .done +.revcpy: + STD + MOVQ DX,CX + LEAQ -1(DX)(SI*1),SI + LEAQ -1(DX)(DI*1),DI + REP; MOVSB + CLD +.done: + RET + +TEXT std$memfill+0(SB),$0 + /* generate 8 bytes of fill */ + MOVBQZX SI,BX + MOVQ $0x101010101010101,AX + IMULQ BX,AX + + /* and fill */ + MOVQ DX,CX + SHRQ $3,CX + REP; STOSQ + MOVQ DX,CX + ANDQ $7,CX + REP; STOSB + RET |