[Coco] Linville's ramblings on assembly vs machine code

Dave Philipsen dave at davebiz.com
Mon Jul 10 16:39:54 EDT 2017


> On Jul 10, 2017, at 2:59 PM, James Jones <jejones3141 at gmail.com> wrote:
> 
> That's what disassemblers are for, save for programs that do tricks like
> modifying themselves.
> 
> Were I teaching assembly language, I'd show the instruction formats, and
> then go into particular instructions as needed. Are you wondering whether
> the order of registers in the push/pull instructions makes a difference?
> Write assembly language that has them in different orders, and see whether
> the generated bytes for the two instructions as shown in the listing are

And, of course, looking at the generated bytes is, in essence, studying the machine language. You're just advocating the study of it using the indirect method.

> the same. (If memory serves, they are.) About span-dependent instructions,
> I'd point out the different encodings and point interested students at the
> relevant paper from CACM back in the 70s, (The general problem is
> NP-complete, but there's an efficient algorithm that works for a family of
> displacements that includes all but the most pathological examples, and a
> good assembler ought to implement it.)

The question of whether to use a branch or long branch or how an assembler should automatically solve that problem is not the point, however. The fact of the matter is that the CPU *has* both instructions. Why? Why might it be prudent in some cases to use a long branch when a short branch would work?  Studying the CPU and its native language reveals the answer.

In some cases, studying only the assembler language does not reveal how it is translated into machine language nor does it reveal why certain rules or methods are in place.

When I was a kid I loved to take mechanical and electrical things apart to see how they worked. Once you understand how it works, then it's easier to build/repair new things. Machine language is like tearing something down to the nuts and bolts to see how it works. A guy who has taken apart and rebuilt a combustion engine piece by piece will be more qualified to diagnose a problem with the family driver than a guy who has only been taught the theory.


> 
> James
> 
> On Mon, Jul 10, 2017 at 12:38 PM, CoCo Demus <retrocanada76 at gmail.com>
> wrote:
> 
>> Machine language is mandatory when you are debugging or disassembling code
>> 
>> 
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco



More information about the Coco mailing list