PDP-10 / its

Incompatible Timesharing System
Other
865 stars 83 forks source link

C library uses UFA #1357

Closed larsbrinkhoff closed 6 years ago

larsbrinkhoff commented 6 years ago

The C library uses the obsolete UFA instruction. This is a problem when running on a KS10 processor.

larsbrinkhoff commented 6 years ago

It's just used three times, in DROUND, DTRUNCATE, and FIXIFY. In all cases it's used like this: UFA A,[233000000000]. The octal number is 0.0.

larsbrinkhoff commented 6 years ago

It's used to convert a floating point number to an integer. If A is a float between 1 and 227, UFA A,[0.0] will add 0 and leave the unnormalized result in B. Next the exponent is masked off leaving just the integer.

larsbrinkhoff commented 6 years ago

I see some options:

larsbrinkhoff commented 6 years ago

One more option:

rcornwell commented 6 years ago

It was not uncommon in the 10 world to have different binaries for different machines. There is some code in Tops-10 (later versions), called kaser.mac which adds in support for the KA10 floating point instructions. This could be added into ITS to handle these as UUO's

larsbrinkhoff commented 6 years ago

Yes, I was thinking that would be a quick and convenient fix. Since the files with UFA are assembly language, I could add a assembly-time switch and use /T to enable it.

But actually it wouldn't be hard to patch out the instruction at run time from the UUH handler. Just overwrite the UFA A,[0.0] with FIX B,A and nop out the following TRZ 777000,B.

larsbrinkhoff commented 6 years ago

Fixed in #1356.

It turns out runtime patching was not as easy as I hoped. The instruction is in a pure page, and there doesn't seem to be a convenient way to make it writable. CORBLK says nope. Apparently you need to make a new writable page, copy the contents of the old page there, and replace the old pure page with the new.

Instead, I added an assembly time switch to select KS10 which uses FIX instead of UFA.