Save a few cycles by not reloading the last written byte between rounds.

This commit is contained in:
Stephen Heumann 2017-06-26 21:49:16 -05:00
parent 75aac0daa9
commit f04000c83d

View File

@ -31,7 +31,9 @@
macro macro
MixColumn &i,&A,&B,&C,&D,&state,&out MixColumn &i,&A,&B,&C,&D,&state,&out
aif (&i=0).AND.(&round<>1),.skip
ldy &state+&D ldy &state+&D
.skip
lda Sbox,Y lda Sbox,Y
pha pha
ldx &state+&A ldx &state+&A
@ -68,13 +70,20 @@
eor Xtime2Sbox,Y eor Xtime2Sbox,Y
eor rk+&round*16+&i+3 eor rk+&round*16+&i+3
sta &out+&i+3 sta &out+&i+3
aif &i<>12,.skip2
tay
.skip2
mend mend
macro macro
FinalRound &round FinalRound &round
FinalRoundStep 3,15,1
FinalRoundStep 15,11
FinalRoundStep 11,7
FinalRoundStep 7,3
FinalRoundStep 0,0 FinalRoundStep 0,0
FinalRoundStep 4,4 FinalRoundStep 4,4
FinalRoundStep 8,8 FinalRoundStep 8,8
@ -90,18 +99,15 @@
FinalRoundStep 14,6 FinalRoundStep 14,6
FinalRoundStep 6,14 FinalRoundStep 6,14
FinalRoundStep 3,15
FinalRoundStep 15,11
FinalRoundStep 11,7
FinalRoundStep 7,3
mend mend
macro macro
FinalRoundStep &to,&from FinalRoundStep &to,&from,&skipldy
aif C:&skipldy,.skip
ldy state2+&from ldy state2+&from
.skip
lda Sbox,Y lda Sbox,Y
eor rk+&round*16+&to eor rk+&round*16+&to
sta state1+&to sta state1+&to