• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NASM with Xcode 3.2 ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NASM with Xcode 3.2 ?


  • Subject: NASM with Xcode 3.2 ?
  • From: Colin Howarth <email@hidden>
  • Date: Sun, 11 Oct 2009 18:00:51 +0200

Hi,

Sorry if this is the wrong list, but I didn't find an assembler- specific one.

I'm trying to get back into assembler. I've never done much of that on Unix machines (being somewhat put off by GNU as's syntax). So I was pleased to see nasm "supported" under Xcode.

The documentation is a bit minimal though, appearing to consist of a man page and the NASM Manual. OK, that sounds like quite a lot of documentation, but I still need a HOWTO or helloworld.nasm to get me started.

Under Xcode I did File->New File... Other: Assembly File.

That creates a .s file.

The assembler didn't like my code. Because it was 'as', not 'nasm'.

OK, rename it to .nasm

The assembler doesn't like the C style comments. OK, delete them.

The assembler (nasm, now) doesn't like the segment _DATA.

OK, replace that with segment .data.

Xcode says there's no rule to make x86_64bit stuff.

OK, go to Target > Inspector > Build > Architecture > Architectures: and choose 32-bit universal. (instead of 64-bit)

Now it compiles, but the bit of code I copied from the NASM Manual (Chapter 8. Writing 32 bit code (Unix...)
crashes with asm misaligned_stack_error.



Any help appreciated. Not especially with the code - I just want to see something on the console :-)


--colin



Here's the code:


/* main.c */ #include <stdio.h>

extern void myfunc(void);

int main (int argc, const char * argv[]) {

	int a = 1;
	int b = 2;
	int c;

	c = a + b;

	myfunc();

	return(0);
}





; tst.nasm

global  _myfunc
extern  _printf

_myfunc:
        push    ebp
        mov     ebp,esp
        sub     esp,0x40		; 64 bytes of local stack space
        mov     ebx,[ebp+8]	; first parameter to function

	call print				; my bit of code

        leave				 ; mov esp,ebp / pop ebp
        ret


print:
push dword [myint] ; one of my integer variables
push dword mystring ; pointer into my data segment
call _printf
add esp,byte 8 ; `byte' saves space ;;; same crash whether commented out or not


		ret


segment .data

myint       dd   1234
mystring    db   'This number -> %d <- should be 1234',10,0

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NASM with Xcode 3.2 ?
      • From: Wim Lewis <email@hidden>
    • Re: NASM with Xcode 3.2 ?
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: Symbol(s) not found error for _vm_region, migrating to Xcode 3.2
  • Next by Date: Re: Cannot remove undocumented and useless "Page" item from project window toolbar
  • Previous by thread: Re: Symbol(s) not found error for _vm_region, migrating to Xcode 3.2
  • Next by thread: Re: NASM with Xcode 3.2 ?
  • Index(es):
    • Date
    • Thread