We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I'm Juan Manuel, I'm using the ADuC7026 with Keil:
IDE-Version:
µVision3 V3.23 Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2005
Tool Version Numbers: Toolchain Path: C:\Keil\ARM\BIN\ C Compiler: CA.Exe V2.42 Assembler: AA.Exe V2.40b Linker/Locator: LA.Exe V2.42 Librarian: LIBA.Exe V4.26 Hex Converter: OHA.Exe V2.10 CPU DLL: SARM.DLL V1.29 Dialog DLL: DARMAD.DLL V1.05b Target DLL: BIN\UL2ARM.DLL V1.14a Dialog DLL: TARMAD.DLL V1.05b
I'm trying to make a division between, for example A (an integer) and 316.5, but I have a problem. I compile it and everything is Ok, but when I debug it, and reachs the line that make the division it open the disassembly panel y and does nothing.
int main (void) { int res, a=4095, float b=316.5; res= a/b; //First I'd tried with / res= div(a,b); // Then with div() function while(1) { } }
Disassembly panel show this
?C?CASTF?T: 0x000801C0 4778 BX PC 0x000801C2 46C0 NOP
Is it possible to make the division I'm trying? What's the mistake?
I would be very grateful for any help!
Thanks
JuanMa
Oops, I could be completely wrong about this. The code in the disassembler looks more like switching from THUMB to ARM...
As noted, you should use your results or the compiler may ignore your code since it can't see any side effect.
Another thing. Floating point is always a bit expensive unless you have a processor with hw support for it. In your case, it is enough to multiply both numbers by two to get an integer division:
int a = 4096; int res = (a << 1) / 633;