Author Topic: Why generates different code then TASM ?  (Read 1413 times)

Offline Sharlenehargrove

  • Jr. Member
  • *
  • Posts: 7
Why generates different code then TASM ?
« on: February 11, 2023, 11:40:43 AM »
Hello, I noticed that NASM generates a different code than NASM for the register-to-register version of MOV, SUB, SBB, AND and some other instructions. And I am very curious why this is done. Technical reasons, speed? Or just first pick? My reason for this curiosity: From the '80s on I disassembled various XT/AT (clone) BIOSes to see how they work and to be able to write my own own that is focussed on testing suspicious motherboards. Some years ago I switched to NASM and it wasn't until I disassembled the BIOS of a Commodore PC and assembled it again with NASM some months ago that I noticed that the generated code was different. FYI: after recalculating the checksum the 'new' BIOS worked as fine as the original one. Lately I disassembled Turbo Pascal 3 and ran into the same problem. That's why I decided to write my own assembler; one that would accept (my) NASM code and could, if needed, generate the alternative code. That's how I found out about the exact differences. FYI: my assembler and disassembler are written in Free Pascal and are based on ones I wrote for the 6502, Z80 and other CPUs. Another good reason to write them: it was fun! :) And don't worry about a competitor: both are only able to handle 8088 and 80286 (partly) instructions and I won't expand that. MyAccountAccess
« Last Edit: February 13, 2023, 05:38:34 AM by Sharlenehargrove »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Why generates different code then TASM ?
« Reply #1 on: February 11, 2023, 11:20:57 PM »
Hi Sharlene,

There's an icon at the lower right that will allow you to edit your message to say "different than Tasm" :)

Tasm's way drove Borland out of Business! Seriously, I think you'd have to ask Simon Tatham, the original author, that question. I suspect an arbitrary decision, but it might have been intentional to be different than Tasm. At one time, courts ruled that software with the same "look and feel" were a copyright violation, even though the code was different.

Eric Isaacson, author of A86, designed A86 to produce a recognizable pattern of different encodings so he could enforce his "free for non-commercial use" license. I speculate that it would be an amusing day in court, trying to convince a jury of this!

Don't worry about "competition". Nobody is getting rich from this!

Out of curiosity, how did you specify the alternatives?

Best,
Frank

« Last Edit: February 11, 2023, 11:26:13 PM by Frank Kotler »