## Re: [Sdcc-user] Does divide work with integer maths?

 Re: [Sdcc-user] Does divide work with integer maths? From: Peter Chant - 2006-10-29 21:20:13 ```On Saturday 28 October 2006 17:02, Raphael Neider wrote: > sdcc -mpic14 -p16f877 bDIV.c Weird, it gets stuck in gpsim about [****] here: BCF STATUS,5 BCF STATUS,6 **** MOVWF _var_u_char_8_b =09 ; .line 14; "bDIV.c" =A0 =A0 return var_u_char_8_b; MOVF _var_u_char_8_b,W RETURN=09 ; exit point of _div1 The offending routine is at the bottom of the post, I've added *******=20 to the offending bit. I think I will upgrade my installation (Slackware)=20 to see if latest gpsim and sdcc on a fresh installation makes a=20 difference, not that it should. Just in case there is something odd this=20 will not destroy the old installation as it will be on a different disk=20 partition. The idea of the function below is that it outputs a pulse 1msec wide for=20 position =3D -1000 and 2msec wide for position =3D 1000. void Single_Servo_Int(int position) { //Take -1000 as full one way, +1000 as the other //0 =3D middle. //Note, needs to provide a pulse from 1-2msec width //at a 20msec interval - check in detail. //Base on 20MHz cpu. unsigned char i; =09 //Put out a logic high PORTD =3D PORTD | 0x80; //PORTB =3D 0xff; //PORTD =3D 0x80;; =09 =09 //Limit if (position > 1000) { position =3D 1000; } =09 if (position < -1000) { position =3D -1000; }=20 //i =3D 255; /* lloop =3D 600000; while(lloop > 0) { lloop--;}*/ //First pause, 1msec - 5 000 cycles =09 for ( i =3D 0 ; i < 250 ; i++ ) { _asm nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop _endasm; } //Calc the variable delay ****** for ( i =3D 0 ; i < (unsigned char) ( (position + 1000)/ 8 ) ; i++ )= { _asm nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop _endasm; } =09 PORTD =3D PORTD & (0xFF - 0x80); //PORTB =3D 0; //PORTD =3D 0x00; } ```