Author Topic: about the example codes and books  (Read 3195 times)

Offline applechu

  • Jr. Member
  • *
  • Posts: 2
about the example codes and books
« on: February 24, 2012, 01:57:40 PM »
Hi:
I am newbie to assembler and have trouble to learn this subject.
The problems come from some issue, one is the difference between nasm and masm.
Is the codes can be work well between these two. Another is the DEBUG prompt. is the
codes can work well under nasm.
Thanks a lot.

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 430
  • Country: us
Re: about the example codes and books
« Reply #1 on: February 24, 2012, 04:34:42 PM »
The differences are mostly syntax.  Opcodes and registers are the same.  You will find better support for the latest CPUs with Nasm.  You will also get support from using this forum as well.  Nasm will also generate code for Linux - a big factor IMHO.  I use Nasm exclusively for both Windows and Linux development.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2384
  • Country: us
Re: about the example codes and books
« Reply #2 on: February 24, 2012, 09:42:11 PM »
Hi Applechu,

You don't mention "what OS?", but your mention of Masm suggests you're not interested in Linux, and your mention of DEBUG suggests dos. Dos is a fairly easy way to start learning asm, but I wouldn't spend too much time learning dos - it's "obsolete" y'know, some people claim "dead".

As Rob says, the difference between Masm and Nasm is mostly syntax. I think the thing that will probably give you the most trouble is the difference in the way we distinguish between an "address" ("offset") and the contents of memory at that address. Nasm doesn't use the word "offset" - if we say "my_var", it means "offset" (the offset part of the address - all addresses include a "segment" and an "offset"). When Masm says "my_var", it usually means "contents of memory" (although this is ambiguous in some cases). For "contents of memory", Nasm says "[my_var]" - always. Masm includes some "built in macros" - "proc" and "invoke" for example, which Nasm would have to provide in an included file. There's a section of the manual that explains differences between Masm and Nasm, but I don't think it covers everything...

DEBUG, as an assembler, is a "simple assembler" - doesn't understand symbols. The only advantage to using it as an assembler is that it'll make you appreciate what a "symbolic assembler" is doing for you! :) As a debugger, what you'll see is "pretty near" what you'd write in Nasm. At the "DEBUG prompt", you can type '?' for a list of commands. 't' (trace) is probably the most useful one. Use 'p' (proceed) when you get to an interrupt - trying to trace through an interrupt is more likely to crash DEBUG than to teach you anything. 'q' to quit. I didn't know that one when I first started to use DEBUG, and the only way I could get out of DEBUG once I started it was to reboot. :)

I don't know what to suggest for a book that covers dos in Nasm syntax. Randy Hyde's old 16-bit "Art of Assembly" is very extensive, but uses Masm syntax (not "too" big a problem). The new 32-bit "Art of Assembly" uses HLA syntax, which is "completely different". When you're ready for 32-bit code (easier, actually!) Dr. Paul Carter's tutorial uses Nasm...

http://www.drpaulcarter.com/pcasm

This needs a C compiler/library. If you've got one already installed, easy - if not... that's a further complication.

For information on dos/bios interrupts, you want Ralf Brown's Interrupt List. Just google for "RBIL" and you'll find it. You definitely want this if you're going to use dos!

Examples... I've got a ton of dos examples, but too poorly organized to be much use. If there's something in particular you want to try, I'll see what I can find...

Quote
I am newbie to assembler and have trouble to learn this subject.

The first days are the hardest days,
Don't you worry anymore...
- Grateful Dead

It gets easier, honest! If you give us a more specific idea what you want to do, we'll try to help out.

Best,
Frank


Offline applechu

  • Jr. Member
  • *
  • Posts: 2
Re: about the example codes and books
« Reply #3 on: February 25, 2012, 12:31:15 AM »
thanks a lot.