Author Topic: Tools for learning “The Art of Intel X86 Assembly”  (Read 11742 times)

Offline Amumu

  • Jr. Member
  • *
  • Posts: 5
Tools for learning “The Art of Intel X86 Assembly”
« on: June 10, 2013, 04:12:39 PM »
Although I studied a Computer Organization course in my college, I want to study Assembly (and related concepts) rigorously using this old book "The ARt of Intel X86 Assembly": http://www.ic.unicamp.br/~pannain/mc404/aulas/pdfs/Art%20Of%20Intel%20x86%20Assembly.pdf. Do you know how to get start on Linux? Is NASM a good choice for this? If I want to incorporate UCR Standard Library: http://www.plantation-productions.com/Webster/www.artofasm.com/DOS/Software.html in my code, do I have to compile the library first?

I want my code to run on a Linux VM (Virtual Box). Is this possible or it must be the native code of my machine?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Tools for learning “The Art of Intel X86 Assembly”
« Reply #1 on: June 10, 2013, 07:57:39 PM »
Well... this is a fairly complicated question, Amumu!

As you know, the 16-bit version of AoA is "old", and for dos. It might be like trying to learn automotive repair using a Model A repair manual. The pistons still go up and down, but practically everything else has changed. Dos isn't going to be making that "comeback" that some of us were hoping for. As an OS, dos is pretty lame. This has an advantage, in that dos allows direct access to the hardware, which no protected-mode OS will let you do. Dos won't "help" you much, but it won't get in your way, either. To maximize this advantage, I'd install "real dos" on a separate partition, rather than count on an emulator to get it right... but maybe I'm just suspicious of emulators. I have not been able to install dosbox on my systen (a long story). You mention on SO that you tried dosbox but it "didn't work". In what way did it not work? (I can't help you, but perhaps others can)

It is possible to use Nasm in conjunction with AoA, but (16-bit) AoA targets Masm/Tasm syntax. Nasm's syntax is different. It is possible to overcome these differences... not too difficult... but you probably don't need any "extra" complications at this stage. I think I'd suggest using the "intended" assembler. If you don't like MS (some people don't, I'm told :) ), Japheth's Jwasm may work...

The 16-bit AoA is useless for Linux. The 32-bit AoA will work on Linux, but it uses HLA (the "high level assembler", an invention of Randy's) which uses a syntax all its own - unlike any other syntax you'll encounter. Last I knew, the Windows version will output Nasm syntax, the Linux version will not. Not that useful anyway - HLA won't "use" Nasm syntax.

Getting back to the 16-bit version, I think you'll find that the UCR Standard Library will come pre-assembled and linked. If not, it shouldn't be difficult... using the intended tools. Nasm won't do it. (I have some of the routines translated to Nasm syntax, but not all... I "might" still be able to find 'em...). As I recall, there's no difficulty linking Nasm-generated code ("-f obj") against the UCR library, if that's what you want to do. If a problem crops up, we might be able to help...

It isn't clear whether you're running Windows and want to run Linux in a VM, or if you're running Linux and want to run dos in a VM. Either should work, but might introduce "extra" complications that you don't need. The native code of the machine is the same in any case. Even a 64-bit machine will run 16-bit code (AFAIK), but a 64-bit OS will prevent it... except in an emulator. I'd install "real dos" (OpenDos seems pretty good) on a separate partition if you want "real" access to "real" hardware. That may be due to my unfamiliarity with emulators...

If you want to get started in Linux, we can discuss that more - I'll leave it for a separate answer. I think that's a fine idea! But the 16-bit AoA is not relevant.

I'm watching SO to see if you get any good answers. I'm betting that they'll close your question. Apparently they don't consider "how should I learn this?" to be a "real question". Maybe they'll fool me. We're willing to discuss it here, even if the answer is "don't use Nasm". (we'll try to avoid that, of course)

Best,
Frank


Offline Amumu

  • Jr. Member
  • *
  • Posts: 5
Re: Tools for learning “The Art of Intel X86 Assembly”
« Reply #2 on: June 11, 2013, 04:21:40 AM »
Thanks Frank for your dedicated reply,

I was trying various solutions, including download ReactOS to run such legacy programs. Suddenly I remembered good old Wine, and found out that Wine was originally made for 16-bit applications running under DOS and Windows 3.1. As a result, I can use all of the applications now. If a program can only be used with DOS, dosbox comes into play.

To run a Windows program, I use wine <Windows_program>; to run a DOS program: dosbox <dos_program>. Work great.

With JWAsm, I can use it to substitute MASM32. At this stage, I am still not sure how to link and use UCR Standard Library, but I hope that I will have a solution when encounter this issue.

As for DOS programming with BIOS, after I learn all non-DOS stuffs (which means everything except chapter 13 and 20-25), I will come back to those topics with a more modern way to learn.

I will start NASM and Linux Assembly soon after I finish the book (or most of it) :). I don't like the new Art Of Assembly book, since  the author (Randall Hyde) used HLA for teaching; the book is also simplified compare with its original content. I learned Assembly once; I don't need a beginner's ASM language anymore.

That's the plan.
« Last Edit: June 11, 2013, 04:26:17 AM by Amumu »

Offline jalisco

  • Jr. Member
  • *
  • Posts: 6
Re: Tools for learning “The Art of Intel X86 Assembly”
« Reply #3 on: July 03, 2013, 12:17:44 AM »
Thought I would just throw in my two cents...

I agree with everything Randy said. I have read about half of the AoA (the older 16 bit version), fiddled with TASM/MASM and now NASM.

Mostly, all that has just led to confusion =/ They are all different in syntax, which doesn't make the process of learning any easier.

I don't mind the AoA explanations and such, but it's just that when learning something new, it doesn't help if the syntaxes aren't the same. Also, it seemed a little broad, so not sure that really helped - if I was interested on focusing on 8086. I really don't mind the history, though.

I also tried playing with emulators on 64 bit systems, and on various OSes (Intel Mac, x64 Windows and Linux), before coming to the grim resolution, that one really should have a system that will allow the usage of 16-bit native code, e.g. 32 bit Windows. I bit the bullet, and installed it on an adjacent partition. Probably the best thing, if you really got old hardware, is install it on a really old box =) But, I don't have any hardware that old just laying around (fortunately, or unfortunately, as the case may be).

I read through the nasm manual, and while it was informative, it doesn't really have much examples for someone trying to learn. Can anyone recommend any other source of code, examples, etc, that might ramp up the learning process?

Something inline with AoA, but with nasm syntax?

Thanks,
Jalisco