! rot13 in sparc assembly for unix (system calls) ! jay kominek .section ".text" .align 4 .global main .type main,#function .proc 020 main: save %sp, -112, %sp ! save the stack! mov 0, %o0 ! stdin readbyte: sub %fp, 1, %o1 ! 1 byte below frame pointer call read mov 1, %o2 ! 1 byte ldub [%fp-1], %l1 ! pull the byte into %l1 cmp %o0, 0 be done ! byte was EOF, jump to done and %l1, 32, %l2 xor %l2, 0xff, %l3 ! invert %l2, store as a temp and %l1, %l3, %l1 cmp %l1, 0x41 bl skip ! note lack of trailing nop. cmp %l1, 0x5A ! the instructions trailing bg skip ! these branches affect nothing mov 26, %o1 ! if the branch isn't taken. sub %l1, 0x41, %l1 ! add 'A' add %l1, 13, %l1 call .rem ! (modulus) call is unconditional mov %l1, %o0 ! so final arg can be set afterwards add %o0, 0x41, %l1 skip: or %l1, %l2, %l1 stb %l1, [%fp-1] ! return the byte to memory mov 1, %o0 ! setup syscal args sub %fp, 1, %o1 call write mov 1, %o2 ba readbyte ! return to beginning mov 0, %o0 ! stdin (see beginning) done: ret ! return restore ! fix stack before return completes