aboutsummaryrefslogtreecommitdiff
path: root/compiler/elymasGlobalStr.ey
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2013-08-28 14:29:13 +0200
committerDrahflow <drahflow@gmx.de>2013-08-28 14:29:13 +0200
commitfdd6dbf870747bd02f3a3ce6523dcc2c32880acb (patch)
tree80ed68cb37e61bd2d123c61f2f20f6d41ae63e22 /compiler/elymasGlobalStr.ey
parent4ed0f87a556e13d9394345727700e6440bd3b6f4 (diff)
More functions in the library
Diffstat (limited to 'compiler/elymasGlobalStr.ey')
-rw-r--r--compiler/elymasGlobalStr.ey35
1 files changed, 35 insertions, 0 deletions
diff --git a/compiler/elymasGlobalStr.ey b/compiler/elymasGlobalStr.ey
index 3376049..e48407b 100644
--- a/compiler/elymasGlobalStr.ey
+++ b/compiler/elymasGlobalStr.ey
@@ -98,6 +98,41 @@
/rbx :pushqReg
:retn
]] /eypostfix defv
+
+ # produce a string from an integer array specifying its bytes
+ # 0 -> array of integers
+ # 0 <- the same bytes as a string
+ [[
+ /rbx :popqReg
+
+ /rsi :popqReg
+ /rsi :pushqReg
+ /rsi /edi :movlMemReg # load array length
+ 3 /rdi :shrqImm8Reg
+ /rdi :decqReg
+ /rdi :pushqReg
+
+ ::internalAllocateString /rax :movqImmReg
+ /rax :callqReg
+
+ /rcx :popqReg # number of characters to copy
+ /rsi :popqReg
+ 8 /rsi :addqImm8Reg # move rsi to first array entry
+ /rax :pushqReg # store target string on stack
+ 24 /rax :addqImm8Reg # move rax to first string byte
+
+ @copyByte
+ /rsi /rdx :movqMemReg # load object pointer
+ 8 /rdx /rdx :movqMemDisp8Reg # load integer value
+ /dl /rax :movbRegMem
+
+ 8 /rsi :addqImm8Reg
+ /rax :incqReg
+ /copyByte :loopLbl8
+
+ /rbx :pushqReg
+ :retn
+ ]] /eyfromArray defv
> _ ==globalFunctions { defv }' ::allocateOffsetStruct
[