Assembly Language Programming under Mac OS X

Click For Summary

Discussion Overview

The discussion centers on assembly language programming under Mac OS X, focusing on how to compile and debug assembly code in this environment. Participants share their experiences and seek guidance on tools and methods for working with assembly language, particularly in relation to system architecture and compatibility.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses interest in learning assembly language after experience with C, citing a lack of up-to-date resources for Mac OS X.
  • Another participant suggests outlining the system architecture to determine the appropriate assembler program.
  • It is noted that XCode includes an assembler (as), but uncertainty exists regarding the requirements for assembling and debugging code within XCode.
  • A participant mentions that using the C compiler's assembly output option could be a way to learn by examining the assembly code generated from C code that makes OS X calls.
  • One participant provides system specifications to clarify the context for assembly programming, emphasizing the importance of architecture in selecting an assembler.
  • Another participant states that for Intel processors, any x86 64 or x86 32 assembler will suffice, highlighting the significance of adhering to the correct calling convention when integrating assembly with other languages like C++.
  • NASM is mentioned as a common assembly program, with a recommendation to consult documentation for setting platform information and linking object modules with development tools.

Areas of Agreement / Disagreement

Participants generally agree on the need to consider system architecture when selecting an assembler and the importance of calling conventions. However, there is no consensus on the best approach to compile and debug assembly code under Mac OS X, as various tools and methods are suggested without a definitive resolution.

Contextual Notes

Participants reference various tools and resources, but there are limitations in the discussion regarding specific steps for using XCode and the integration of assembly with other programming languages. The discussion also reflects a dependency on the participants' individual system specifications and experiences.

Agisch
Messages
7
Reaction score
0
I want to start with assembly language programming after some years with C, cause I think it's a good way to learn how a computer actually works.

But how I can compile assembly code under Mac OS X?

I went to a library, and I had found out that many books are outdated, and no book covers assembly language concerning Mac OS X.
 
Technology news on Phys.org
Hey Agisch and welcome to the forums.

Can you outline your architecture for your system (since this is important for picking an assembler program)?
 
XCode includes an assembler (as), but I'm not sure what's required to assemble and debug code using XCode. Here's a wiki link, but you should do a web search for "XCode assenbler" to get more information on how to use it, and howto use it with OS X. Assuming the C compiler has an assembly output option, you could write some code in C that makes basic OS X calls such as file I/O and look at the assembly code produced by the C compiler.

http://en.wikipedia.org/wiki/Xcode
 
chiro said:
Hey Agisch and welcome to the forums.

Can you outline your architecture for your system (since this is important for picking an assembler program)?

My system specifications:

MacBook Pro
15-inch, Mid 2012


Processor 2.3 GHz Intel Core i7
Memory 4 GB 1600 MHz DDR3
Graphics NVIDIA GeForce GT 650M 512 MB
Software Mac OS X Lion 10.7.5 (11G63)
 
Given you have an Intel then any x86 64 (or x86 32 if 32-bit size words) will do the trick.

When you do assembler routines you need to make sure the calling convention is correct. Here is a look at it from Apple:

http://developer.apple.com/library/...owLevelABI/000-Introduction/introduction.html

Basically this ensures stuff is passed directly between different environments and its a critical thing when using assembly code in conjunction with say C++ or something else.

As for the actual assembler, I did a google search and I got this:

This document here mentions NASM which is a common assembly program.

http://www.nasm.us/

Read the docs for how to set the platform information (word size, operating system, calling conventions, etc) and you'll be good to go.

Also check out how you can link object modules compiled with NASM with your other dev tools if you are linking to compiled libraries, dynamic libraries, executables or other code objects.
 

Similar threads

  • · Replies 102 ·
4
Replies
102
Views
3K
  • · Replies 122 ·
5
Replies
122
Views
17K
  • · Replies 25 ·
Replies
25
Views
1K
Replies
16
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 16 ·
Replies
16
Views
5K
Replies
3
Views
3K
  • · Replies 397 ·
14
Replies
397
Views
21K
Replies
86
Views
3K
  • · Replies 59 ·
2
Replies
59
Views
8K