Skip to content

Commit

Permalink
[std.porth] fix: memset bug :O
Browse files Browse the repository at this point in the history
  • Loading branch information
taylowar committed Apr 24, 2024
1 parent 29cb5fc commit bf30c76
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ tests/memset
tests/envp
tests/local-memory-overshadowing
tests/backslash-in-strlit
tests/memset-bug
2 changes: 1 addition & 1 deletion std/std.porth
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ in
byte !64
data @ptr swap
while dup 0 > do
byte @64 data @ptr !64
byte @64 data @ptr !8
data inc64
1 -
end
Expand Down
14 changes: 14 additions & 0 deletions tests/memset-bug.porth
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

include "std/std.porth"

const N 32 end
memory xs N end

0 while dup N < do
'a' over xs + !8
1 +
end drop

N xs puts "\n" puts
15 'b' xs memset drop
N xs puts "\n" puts
10 changes: 10 additions & 0 deletions tests/memset-bug.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:i argc 0
:b stdin 0

:i returncode 0
:b stdout 66
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaa

:b stderr 0

0 comments on commit bf30c76

Please sign in to comment.