Skip to content

Commit

Permalink
Implement Caesar cipher
Browse files Browse the repository at this point in the history
  • Loading branch information
thaliaarchi committed Oct 18, 2019
1 parent 3815a4f commit 90ee37f
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 0 deletions.
106 changes: 106 additions & 0 deletions programs/caesar.out.ws
@@ -0,0 +1,106 @@










































































































7 changes: 7 additions & 0 deletions programs/caesar.out.ws.map
@@ -0,0 +1,7 @@
63400:loop
3818821:encode
2:.encode_loop
4:.skip
5:.upper
6:.lower
60348:exit
102 changes: 102 additions & 0 deletions programs/caesar.wsa
@@ -0,0 +1,102 @@
push 'K'; printc
push 'e'; printc
push 'y'; printc
push ':'; printc
push ' '; printc

push 0
readi

push 'P'; printc
push 'l'; printc
push 'a'; printc
push 'i'; printc
push 'n'; printc
push ':'; printc
push ' '; printc

push 1
loop:
dup
readc
dup
retrieve

dup
push 1
sub
jn encode
push '\n'
sub
jz encode

push 1
add
jmp loop

encode:
push 0
store
push 0
retrieve
push 0

.encode_loop:
push 1
add

dup
retrieve
dup
jz exit

dup
push 'A'
sub
jn .skip
dup
push '['
sub
jn .upper
dup
push 'a'
sub
jn .skip
dup
push '{'
sub
jn .lower

.skip:
printc
jmp .encode_loop

.upper:
push 'A'
sub
copy 2
add
push 26
mod
push 'A'
add
printc
jmp .encode_loop

.lower:
push 'a'
sub
copy 2
add
push 26
mod
push 'a'
add
printc
jmp .encode_loop

exit:
push '\n'
printc
drop
end

0 comments on commit 90ee37f

Please sign in to comment.