-
-
Save nilium/4dbd391dc381dc05edd3 to your computer and use it in GitHub Desktop.
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
// function rot13(mem_in, mem_out) -> bytes written | |
.rot13: | |
pop $4 | |
pop $5 | |
memlen $0 $4 | |
memlen $1 $5 | |
if $1 < $0 | |
load $0 $1 | |
load $1 0 | |
for $1 < $0 { | |
peek $2 $4 $1 0 | |
if 'a' <= $2 { | |
if $2 <= 'z' { | |
load $3 'a' | |
jump @__rot13__apply_rotate | |
} | |
} | |
if 'A' <= $2 { | |
if $2 <= 'Z' { | |
load $3 'A' | |
jump @__rot13__apply_rotate | |
} | |
} | |
jump @__rot13__continue | |
@__rot13__apply_rotate: | |
sub $2 $2 $3 | |
add $2 $2 13 | |
imod $2 $2 26 | |
add $2 $2 $3 | |
@__rot13__continue: | |
poke $5 $2 $1 0 | |
add $1 $1 1 | |
} | |
load rp $0 | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment