; CC5X Version 3.1F, Copyright (c) B Knudsen Data
; C compiler for the PICmicro family
; ************ 27. Apr 2002 11:04 *************
processor 16C54
radix DEC
Carry EQU 0
Zero_ EQU 2
arg1 EQU 0x08
arg2 EQU 0x0A
res EQU 0x0B
rm EQU 0x0C
counter EQU 0x07
; FILE test\div16_8.c
;/*
; DIVISION: 16 bit DIV 8 bit
; ==========================
; Requires only 97 Cycles (97 microsec. at 4 MHz) to divide a 16 bit
; number by a 8 bit number. Requires that the result is 8 bit. The
; division remainder is also available.
; Optimized for SPEED & SIZE.
;*/
;
;uns16 arg1; // argument 1: 16 bit unsigned
;uns8 arg2; // argument 2: 8 bit unsigned
;uns8 res; // result : 8 bit unsigned
;uns8 rm; // remainder : 8 bit unsigned
;
;
;char uDiv16_8( void)
;// res,rm = arg1 / arg2
;// CYCLES: 11*8 + 10 - 1 = 97 + CALL & RETURN
;// INSTRUCTIONS: 27
;{
uDiv16_8
; if ( arg1.high8 >= arg2)
MOVF arg2,W
SUBWF arg1+1,W
BTFSC 0x03,Carry
; return 0; /* overflow or zero divide */
RETLW .0
; char counter = 8;
MOVLW .8
MOVWF counter
; rm = arg1.high8;
MOVF arg1+1,W
MOVWF rm
; res = rl( arg1.low8);
RLF arg1,W
MOVWF res
; do {
; LOOP:
; rm = rl( rm);
m001 RLF rm,1
; W = arg2;
[1] [2] [3] 下一页
本文关键字:暂无联系方式PIC单片机,单片机-工控设备 - PIC单片机