;;***Registerdefinitionen ;;tempu.. Register 16 - 25 ;;templ.. Register 0 - 15 ;;isnull Register 0 - 15 mit Inhalt 0 ;;***SRAM ;;div64_rem: .byte 8 ;;Ziel/Divisor: .byte 8 => Startadresse in X übergeben ;;Divident: .byte 8 => Startadresse in Z übergeben ;;***Makros ;;PUSH/POP 16-Bit & 32-Bit ;;.macro PushZ ;Z_H und Z_L auf Stack ;; push ZH ;; push ZL ;;.endmacro ;;.macro PopZ ;; pop ZL ;; pop ZH ;;.endmacro ;;.macro PushX ;X_H und X_L auf Stack ;; push XH ;; push XL ;;.endmacro ;;.macro PopX ;; pop XL ;; pop XH ;;.endmacro ;;.macro PushY ;Y_H und Y_L auf Stack ;; push YH ;; push YL ;;.endmacro ;;.macro PopY ;; pop YL ;; pop YH ;;.endmacro ;;16-Bit load & store ;;.macro ldiw ;16-Bit Adresse aus EEProm / Ram laden ;; ldi @0L,low(@1) ;; ldi @0H,high(@1) ;;.endmacro BME_DIV_64: ;X = Ziel ;SRAM-Ptr ;Z = Divisor ;SRAM-Ptr ;Rest @div64_rem ;SRAM-Ptr pushX ldiw X,div64_rem movw Y,X rcall BME_CLR64 popX ldi tempu2,65 clc BME_div64_l0: ;shift left dividend ldi tempu1,8 pushX BME_div64_l1: ld templ1,X rol templ1 st X+,templ1 dec tempu1 brne BME_div64_l1 popX dec tempu2 brne BME_div64_m0 ret BME_div64_m0: ;shift dividend into remainder ldi tempu1,8 pushY BME_div64_l2: ld templ1,Y rol templ1 st Y+,templ1 dec tempu1 brne BME_div64_l2 popY ;remainder = remainder - divisor ldi tempu1,8 pushY pushZ clc BME_div64_l3: ld templ1,Y ld templ2,Z+ sbc templ1,templ2 st Y+,templ1 dec tempu1 brne BME_div64_l3 popZ popY brcc BME_div64_m1 ;restore remainder ldi tempu1,8 pushY pushZ clc BME_div64_l4: ld templ1,Y ld templ2,Z+ adc templ1,templ2 st Y+,templ1 dec tempu1 brne BME_div64_l4 popZ popY clc rjmp BME_div64_l0 BME_div64_m1: sec rjmp BME_div64_l0 ret BME_Clr64: ;X = Ziel push tempu2 ldi tempu2,8 BME_Clr64_l0: st X+,isnull dec tempu2 brne BME_Clr64_l0 pop tempu2 ret