-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<coverage generated="1699240284808" clover="3.2.0"> | ||
<project timestamp="1699240284808" name="All files"> | ||
<coverage generated="1699243322499" clover="3.2.0"> | ||
<project timestamp="1699243322499" name="All files"> | ||
<metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/> | ||
</project> | ||
</coverage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,36 @@ | ||
;; https://exercism.org/tracks/wasm/exercises/two-fer | ||
|
||
(module | ||
(memory (export "mem") 1) | ||
|
||
;; default return value/string | ||
;; 012345678901234567890123 | ||
(data (i32.const 0) "One for you, one for me.") | ||
|
||
(func (export "twoFer") (param $offset i32) (param $length i32) (result i32 i32) | ||
(return (i32.const 0) (i32.const 24)) | ||
;; return the default string when there input is zero-length | ||
(if (i32.eqz (local.get $length)) | ||
(return (i32.const 0) (i32.const 24)) | ||
) | ||
|
||
;; copy "One for ", offset 24+8=>32 | ||
(memory.copy (i32.const 24) (i32.const 0) (i32.const 8)) | ||
|
||
;; copy input string after "One for ", offset 32+$length | ||
(memory.copy (i32.const 32) (local.get $offset) (local.get $length)) | ||
|
||
;; copy the end of the default string after the function input | ||
(memory.copy | ||
;; new offset =>32+$length | ||
(i32.add (i32.const 32) (local.get $length)) | ||
|
||
;; copy ", one for me." to the end off 32+$length | ||
(i32.const 11) (i32.const 13) | ||
) | ||
|
||
;; return the new string | ||
(return (i32.const 24) | ||
(i32.add (i32.const 21) (local.get $length)) | ||
) | ||
) | ||
) |