top | item 30982053

(no title)

jmcguckin | 3 years ago

Wasn’t this compiler liscenced from Silicon Valley Software?

discuss

order

adrian_b|3 years ago

Microsoft has bought some software from other companies, most famously the operating system which became MS-DOS (from Seattle Computer Products), but in their early years compilers and interpreters were their core ability.

I do not remember that they have bought any CP/M compiler.

In any case, I can guarantee that the Microsoft Fortran compiler was written by the same people who had written the Microsoft Basic interpreter.

I have disassembled both the MS Fortran and the MS Basic for CP/M, and they shared many unusual tricks.

For example both Microsoft programs included machine instructions that were executed with different meanings, depending on whether the instruction was entered sequentially or by a jump in the middle of the instruction.

A frequent use of this technique was for skipping the first instruction of a loop, when the loop was executed the first time (e.g. for skipping the incrementing of the loop counter after the initial value is assigned to it).

This was done by using a 3-byte load-register-with-immediate-value instruction, which loaded a 16-bit register with a 2-byte constant, but then the register was not used, so the load had the effect of a NOP.

At the end of the loop, there was a jump to the initial load instruction, but not to its beginning, but 1 byte later. So starting from the second execution of the loop what had initially been interpreted as 16-bit constant to be loaded in a register, was interpreted as an operation code and executed.

The net effect of the trick was that the program code was shorter by 2 bytes for each occurrence of the trick, in comparison with a program written in the standard way, where a jump instruction would have been needed to skip the first instruction of the loop.

The trick had the added benefit that it would confuse naive automatic disassemblers, which would attempt to disassemble sequentially, instead of disassembling by tracing the execution.