@@ -288,15 +288,14 @@ def _divu16(ins):
288288 '''
289289 op1 , op2 = tuple (ins .quad [2 :])
290290 if is_int (op1 ) and int (op1 ) == 0 : # 0 / A = 0
291+ if op2 [0 ] in ('_' , '$' ):
292+ output = [] # Optimization: Discard previous op if not from the stack
293+ else :
294+ output = _16bit_oper (op2 ) # Normalize stack
291295
292- if op2 [0 ] in ('_' , '$' ):
293- output = [] # Optimization: Discard previous op if not from the stack
294- else :
295- output = _16bit_oper (op2 ) # Normalize stack
296-
297- output .append ('ld hl, 0' )
298- output .append ('push hl' )
299- return output
296+ output .append ('ld hl, 0' )
297+ output .append ('push hl' )
298+ return output
300299
301300 if is_int (op2 ):
302301 op = int16 (op2 )
@@ -349,15 +348,14 @@ def _divi16(ins):
349348 '''
350349 op1 , op2 = tuple (ins .quad [2 :])
351350 if is_int (op1 ) and int (op1 ) == 0 : # 0 / A = 0
351+ if op2 [0 ] in ('_' , '$' ):
352+ output = [] # Optimization: Discard previous op if not from the stack
353+ else :
354+ output = _16bit_oper (op2 ) # Normalize stack
352355
353- if op2 [0 ] in ('_' , '$' ):
354- output = [] # Optimization: Discard previous op if not from the stack
355- else :
356- output = _16bit_oper (op2 ) # Normalize stack
357-
358- output .append ('ld hl, 0' )
359- output .append ('push hl' )
360- return output
356+ output .append ('ld hl, 0' )
357+ output .append ('push hl' )
358+ return output
361359
362360 if is_int (op2 ):
363361 op = int16 (op2 )
0 commit comments