- sbrc z_flags,ZFL_N ; if add-op
- rjmp do_op_da_sub ; then
- ldi temp2,0 ;
- mov temp,opl ;
- andi temp,0x0f ;
- cpi temp,0x0a ;if lower digit > 9
- brlo do_op_da_h ;
- ori temp2,0x06 ; add 6 to lower digit
-do_op_da_h: ;
- sbrc z_flags,ZFL_H ; ... or H-Flag
- ori temp2,0x06 ;
- add opl,temp2 ;
-
- ldi temp2,0 ;
- mov temp,opl ;
- andi temp,0xf0 ;
- cpi temp,0xa0 ;
- brlo do_op_da_c ;
- ori temp2,0x60 ;
-do_op_da_c: ; else sub-op
- sbrc z_flags,ZFL_C ;
- ori temp2,0x60 ;
- andi z_flags, ~( (1<<ZFL_S) | (1<<ZFL_Z) | (1<<ZFL_H) )
- add opl,temp2 ;
- in temp,SREG ;
- bst temp,AVR_Z ;Z-Flag
- bld z_flags,ZFL_Z ;
- bst temp,AVR_N ;S-Flag
- bst z_flags,ZFL_S ;
- sbrc temp2,5 ;C-Flag, set if 0x06 added
- ori z_flags,(1<<ZFL_C) ;
- ;H-Flag?
+ ldi temp2,0 ;new C and H flag
+ ldi oph,0 ;oph: what to add
+
+ sbrc z_flags,ZFL_N ;if add-op
+ rjmp op_da_sub ;then
+op_da_add:
+ mov temp,opl ; |
+ andi temp,0x0f ; |
+ cpi temp,0x0a ; if (lower nibble >= 0x0A)
+ brlo op_da_a10 ; |
+ ori oph,0x06 ; add 6
+ ori temp2,(1<<ZFL_H) ; set new H flag
+
+ sbrc z_flags,ZFL_C ; |
+ rjmp op_da_a02 ; if (C flag ...
+ cpi opl,0x90 ; |... or upper nibble >= 0x90)
+ brlo op_da_a03 ; |
+op_da_a02:
+ ori oph,0x60 ; add 0x60
+ ori temp2,(1<<ZFL_C) ; set new C flag
+op_da_a03: ; endif
+ rjmp op_da_ae
+op_da_a10: ; else (lower nibble is 0x09 or lower)
+ sbrc z_flags,ZFL_C ; |
+ rjmp op_da_a12 ; if (C flag ...
+ cpi opl,0xA0 ; |... or upper nibble >= 0xA0)
+ brlo op_da_a13 ;
+op_da_a12:
+ ori oph,0x60 ; add 0x60
+ ori temp2,(1<<ZFL_C) ; set new C flag
+op_da_a13:
+ sbrs z_flags,ZFL_H ; if (H flag)
+ rjmp op_da_ae ; |
+ ori oph,0x06 ; add 0x06
+ mov temp,opl ; |
+ andi temp,0x0f ; |
+ cpi temp,0x06 ; if (lower nibble >= 0x0A)
+ brsh op_da_ae ; |
+ ori temp2,(1<<ZFL_H) ; set new H flag
+ ; endif
+ ; endif
+op_da_ae:
+ add opl,oph
+ ldpmx z_flags, sz53p_tab, opl ; get S,Z,P flag
+ or z_flags,temp2 ; merge new C and H flag