Monday, December 19, 2011

LC 3.00 strikes again

Hi there, sorry to make you wait, I was doing research on the C library part (plus reverse-coding on Commander Keen, Moebius, Ultima IV, ... I wish I can make a blog about them too).

Remember one of the first posts here ? The string "LC 3.00" at the beginning of the data segment gives us the hint that it have been compiled with Lattice C version 3.
Thanks to the internet, I found an almost complete version of the compiler (copyrighted from 1982, so you can say it's an old one).
In this version, there is a file C.ASM which is the source file to the very first piece of code that will be called when launching MGT.
The problem is, although it contains the line:
_VER DB "LC 3.00",0
confirming the fact that it is the right compiler, the source differs from what found in MGT's executable in some places.

For instance:
MOV _MSIZE,BX
MOV _MSIZE+2,AX
CALL RBRK ; reset memory pool
OR AX,AX
becomes:
MOV _MSIZE,BX
MOV _MSIZE+2,AX
PUSH ES
PUSH SI
CALL RBRK ; reset memory pool C_3B65_0000
POP SI
POP ES
OR AX,AX
in MGT.

And that's not all.

When checking the C library too, we can find some differences. In the floating point library for instance, there is a module named CXNDPL (don't ask me what it does... yet).

Inside you can find:
FLDZ
FSTP QWORD PTR _FPA
PUSH BX
PUSH AX
CALL CXFERR
POP AX
POP BX
and for MGT:
PUSH BX
PUSH AX
CALL CXFERR
POP AX
POP BX
the two upper instructions have disappeared.

If you want my opinion, the version of Lattice I have may be one of the first released. And it has some bugs left, which may have been corrected/patched in a later release. Though I don't understand why the version string is the same. Why not change it to "LC 3.00b" or "LC 3.01" ?

So if somewhere, someone reading this post has any information about this verions/bug/patch issue, I would be really great to hear from her (or him, it may be a guy too). Don't hesitate to comment !

That's all for today ! Thanks for reading !

No comments: