#NEWLINE# def assemble_I( PC , A , B ) : #NEWLINE# #INDENT# I = empty [ 'I' ] #NEWLINE# I . file_name = bench_name #NEWLINE# I . A ( 1 ) #NEWLINE# base_addr = mem_map [ 'BO' ] [ 'Origin' ] #NEWLINE# depth = mem_map [ 'BO' ] [ 'Depth' ] #NEWLINE# I . I ( ADD , base_addr , 'jmp0' , 0 ) #NEWLINE# I . I ( ADD , ( base_addr + depth ) , 'jmp1' , 0 ) #NEWLINE# I . I ( ADD , ( base_addr + ( depth * 2 ) ) , 'jmp2' , 0 ) #NEWLINE# I . I ( ADD , ( base_addr + ( depth * 3 ) ) , 'jmp3' , 0 ) #NEWLINE# base_addr = mem_map [ 'BPO' ] [ 'Origin' ] #NEWLINE# ( I . I ( ADD , base_addr , 0 , 'seed_pointer_init' ) , I . N ( 'init' ) ) #NEWLINE# I . I ( ADD , ( base_addr + 1 ) , 0 , 'output_pointer_init' ) #NEWLINE# ( I . I ( ADD , 'temp' , 0 , 'seed_pointer' ) , I . N ( 'hailstone' ) ) #NEWLINE# ( I . I ( MLS , 'temp' , 'three' , 'temp' ) , I . JEV ( 'even' , False , 'jmp0' ) , I . JNE ( 'init' , False , 'jmp1' ) ) #NEWLINE# ( I . I ( ADD , 'seed_pointer' , 'one' , 'temp' ) , I . JMP ( 'output' , 'jmp2' ) ) #NEWLINE# ( I . I ( MHU , 'seed_pointer' , 'right_shift_1' , 'temp' ) , I . N ( 'even' ) ) #NEWLINE# ( I . I ( ADD , 'A_IO' , 0 , 'output_pointer' ) , I . N ( 'output' ) , I . JMP ( 'hailstone' , 'jmp3' ) ) #NEWLINE# I . resolve_forward_jumps ( ) #NEWLINE# read_PO = ( ( ( mem_map [ 'B' ] [ 'Depth' ] - mem_map [ 'B' ] [ 'PO_INC_base' ] ) + B . R ( 'seeds' ) ) & 1023 ) #NEWLINE# write_PO = ( ( ( ( mem_map [ 'H' ] [ 'Origin' ] + mem_map [ 'H' ] [ 'Depth' ] ) - mem_map [ 'H' ] [ 'PO_INC_base' ] ) + B . W ( 'seeds' ) ) & 4095 ) #NEWLINE# PO = ( ( ( ( 1 << 34 ) | ( 1 << 32 ) ) | ( write_PO << 20 ) ) | read_PO ) #NEWLINE# B . A ( B . R ( 'seed_pointer_init' ) ) #NEWLINE# B . L ( PO ) #NEWLINE# read_PO -= 1 #NEWLINE# write_PO -= 1 #NEWLINE# PO = ( ( ( ( 1 << 34 ) | ( 1 << 32 ) ) | ( write_PO << 20 ) ) | read_PO ) #NEWLINE# B . A ( B . R ( 'output_pointer_init' ) ) #NEWLINE# B . L ( PO ) #NEWLINE# return I