Error DIV result
Original Reporter info from Mantis: devport
-
Reporter name: Dariusz Kwiecinski
Original Reporter info from Mantis: devport
- Reporter name: Dariusz Kwiecinski
Description:
I get incorrect results using the div command.
Test code:
program test;
var
x,size : byte;
function doit(ax,asize : byte):byte;
begin
Result := ax+(asize div 2);
end;
begin
LPC_SYSCON.SYSAHBCLKCTRL := LPC_SYSCON.SYSAHBCLKCTRL or ((1 shl 6) or (1 shl 16));
LPC_GPIO0.DIR := LPC_GPIO0.DIR OR $0002;
size := 16;
x := 10;
size := doit(x,size);
if(size = 18) then
LPC_GPIO0.MASKED_ACCESS[$0002] := 0;
end.
If "(asize div 2)" change to "trunc(asize/2" or "(asize shr 1)" results is correct.
Im using 3.3.1 from last trunk :
ppcrossarm.exe -Tembedded -Parm -CpARMV6M -MObjFPC -l -vewnhibq -otestprogram -al -WpLPC1114FBD48_303
All outputs assembly in attachments.
Topic in forum:
https://forum.lazarus.freepascal.org/index.php/topic,47363.0.html
Additional information:
My english is not prefect :)
Mantis conversion info:
- Mantis ID: 36302
- OS: Windows 7
- Build: 3.3.1 pccrossarm embedded ARMV6M
- Version: 3.3.1