[fpc-devel]BUG in BASEGO32 snapshot 18:18:52 Fri 17/11/00 (322)

Michael Knapp mknapp at gmx.at
Sun Nov 19 00:34:14 CET 2000


GraphiX is currently a quite good "Bug-Finder for FPC", not a graphics
library ...
I'm not happy about that ...

VAR x,y:dword;

BEGIN
  x:=1000;
  y:=((x DIV 1000) SHL 28)+   { $10000000 }
     ((x DIV 1000) SHL 24)+   { $01000000 }
     ((x DIV 1000) SHL 20);   { $00100000 }
  writeln('the result is ',y);
  writeln('but it should be 286261248 = $11100000');

(* The Assembler Output:

# [6] x:=1000;
  movl  $1000,_X
# [7] y:=((x DIV 1000) SHL 28)+   { $10000000 }
  movl  _X,%eax          eax=1000d
  movl  $1000,%edi       edi=1000d
  xorl  %edx,%edx        edx=0
  idivl  %edi             eax=1,edx=0
  shll  $28,%eax         eax=10000000h
# [8] ((x DIV 1000) SHL 24)+   { $01000000 }
  movl  _X,%edx          edx=1000d
  movl  $1000,%edi       edi=1000d
  pushl  %eax             push eax=10000000h
  movl  %edx,%eax        eax=1000d
  xorl  %edx,%edx        edx=0
  idivl  %edi             eax=1,edx=0
  movl  %eax,%edx        edx=1
  popl  %eax             pop eax=10000000h
  shll  $24,%edx         edx=01000000h
  addl  %eax,%edx        edx=11000000h
# [9] ((x DIV 1000) SHL 20);   { $00100000 }
  movl  _X,%eax          eax=1000d
  movl  $1000,%edi       edi=1000d
  xorl  %edx,%edx        edx=0 >>> here the edx=11000000 is overwritten
!!!
  idivl  %edi             eax=1, edx=0
  shll  $20,%eax         eax=00100000h
  addl  %edx,%eax        eax=00100000h
  movl  %eax,_Y          y=00100000h
*)

END.

-----

Michael

-- 
+--------------------------------------------------------------------+
|  Michael Knapp - Mauerbach - Niederösterreich - Austria - Europe   |
|  E-Mail: mknapp at gmx.at                             ICQ: 36542787   |
+--------------------------------------------------------------------+
| G r a p h i X            http://programmierer.freepage.de/graphix/ |
| Graphics Library for Freepascal, Virtual Pascal and Borland Pascal | 
| http://graphix4pascal.cjb.net/    http://www.graphix4pascal.de.vu/ |
+--------------------------------------------------------------------+




More information about the fpc-devel mailing list