@@ -250,7 +250,7 @@ def make_ins(layout):
250
250
251
251
# assembler opcode definitions
252
252
253
- REG , IMM , COND_FLAGS , COND_COMP = 0 , 1 , 2 , 3
253
+ REG , IMM , COND = 0 , 1 , 2
254
254
ARG = namedtuple ('ARG' , ('type' , 'value' , 'raw' ))
255
255
256
256
@@ -268,10 +268,8 @@ def arg_qualify(arg):
268
268
if 0 <= reg <= 3 :
269
269
return ARG (REG , reg , arg )
270
270
raise ValueError ('arg_qualify: valid registers are r0, r1, r2, r3. Given: %s' % arg )
271
- if len (arg ) == 2 and arg in ['--' , 'eq' , 'ov' ]:
272
- return ARG (COND_FLAGS , arg .lower (), arg )
273
- if len (arg ) == 2 and arg in ['EQ' , 'LT' , 'GT' , 'GE' ]:
274
- return ARG (COND_COMP , arg .lower (), arg )
271
+ if len (arg ) == 2 and arg .lower () in ['--' , 'eq' , 'ov' , 'lt' , 'gt' , 'ge' ]:
272
+ return ARG (COND , arg .lower (), arg )
275
273
try :
276
274
return ARG (IMM , int (arg ), arg )
277
275
except ValueError :
@@ -293,18 +291,11 @@ def get_imm(arg):
293
291
raise TypeError ('wanted: immediate, got: %s' % arg .raw )
294
292
295
293
296
- def get_cond_flags (arg ):
294
+ def get_cond (arg ):
297
295
arg = arg_qualify (arg )
298
- if arg .type == COND_FLAGS :
296
+ if arg .type == COND :
299
297
return arg .value
300
- raise TypeError ('wanted: flags condition, got: %s' % arg .raw )
301
-
302
-
303
- def get_cond_comp (arg ):
304
- arg = arg_qualify (arg )
305
- if arg .type == COND_COMP :
306
- return arg .value
307
- raise TypeError ('wanted: comparison condition, got: %s' % arg .raw )
298
+ raise TypeError ('wanted: condition, got: %s' % arg .raw )
308
299
309
300
310
301
def _soc_reg_to_ulp_periph_sel (reg ):
@@ -544,13 +535,15 @@ def i_sleep(timer_idx):
544
535
545
536
def i_jump (target , condition = '--' ):
546
537
target = arg_qualify (target )
547
- condition = get_cond_flags (condition )
538
+ condition = get_cond (condition )
548
539
if condition == 'eq' :
549
540
jump_type = BX_JUMP_TYPE_ZERO
550
541
elif condition == 'ov' :
551
542
jump_type = BX_JUMP_TYPE_OVF
552
- else : # '--' means unconditional
543
+ elif condition == '--' : # means unconditional
553
544
jump_type = BX_JUMP_TYPE_DIRECT
545
+ else :
546
+ raise ValueError ("invalid flags condition" )
554
547
if target .type == IMM :
555
548
_bx .dreg = 0
556
549
_bx .addr = target .value
@@ -575,7 +568,7 @@ def i_jump(target, condition='--'):
575
568
def i_jumpr (offset , threshold , condition ):
576
569
offset = get_imm (offset )
577
570
threshold = get_imm (threshold )
578
- condition = get_cond_comp (condition )
571
+ condition = get_cond (condition )
579
572
if condition == 'lt' :
580
573
cmp_op = B_CMP_L
581
574
elif condition == 'ge' :
@@ -594,7 +587,7 @@ def i_jumpr(offset, threshold, condition):
594
587
def i_jumps (offset , threshold , condition ):
595
588
offset = get_imm (offset )
596
589
threshold = get_imm (threshold )
597
- condition = get_cond_comp (condition )
590
+ condition = get_cond (condition )
598
591
if condition == 'lt' :
599
592
cmp_op = BC_CMP_LT
600
593
elif condition == 'gt' :
0 commit comments