Author Topic: A beginner with a few questions  (Read 9585 times)

Offline arsnic

  • Jr. Member
  • *
  • Posts: 2
A beginner with a few questions
« on: January 19, 2011, 05:51:37 PM »
First off I need to say I'm new to assembly on the Mac architecture. When taking my assembly course in college it was using MIPS so please bear with me.

1.) I was wondering if I can perform recursion with NASM, I saw topic http://forum.nasm.us/index.php?topic=851.0 which says you can't use recursive macros, but if I push and pop the elements myself can i still call a label?

2.) What is the difference of compiling NASM's source on Mac vs. the Mac OSX package in the pub/nasm/releasebuilds/2.09.04/macosx/ directory if there is one?

3.) Does anyone know of some great, starting decently simple, tutorials that I could look over. I'll be looking over the sample code on the forum for sure but a tutorial over the basics would be nice to start with. I did find and download the documentation as well.

Thanks to all that can help me get started.

Offline cm

  • Jr. Member
  • *
  • Posts: 65
Re: A beginner with a few questions
« Reply #1 on: January 19, 2011, 10:25:16 PM »
1.) I was wondering if I can perform recursion with NASM, I saw topic http://forum.nasm.us/index.php?topic=851.0 which says you can't use recursive macros, but if I push and pop the elements myself can i still call a label?

The macros are a concept specific to NASM's pre-processor. Your assembly language source code (ie the program you are compiling with NASM) can perform recursion the usual way.

Quote
3.) Does anyone know of some great, starting decently simple, tutorials that I could look over. I'll be looking over the sample code on the forum for sure but a tutorial over the basics would be nice to start with. I did find and download the documentation as well.

I'm not aware of any x86-Mac-specific tutorials, but the locals will surely guide you to their favourite Linux or Windows tutorials. Frank would probably suggest Paul Carter's tutorial, which is listed to work on Windows, Linux and FreeBSD.
C. Masloch

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: A beginner with a few questions
« Reply #2 on: January 21, 2011, 03:14:55 PM »
1) You should be able to code anything - recursive or not - without resorting to macros. If and when recursive macros become available, I suspect their use will not be a "beginner's question". :)

Recursion can be difficult to get right:

Code: [Select]
recursion error: see recursion error

... but you shouldn't need macros to do it.

2) I don't know how the executables in the macosx directory are produced, nor how you would compile 'em yourself, but there "shouldn't" be any difference. (note that "everything" and "install_everything" are targets to "make" - these may produce more than what's in the .zip file... more documentation formats, e.g.)

3) As Christian predicts, I suggest Dr. Carter's tutorial, although it is not specifically targetted to MacOSX. I think the examples could be made to build on Mac with some minor tweaking - the "Linux" package might be easiest(?)... mainly a question of where/whether underscores are used. If you try it and have trouble, holler - we may be able to help(?).

There's also a "BSD Developer's Handbook":

http://www.freebsd.org/doc/en/books/developers-handbook/

It has a chapter on x86 assembly language that looks quite good. I don't know how close MacOSX is to "regular BSD", but it may be some help...

Best,
Frank

« Last Edit: January 21, 2011, 03:20:19 PM by Frank Kotler »

Offline arsnic

  • Jr. Member
  • *
  • Posts: 2
Re: A beginner with a few questions
« Reply #3 on: January 22, 2011, 06:28:09 AM »
Thank you both. Like I said, I learned MIPS and that was a time ago so thanks for the pointers.