Nov 29, 2005

Back to 0-1

Assembly ... Oh no, It was 10 years ago. And now things dont change :-)

// This file calculates Ck of given k
#define R_in R15

#define R_loop R14
#define R_out R13
#define R_s1 R12
#define R_s3 R11
.code

.org 0
ldi R_in 0 3 // Enter data, k
addi R_in R_in 0x10 // k = k+10
mvr R_out 0 R_in 0 8 0 // Copy data
mvr R_s1 0 R_in 7 1 0 // R_s1 initial value = R_in[7]
ldi R_loop 0 7 // 0..MSB-1
_A:

shi R_in R_in 1 0 0
mvr R_s3 0 R_in 7 1 0 // Get next bit
xor R_s1 R_s1 R_s3 0
decibr R_loop 1 _A 0
nop
subi R_s1 R_s1 1
brz _B 0
nop
addi
R_out R_out 0x80
_B:
nop // if even, do nothing
nop
break




No comments:

Post a Comment