[comp.sys.amiga.tech] Reverse-Engineering A Hard Disk Device

djh@dragon.metaphor.com (Dallas J. Hodgson) (05/31/90)

OK Folks, let me tell you a story...

Once upon a time there was a programmer who owned a drive from the land of
M.A.S.T. This land was full of Tigers, and he bought a Tiny one. "30 Mb" was
its name. As he still wanted to use his Tiger when he upgraded his A-1000 to
an A-3000, he bought the Parallel Port version.

Then, said programmer tried his Tiger on said faster machine. His Tiger said
"I can't talk to my Driver, he runneth too fast for me" and would lock up.
When he asked the Driver if he could slow down, he replied, "I canneth not,
for I useth hard-coded timing loops, a nasty thing"

So the Programmer painstakingly reverse-engineered the Driver, whose nameth
was "X500.device". He commented every line, and put every Section into a
different Module. He useth the latest program Resource, and the Aztec
assembler that natives call "AS". He compared the loader output against the
original, and was content. Every byte of code and data was identical! All
except for a few instances whereby the instruction :

		ANDI.B #C0,D0

would differ in the opcode value; the original haddeth the value "$FFC0",
while his version haddeth the more correct value "$00C0". Since the hi-byte
of this sequence is unused by the 68000, he thought it should mattereth not.

The original X500.device has a couple 0-length hunkeths of BSS-type; the
programmer's had but one. He used Resource and compared the Binary output of
both, stripped, as it were, of information some call "loader". Except for
the FFC0 differences, both were equal in content, length, and order.

Except it didn't work - the Guru would visit the programmer, uninvited -
disturbing the dog and eating all the ice cream in the fridge.

So, the point of all this is; What's the difference? Does the 68030 care
about the high-byte of the ANDI.B opcodes and act differently? They
certainly dissassemble identically. I also discovered that Resource would
produce the same opcode for both a short and long "JMP 0". I had to fix
these up by hand in the Aztec source. AS won't allow a long-jmp constant
unless the address exceeds a SHORT, so I retouched these by hand. Any ideas,
people? Any replies will be gratefully accepted.
+----------------------------------------------------------------------------+
| Dallas J. Hodgson               |     "This here's the wattle,             |
| Metaphor Computer Systems       |      It's the emblem of our land.        |
| Mountain View, Ca.              |      You can put it in a bottle,         |
| USENET : djh@metaphor.com       |      You can hold it in your hand."      |
+============================================================================+
| "The views I express are my own, and not necessarily those of my employer" |
+----------------------------------------------------------------------------+