Open asiekierka opened 1 year ago
Hello @asiekierka,
Confirmed. The bug is that the call is performed with %ds
≠ .data
(the default data segment) even though the callee expects %ds
= .data
.
main:
...
movw 8(%bp), %bx
movw 2(%bx), %bx
movb (%bx), %al
cbtw
movb $2, %cl
shlw %cl, %ax
xchgw %ax, %bx
movw $oop_procs@OZSEG16, %ax
movw %ax, %ds
lcall *oop_procs-192(%bx)
...
I may need some time to figure out how to properly fix this.
Thank you!
I changed the name of the bug accordingly, as I have found a different case in which this issue occured.
One workaround that comes to mind is allocating %es
in such a scenario, and using an %es
segment override on lcall
.
(I can move to Codeberg, if you prefer.)
Test case:
ia16-elf-gcc -mcmodel=medium -o testcase.exe testcase.c
gives the expected result, which is:testcase.exe 0
=> printstest1
,testcase.exe 1
=> printstest2
,testcase.exe 2
=> printstest3
.On any optimization level (tested -O1, -O2, -Os), running any of the above commands results in a DOS freeze.
Tested on the latest version of
build-ia16
from PPA; can also reproduce on my own WonderSwan builds. A workaround is to use__attribute__((optimize("-O0")))
on affected functions.