Level 2 optimalization makes wrong code for absolute variables like Mem array (unit system)
Original Reporter info from Mantis: laaca@seznam.cz
-
Reporter name: Ladislav Lacina
Original Reporter info from Mantis: laaca@seznam.cz
- Reporter name: Ladislav Lacina
Description:
When Level 2 optimalization is on compiler sometimes forget to add segment prefix for access to absolute variables like mem:array[0..something] ob byte absolute 0:0
as defined in SYSTEM.PP for GO32V2 platform. This bug is not in every code with MEM however I found an example in file VESA.INC from unit Graph for GO32V2. (procedure PutPixVESA256)
I wrote two variants of critical piece of code - just look at it.
BUGREPORT:
Compilation of procedure PutPixVESA256 from VESA.INC file from unit Graph
for GO32V2 target.
{winwriteseg:word; offs:longint; color:word}
SetWriteBank(smallint(offs shr 16));
mem[WinWriteSeg : word(offs)] := byte(color);
$00029AC8: call $299d8 <SETWRITEBANK at vesa.inc:387>
$00029ACD: movzwl 0x48642,%edx
$00029AD4: shl $0x4,%edx
$00029AD7: and $0xffff,%esi
$00029ADD: add %esi,%edx
$00029ADF: mov %bl,(%edx) {BUG! Should be "mov %bl,%fs:(%EDX)"}
$00029AE1: mov (%esp),%ebx
$00029AE4: mov 0x4(%esp),%esi
$00029AE8: add $0x8,%esp
$00029AEB: ret
End of assembler dump.
{winwriteseg:word; offs:longint; color:word; col8:byte}
SetWriteBank(smallint(offs shr 16));
col8:=byte(color);
mem[WinWriteSeg : word(offs)] := col8;
$00029AC8: call $299d8 <SETWRITEBANK at vesa.inc:387>
$00029ACD: mov %bl,%al
$00029ACF: movzwl 0x48642,%edx
$00029AD6: shl $0x4,%edx
$00029AD9: and $0xffff,%esi
$00029ADF: add %esi,%edx
$00029AE1: mov %al,%fs:(%edx) {Correct}
$00029AE4: mov (%esp),%ebx
$00029AE7: mov 0x4(%esp),%esi
$00029AEB: add $0x8,%esp
$00029AEE: ret
$00029AEF: nop
Additional information:
this bug is associated with bug 0011724
Mantis conversion info:
- Mantis ID: 18113
- OS: GO32V2
- Platform: GO32V2
- Version: 2.4.2
- Fixed in version: 3.0.0
- Fixed in revision: 16619 (#d10f46ec),22067 (#de34f582)
- Monitored by: » laaca@seznam.cz (Ladislav Lacina)