Hallo
Also mein Problem ist wiefolgt des Dividieren, aber die Routine funktioniert bei kleinen Zahlen 8bit durch 8 bit beschraenkt(so lange die Zahl nicht zu gross wird) aber die Routine ist eigentlich fuer 16/8 Bit gedacht.
Und ich muss mit grossen Zahlen Rechnen.
Muss ich irgendwas Wichtiges beachten beim Dividieren??
Meine Routine ist wie folgt:
Code:list p=16f873 ; list directive to define processor #include <p16f873.inc> ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _RC_OSC & _WRT_ENABLE_ON & _LVP_ON & _CPD_OFF SDIV1608L macro AARGB0,AARGB1, BARGB0 MOVF BARGB0,W SUBWF REMB0, F RLF AARGB0, F RLF AARGB0,W RLF REMB0, F MOVF BARGB0,W ADDWF REMB0, F RLF AARGB0, F MOVLW 6 MOVWF LOOPCOUNT LOOPS1608A RLF AARGB0,W RLF REMB0, F MOVF BARGB0,W BTFSC AARGB0,0 SUBWF REMB0, F BTFSS AARGB0,0 ADDWF REMB0, F RLF AARGB0, F DECFSZ LOOPCOUNT, F GOTO LOOPS1608A RLF AARGB1,W RLF REMB0, F MOVF BARGB0,W BTFSC AARGB0,0 SUBWF REMB0, F BTFSS AARGB0,0 ADDWF REMB0, F RLF AARGB1, F MOVLW 7 MOVWF LOOPCOUNT LOOPS1608B RLF AARGB1,W RLF REMB0, F MOVF BARGB0,W BTFSC AARGB1,0 SUBWF REMB0, F BTFSS AARGB1,0 ADDWF REMB0, F RLF AARGB1, F DECFSZ LOOPCOUNT, F GOTO LOOPS1608B BTFSS AARGB1,0 ADDWF REMB0, F endm ;***** VARIABLE DEFINITIONS w_temp EQU 0x20 ; variable used for context saving status_temp EQU 0x21 ; variable used for context saving AARGB0 EQU 0x22 AARGB1 EQU 0x23 ;geteil durch BARG EQU 0x24 BARGB0 EQU 0x25 BARGB1 EQU 0x26 ;Ergebnis REMB0 EQU 0x27 REMB1 EQU 0x28 LOOPCOUNT EQU 0x29 Nenner EQU 0x30 Zaehler EQU 0x31 TEMP EQU 0x32 AARGB5 EQU 0x33 Nenner1 EQU 0x34 ;********************************************************************** ORG 0x000 ; processor reset vector clrf PCLATH ; ensure page bits are cleared goto main ; go to beginning of program ;Initialisierung ini movlw 0x96 movwf Nenner movlw 0x00 movwf Nenner1 movlw d'3' movwf Zaehler return main call ini SDIV0808L Nenner,Nenner1,Zaehler nop nop nop END ; directive 'end of program'







Zitieren

Lesezeichen