Hallo

Also ich bin ueberhaupt nicht mit den Routinen von Microchip begeistert.

bei mir Klappen die gar nicht ich komm nie auf mein gewuenschtes Ergebnis.

Ich hab mal die erste bei AN617 rausgesucht fuer 16/8Bit Dividierung und hab die erste Routine gewaehlt. (Ich hab auch schon mal andere Routinen benutzt bin dabei aber auch nie auf mein Ergebnis gekommen.)

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

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.






;***** 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

;**********************************************************************
		ORG     0x000             ; processor reset vector
		clrf    PCLATH            ; ensure page bits are cleared
  		goto    main              ; go to beginning of program


;Initialisierung
ini
		movlw	d'250'
		movwf	BARG
		movlw	0xE2
		movwf	AARGB0
		movlw	0x04
		movwf	AARGB1
		return
main
		call	ini

		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
		NOP
		NOP
		NOP
	END                       ; directive 'end of program'
Ich teil bei der Routine 1250 durch 250 ergebnis muesste 5 sein bekomm aber 4 heraus.

Ich hab schon mit mehreren Zahlen gerechnet aber nie auf irgend ein richtiges Ergebnis gekommen.
Koennte mir einer dabei weiterhelfen richtige Werte auszurechnen?? [-o<
Gruss Egg