aboutsummaryrefslogtreecommitdiff
path: root/compiler/elymasGlobalStr.ey
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2013-09-10 10:55:17 +0200
committerDrahflow <drahflow@gmx.de>2013-09-10 10:55:17 +0200
commitb7b2ef2c65a4b6e3d97c1e835ca82484f33f037c (patch)
tree8401f9df87bd5c6ab0bba50c9961085d46067a3f /compiler/elymasGlobalStr.ey
parent97d0ff2a4340a96be3753ed1fefec20b452fada0 (diff)
Bitfield operations on strings
(maybe moving into bin .* one day)
Diffstat (limited to 'compiler/elymasGlobalStr.ey')
-rw-r--r--compiler/elymasGlobalStr.ey75
1 files changed, 75 insertions, 0 deletions
diff --git a/compiler/elymasGlobalStr.ey b/compiler/elymasGlobalStr.ey
index b3407e5..01d2f17 100644
--- a/compiler/elymasGlobalStr.ey
+++ b/compiler/elymasGlobalStr.ey
@@ -264,6 +264,81 @@
/rbx :pushqReg
:retn
]] /eyfromArray defv
+
+ ## Bitfield style functions
+
+ # reset a string to all-zero
+ # 0 -> string to reset
+ [[
+ /rbx :popqReg
+
+ /rax /rax :xorqRegReg
+ /rdi :popqReg
+ 16 /rdi /rcx :movqMemDisp8Reg
+ 24 /rdi :addqImm8Reg
+ :reprcx :stosb
+
+ /rbx :pushqReg
+ :retn
+ ]] /eyzero defv
+
+ # bit test
+ # 0 -> string to extract bit from
+ # 1 -> bit index to extract
+ [[
+ /rbx :popqReg
+
+ ::internalAllocateInteger /rax :movqImmReg
+ /rax :callqReg
+ /rax /rdx :movqRegReg
+
+ /rdi :popqReg
+ /rax :popqReg
+ 8 /rax /rax :movqMemDisp8Reg
+
+ /rdx :pushqReg
+
+ /rcx /rcx :xorqRegReg
+ /rax 24 /rdi :btqRegMemDisp8
+ /cl :setcbReg
+
+ /rcx 8 /rdx :movqRegMemDisp8
+
+ /rbx :pushqReg
+ :retn
+ ]] /eybitTest defv
+
+ # bit set
+ # 0 -> string to extract bit from
+ # 1 -> bit index to set
+ [[
+ /rbx :popqReg
+
+ /rdi :popqReg
+ /rax :popqReg
+ 8 /rax /rax :movqMemDisp8Reg
+
+ /rax 24 /rdi :btsqRegMemDisp8
+
+ /rbx :pushqReg
+ :retn
+ ]] /eybitSet defv
+
+ # bit reset
+ # 0 -> string to extract bit from
+ # 1 -> bit index to set
+ [[
+ /rbx :popqReg
+
+ /rdi :popqReg
+ /rax :popqReg
+ 8 /rax /rax :movqMemDisp8Reg
+
+ /rax 24 /rdi :btrqRegMemDisp8
+
+ /rbx :pushqReg
+ :retn
+ ]] /eybitReset defv
> _ ==globalFunctions { defv }' ::allocateOffsetStruct
[