Not handling dword arithmetic correctly in ppcross8086
Original Reporter info from Mantis: Mecrisp
-
Reporter name: Matthias Koch
Original Reporter info from Mantis: Mecrisp
- Reporter name: Matthias Koch
Description:
The upper 16 bits of a dword variable are not calculated properly and contain zero using this function:
var memory : array[0..7] of byte;
function read32(addr : dword) : dword;
begin
read32 := memory[addr] or
memory[addr + 1] shl 8 or
memory[addr + 2] shl 16 or
memory[addr + 3] shl 24;
end;
Steps to reproduce:
Using Free Pascal Compiler version 3.0.4+dfsg-22 [2019/01/24] for x86_64
on Debian 10 gives correct result:
fpc error && ./error
12345678
43424140
44434241
45444342
46454443
47464544
When using compiler from ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/i8086-msdos/fpc-3.3.1.msdos.built.on.x86_64-linux-tiny.tar.gz
Free Pascal Compiler version 3.3.1-r20:48878 [2021/03/05] for i8086
ppcross8086 -XX -Os -CX -WmTiny -Wtcom error.pas
Running error.com in Dosbox gives:
12345678
00004140
00004241
00004342
00004443
00004544
Mantis conversion info:
- Mantis ID: 38593
- OS: DOS
- OS Build: DOSBox 0.74-2
- Build: 3.3.1-r20:48878 [2021/03/05]
- Platform: Cross 16 Bit DOS on AMD64 Linux
- Version: 3.3.1
- Monitored by: » Mecrisp (Matthias Koch)