Question

I've been reading Assembly Language Step-By-Step (3rd edition; by Jeff Duntemann). I have a Linux box, a Lion box, and a (PPC) Tiger machine I can use. I've been writing small assembly programs with NASM on the Lion and Linux machines, and would like to do so on the Tiger one.

Mind you, I never expected this to be easy.

I'm not quite sure how I should change the code to work on PPC. I've so far ran into three expression syntax errors (lines 2, 3, and 14) that I can't figure out.

(I don't have a firm grasp of the PPC instruction set in the least.)

The code I'm trying to assemble is such: (ignore the line numbers)

1    SECTION .data
2        str: db "Hello, World!",0x10
3        len: equ $-str
4
5    SECTION .bss
6
7    SECTION .text
8        global start
9
10   start:
11       nop
12       mov eax,4
13       mov ebx,1
14       mov ecx,str
15       mov edx,len
16       int 0x80
17
18       mov eax,1
19       mov ebx,0
20       int 0x80

(I do realize that PPC is dying and there's not much point in figuring out its assembly, but learning is never a bad thing.)

Était-ce utile?

La solution

nasm is an assembler for x86 / x86-64. You need to look at using the native (Mach-O ppc) as or gcc extended asm. It's not just a matter of changing opcodes - some directives will be invalid for ppc too. So you will need a firm grasp on PPC assembly.

It's also premature to say that power is dying. IBM POWER7 is still the "fastest" general purpose processor available. Also consider the Cell architecture and embedded markets.

Autres conseils

You wrote assembly for x86 (Intel i386). That is a different architecture than PowerPC (Motorola). See the PowerPC instruction set here.

Additionally you need to use assembler which understands the PowerPC instruction set, gnu as for instance.

Edit: Without a basic understanding of the instruction set (which is often fundamentally different for each architecture) you will find it impossible to write assembly.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top