示例#1
0
def store_load_right_to_left(reg):
    AVR.POPZ()  # idx + 48
    AVR.STZ32(reg[5])  # store z
    AVR.STZ32(reg[2])  # store y
    AVR.SBIW(30, 8)
    AVR.STZ32(reg[4])  # store x
    AVR.STZ32(reg[1])  # store z
    AVR.SBIW(30, 8)
    AVR.STZ32(reg[3])  # store y
    AVR.STZ32(reg[0])  # store x
    reg = init_state()  # reinit the state.
    # current idx is +8
    AVR.ADIW(30, 8)  # go to idx + 16
    AVR.LDZ32(reg[1])  # load r[1]
    AVR.LDZ32(reg[4])  # load r[2]
    AVR.ADIW(30,
             8)  # skip the next 4 words as they contain garbage (former r[3])
    AVR.LDZ32(reg[2])  # load r[4]
    AVR.LDZ32(reg[5])  # load r[5]
    # pop the initial values of the other half from the stack ! :p

    AVR.POP32(reg[0])  # load r[0]
    AVR.POP32(reg[3])  # load r[1]
    # current value of idx is +40
    AVR.PUSHZ()
    return reg
示例#2
0
def big_swap():
	reg = init_state()
	AVR.LDZ32(reg[0])
	AVR.LDZ32(reg[1])
	AVR.LDZ32(reg[2])
	AVR.LDZ32(reg[3])
	AVR.STZ32(reg[1])
	AVR.STZ32(reg[0])
	AVR.STZ32(reg[3])
	AVR.STZ32(reg[2])
示例#3
0
def stack_load_left_to_right(reg):
    AVR.POPZ()  # idx + 48
    AVR.PUSH32(reg[3])
    AVR.PUSH32(reg[0])
    # DO WE DO ONLY  A SIMPLE REINIT OR A FULL ???
    reg[0].sort()  # we only re init the values in r[0] and r[3]
    reg[3].sort()  # we only re init the values in r[0] and r[3]
    AVR.SBIW(30, 48)  # go the begining of the state
    AVR.LDZ32(reg[0])  # load r[0]
    AVR.LDZ32(reg[3])  # load r[3]
    AVR.ADIW(30, 40)  # go back to idx+48 : 4 + 4 + 16 + 16
    AVR.PUSHZ()  # push to the stack : idx + 48
    return reg
示例#4
0
def stack_load_right_to_left(reg):
    AVR.POPZ()  # idx + 40
    AVR.PUSH32(reg[3])
    AVR.PUSH32(reg[0])
    reg[3].sort()
    reg[0].sort()
    # reg = reinit_state(reg)			# we only re init the values in r[0] and r[3]
    AVR.SBIW(30, 32)  # skip the next two words
    AVR.LDZ32(reg[0])  # load r[0]
    AVR.LDZ32(reg[3])  # load r[3]
    AVR.ADIW(30, 24)  # skip back 8 + 16
    # current value of idx is +40
    AVR.PUSHZ()
    return reg
示例#5
0
def load():
	# load the first column
	# load x then y then z
	reg = init_state()
	AVR.LDZ32(reg[0])
	AVR.LDZ32(reg[3])
	AVR.ADIW(30,8)
	AVR.LDZ32(reg[1])
	AVR.LDZ32(reg[4])
	AVR.ADIW(30,8)
	AVR.LDZ32(reg[2])
	AVR.LDZ32(reg[5])
示例#6
0
def load(reg):
    # load the first column
    # load x then y then z
    reg = init_state()
    AVR.LDZ32(reg[0])
    AVR.LDZ32(reg[3])
    AVR.ADIW(30, 8)
    AVR.LDZ32(reg[1])
    AVR.LDZ32(reg[4])
    AVR.ADIW(30, 8)
    AVR.LDZ32(reg[2])
    AVR.LDZ32(reg[5])
    AVR.PUSHZ()  # save current pointer (point to the first half of the state)
    return reg
示例#7
0
AVR.JMP('spbx')
AVR.LBL('spbxend')

AVR.SBIW(30,16)

# pop the constant of the round
AVR.POP(28)

AVR.LDI(27,3)
AVR.AND(27,28)
AVR.CPI(27,0)

AVR.BRNE('bigswap')

reg = init_state()
AVR.LDZ32(reg[0])
AVR.LDZ32(reg[1])
AVR.LDZ32(reg[2])
AVR.LDZ32(reg[3])
AVR.STZ32(reg[2])
AVR.STZ32(reg[3])
AVR.STZ32(reg[0])

# ROUND CONSTANT
AVR.LDI(24,0x9e)
AVR.LDI(25,0x37)
AVR.LDI(26,0x79)

AVR.EOR(reg[1][0],24)
AVR.EOR(reg[1][1],25)
AVR.EOR(reg[1][2],26)