Пример #1
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])
Пример #2
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
Пример #3
0
def store():
	reg = init_state()
	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
Пример #4
0
def store(reg):
    AVR.POPZ()
    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
    return reg
Пример #5
0
# 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)
AVR.EOR(reg[1][3],28)

AVR.STZ32(reg[1])