views:

248

answers:

2

I've inherited a rather old big and complex codebase for a program originally targeted at MSDOS. It turns out that some sections of this program are written in an obscure dialect of x86 assembler called "Phar Lap assembler", after the company and product that produced the assembler program. I've done a fairly deep google search and I'm unable to find either the original assembler program, or any information or documentation about it. (Though I have found some rather frustrating pages on Experts Exchange of people asking similar questions).

So basically, I won't be able to get this thing to compile until I can either find a copy of PharLap Assembler (386asm.exe), or find enough information about the dialect to translate it to a more "standard" MASM like dialect. Either that, or try to muscle through just figuring it out by reading it.

Alternatively, if none of this is possible, then I just need some help with this problem, and I should at least be able to get one section of the program to compile.

There's a struct declaration in a .c file that looks like this:

//static struct bhash *bhash;

typedef struct bhash_control {
 void   *cachedata;
 Rgb3   *ctab;
 int    rederr;
 int    grnerr;
 int    bluerr;
 ULONG  drgb;   // temp var used by dithering, blackbox to us here
#ifdef SHOW_STATS
 int calls, hits1, hits2, fhits, misses;
#endif
 } BhashCtl;

BhashCtl bhashctl;   // global so assembler code can see it.

and then there's some assembler that looks like this, which is presumably trying to make the same type declaration so that some assembler code can use the same type:

BhashCtl struct
 cachedata  dd ?   ; pointer to alloc'd cache data area
ctab    dd ?   ; contains vb.pencel->cmap->ctab
rederr    dd ?   ; error diffusion dithering variables...
grnerr    dd ?
bluerr    dd ?
drgb    dd ?   ; rgb value with dithering rolled in

;calls     dd  ?    ; cache stats...
;hits1     dd  ?    ;   to use these, you also need to
;hits2     dd  ?    ;   uncomment a few lines below.
;fhits     dd  ?    ;   search for 'bhashctl.' to find them.
;misses     dd  ?

BhashCtl ends

 extern bhashctl:BhashCtl ; the one-and-only lives in bhash.c

this compiles with an error on the last line which looks like this (watcom assembler):

Error! E518: External definition different from previous one

So basically, I think what this is saying is that the assembler version of this struct doesn't match the C version of this struct. I've tried a number of different combinations of WORD and DWORD in place of dd in the assembler, but I can't get past this little thing. Maybe if I could find a way to get these two declarations to match perfectly, my need for information about pharlap would be diminished.

Also, if anyone can think of a better title for this sprawling question, I'm open to ideas.

Edit: Okay it turns out I skimmed over some important info. This is a file originally written for a Phar Lap assembler (which I don't have), that I'm trying to assemble using the watcom assember (wasm). The problem with that particular error, it turns out, is it seems Phar Lap is case sensitive, while watcom isn't. So it sees bhashctl as the same as BhashCtl. Figured this out with the help of my brother in law. I never would have thought of case insensitivity being the cause of that one.

A: 

This may not be the answer you need, but I'll try anyway: how hard is it to port your assembly sections into C? I know there is stuff that C can't do, but perhaps you can use inline assembly to accomplish that.

Chris Jester-Young
while generally that is a good idea, I'd like to at least see the code compile before I start messing significantly with it. At least I'll know then what it's meant to do when it's working correctly.
Breton
+1  A: 

ZIP of some Phar Lap manuals (including a 386|ASM one) at:

http://www.dinigroup.com/pharlap.php

barrowc