#!/usr/bin/env python import sys import re from math import log,ceil,floor,sqrt #V[loc] = "s%d", "[sp,#%d]", "sp+%d" or "label[%d]" where V[label] = "sp+%d" from loadsave import alloc_save,print_ldr,print_str,alloc_save_no,read_V # need to sync this list with whatever file that calls this file # otherwise the results will be wrong # alloc_save("h") # V["h"] = s0 # h = output alloc_save("g") # V["g"] = s1 # g = input 1 alloc_save("f") # V["f"] = s2 # f = input 0 alloc_save("hh") # V["hh"] = s3 # hh = cursor in h for i in range(7) : # seven scratch registers alloc_save(str(i)) r_f = "r1" r_g = "r2" r_h = "r0" # rotating accumulator k during round i def acc_r (i,k) : #global V #return(read_V(str((4*i+k)%7))) return('r' + str(8+(k+2*(i%2))%4)) def add_block_initial (a,b) :
import sys import re from math import log,ceil,floor,sqrt def cmod (A, B) : assert (B>0 and B==int(B)) R = A % B if R > B/2 : return R - B else : return R #V[loc] = "s%d", "[sp,#%d]", "sp+%d" or "label[%d]" where V[label] = "sp+%d" from loadsave import alloc_save,print_ldr,print_str,alloc_save_no,read_V alloc_save("ct") # V["ct"] = s0 # the counter alloc_save("1") # V["1"] = s1 # the float value 1 alloc_save("M") # V["M"] = s2 # M = output matrix ptr alloc_save("D") # V["D"] = s3 # delta = input 0 alloc_save("Temp") # V["Temp"] = s4 # store temp data def div_bot_trit_to_CZ (a1,b0,b1,X1): # a[0]!=0, destroys X1 print " eor %s, %s, %s " % (X1,a1,b1) print " and %s, %s, %s // M = g/f in (b0[0],X1[0])" % (X1,X1,b0) print " bfi %s, %s, #1, #1 // M = (X1[1],X1[0])" % (X1,b0) print " lsl %s, %s, #29 // shift to bit 29 and 30" % (X1, X1) print " msr APSR_nzcvq, %s // (Z=prod[0], C=prod[1])" % (X1) def mul_mod3_CZ (a0, a1, b0, b1) : print " ite eq" print " moveq %s, %s" % (a0, b0)
def cmod(A, B): assert (B > 0 and B == int(B)) R = A % B if R > B / 2: return R - B else: return R #V[loc] = "s%d", "[sp,#%d]", "sp+%d" or "label[%d]" where V[label] = "sp+%d" from loadsave import alloc_save, print_ldr, print_str, alloc_save_no, read_V # need to sync this list with whatever file that calls this file # otherwise the results will be wrong alloc_save("0") # scratch registers alloc_save("1") alloc_save("2") alloc_save("3") alloc_save("4") alloc_save("5") alloc_save("6") alloc_save("7") alloc_save("8") alloc_save("9") alloc_save("10") alloc_save("11") alloc_save("12") alloc_save("13") from bitslice3_mul32_i import add_to_mod3_d, sub_from_mod3_d, mul32_mod3, mul32_mod3_negc, add_sub_mod3_d
#!/usr/bin/env python import sys import re from math import log, ceil, floor, sqrt ARGS = sys.argv SAVES = 0 #V[loc] = "s%d", "[sp,#%d]", "sp+%d" or "label[%d]" where V[label] = "sp+%d" from loadsave import alloc_save, print_ldr, print_str, alloc_save_no, read_V, read_NV alloc_save("h") alloc_save("ov") try: NN = int(sys.argv[1]) except: NN = 256 try: B = int(sys.argv[2]) except: B = 32 assert (isinstance(B / 32, int)) def is_even(E): if isinstance(E, int): return (int(E / 2) * 2 == E) else: return (False)
# adjust # def adj_size (size) : # if (size < q_ab) : # 2341 is q-dependent # return(size) # else : # i = ceil ((floor(size * q16 / 2.0**16 + 0.5) - 0.5) * 2.0**16 / q16) - 1 # return(i - q * floor(i * q16 / 2.0**16 +0.5)) #V[loc] = "s%d", "[sp,#%d]", "sp+%d" or "label[%d]" where V[label] = "sp+%d" from loadsave import alloc_save, print_ldr, print_str, alloc_save_no, read_V, read_NV # need to sync this list with whatever file that calls this file # otherwise the results will be wrong alloc_save("q32") # round(2^32/q) alloc_save_no("q", str(q)) # ; print "q is %s" % read_V("q") alloc_save("d") # alloc_save("0" ) # scratch registers # alloc_save("1" ) # alloc_save("2" ) # alloc_save("3" ) # alloc_save("4" ) # alloc_save("5" ) # alloc_save("6" ) # alloc_save("7" ) # alloc_save("8" ) # alloc_save("9" ) # alloc_save("10") # alloc_save("11")