在哪里可以找到在OS X上学习汇编程序的工具?

时间:2022-02-08 13:36:29

I'd like to learn assembler. However, there are very few resources for doing assembler with OS X.

我想学习汇编程序。但是,使用OS X进行汇编程序的资源非常少。

Is there anyone out there who has programmed in assembly on a Mac? Where did you learn?

是否有人在Mac上进行程序集编程?你在哪里学习的?

And, is there any reason I shouldn't be doing assembly? Do I risk (significantly) crashing my computer irreparably?

而且,我有什么理由不做集会吗?我是否冒着(显着)使计算机崩溃的风险无可挽回?

10 个解决方案

#1


13  

If you're using a PowerPC Mac, look into gcc inline assembler. Otherwise, look into nasm. I can't give any decent references to PPC ASM (they're few and far between), but I suggest the following things to learn x86 asm:

如果您使用的是PowerPC Mac,请查看gcc内联汇编程序。否则,请查看nasm。我不能给PPC ASM提供任何不错的参考(他们很少和很远),但我建议学习x86 asm以下内容:

  • The book Reversing by Eldad Eilam
  • 这本书由Eldad Eilam翻译

  • Compile simple C source with gcc -S and read the assembly generated
  • 使用gcc -S编译简单的C源并读取生成的程序集

  • Use Sandpile
  • Join #openrce on irc.freenode.net and use OpenRCE
  • 在irc.freenode.net上加入#openrce并使用OpenRCE

Also, if you're not in kernel mode then there's no chance of screwing anything up, really, and even if you are in kernel mode it's hard to really destroy anything.

此外,如果你不处于内核模式,那么就没有机会搞砸任何东西,真的,即使你处于内核模式,也很难真正破坏任何东西。

Edit: Also, get gcc and such from XCode not Macports or somesuch. You're in for a world of malformed Mach-O files if you don't. Not fun to diagnose file format issues when you're just starting asm hacking.

编辑:此外,从XCode获取gcc等,而不是Macports或其他。如果你不这样做,你就会陷入畸形的Mach-O文件世界。当你刚开始asm hacking时诊断文件格式问题并不好玩。

#2


5  

The assembler language is determined by the hardware platform, not the operating system. Given that OS X runs on Intel platform and is 64-bit, you should look for information on x64 (also called AMD64) assembler. Check the Wikipedia article (http://en.wikipedia.org/wiki/X86-64) for a lot of links to documentation about x64.

汇编语言由硬件平台决定,而不是由操作系统决定。鉴于OS X在Intel平台上运行且为64位,您应该查找有关x64(也称为AMD64)汇编程序的信息。查看*文章(http://en.wikipedia.org/wiki/X86-64),获取有关x64文档的大量链接。

Also, the OS X tools documentation might contains a lot of information about x64 assembler. In particular, the Netwide Assembler (NASM - http://developer.apple.com/documentation/DeveloperTools/nasm/nasmdoc0.html) might have documentation on how to build OS X applications using assembler.

此外,OS X工具文档可能包含有关x64汇编程序的大量信息。特别是,Netwide Assembler(NASM - http://developer.apple.com/documentation/DeveloperTools/nasm/nasmdoc0.html)可能有关于如何使用汇编程序构建OS X应用程序的文档。

#3


5  

To start learning assembly, you might want to start with simple C programs and ask GCC to generate the assembler code for it using the -S option:

要开始学习汇编,您可能希望从简单的C程序开始,并要求GCC使用-S选项为其生成汇编代码:

gcc -S hello.c -o hello.asm

You will then be able to understand how to call functions, pass arguments, etc.

然后,您将能够理解如何调用函数,传递参数等。

#4


3  

Nasm/yasm are your best bet; gcc inline syntax is quite crippling and can be very painful to use at times, plus there are literally some things it cannot do. Nasm's macro syntax is also much much more useful, a godsend in a language like assembly that has no built-in templating features.

Nasm / yasm是你最好的选择; gcc内联语法非常瘫痪,有时使用起来非常痛苦,而且实际上还有一些它无法做到的事情。 Nasm的宏语法也更有用,是像汇编这样没有内置模板功能的语言中的天赐之物。

#5


1  

XCode (ie. GCC) has great support for writing assembler. It's a fun thing to learn (although you're unlikely to need it much), and the worst you can do is crash the program you're writing, same as in C. Just Google for 'gcc inline asm x86 tutorial' and you should find plenty of starting points. Don't worry that some will seem to be Linux specific, they'll generally work just as well in XCode.

XCode(即GCC)对编写汇编程序有很大的支持。这是一个有趣的事情(虽然你不太可能需要它),你可以做的最糟糕的事情是崩溃你正在编写的程序,就像在C中一样。只是谷歌的'gcc inline asm x86教程'和你应该找到很多起点。不要担心某些内容似乎是特定于Linux的,它们通常在XCode中也能正常工作。

(edit) ...assuming you have an Intel Mac of course; if not then replace 'x86' with 'ppc'.

(编辑)...假设你当然有一台Intel Mac;如果没有,那么用'ppc'替换'x86'。

#6


1  

here

I programmed assembly on a Mac. It was Motorola 680x0 assembler using MPW. I've touched on the PowerPC assembler a few times in CodeWarrior and ProjectBuilder. Now ProjectBuilder is called XCode, and there is Intel. The assembler is one of the many tools within XCode.

我在Mac上编写了程序集。使用MPW的是Motorola 680x0汇编程序。我在CodeWarrior和ProjectBuilder中几次触及PowerPC汇编程序。现在ProjectBuilder被称为XCode,而且还有Intel。汇编程序是XCode中的众多工具之一。

I originally learned assembler on the Apple II: the 6502 machine language monitor built in ROM, the Sweet16 mini-assembler, and others. Later, I used Intel 80186 assembler to speed up slow bits of C code, and work paid for a one day course on Intel 80186 assembler at a university. Later, I had to maintain some 680x0 assembly for the Mac. That was a long time ago.

我最初学习了Apple II上的汇编程序:内置ROM的6502机器语言监视器,Sweet16迷你汇编器等。后来,我使用英特尔80186汇编程序来加速C代码的慢速运行,并为一所大学的英特尔80186汇编程序的一天课程付费。后来,我不得不为Mac维护一些680x0的程序集。那是很久以前的事。

I don't think there is any reason not to do assembly. Learning is great. Learn all you can. Drop into a low enough level debugger and look at the disassembled code.

我认为没有任何理由不做集会。学习很棒。尽你所能。进入足够低级别的调试器并查看反汇编代码。

My advice is:

我的建议是:

Don't be scared.

不要害怕。

#7


0  

There's no reason why you shouldn't; there is nothing you can do in assembly language that you can't do in a higher level language like C.

没有理由你不应该这样做;在汇编语言中你无法做任何事情,你不能用更高级别的语言来做。

As far as tools go, you might want to install MacPorts and get the GNU assembler. That may or may not be the easiest way, but it's free and you can probably find tutorial documentation for writing Unix programs in GNU assembler somewhere on the net.

就工具而言,您可能希望安装MacPorts并获得GNU汇编程序。这可能是也可能不是最简单的方法,但它是免费的,您可以在网上某处找到在GNU汇编程序中编写Unix程序的教程文档。

#8


0  

There are two three things you to know need for writing assembly language on a system with an operating system (as opposed to 'bare metal' assembly which is a world of its own):

在具有操作系统的系统上编写汇编语言需要知道两件事(而不是“裸机”汇编,这是一个独立的世界):

  1. How the instruction set works - loads of resources for Intel X86 if you have an Intel Mac, still reasonable set for PPC for example Mac OS X Internals.

    指令集的工作原理 - 如果你有英特尔Mac,那么英特尔X86的资源负载,对于PPC来说仍然是合理的设置,例如Mac OS X Internals。

  2. How to assemble link your programmes - if you have the Developer tools installed you have GCC and associated tools

    如何组装链接程序 - 如果安装了Developer工具,则需要GCC和相关工具

  3. How to talk to the OS - here is where Mac assembly is a lot less well documented than Windows or Linux. It may be you have to write equivalent C programs and use 'gcc -S' to see what calling/stack restoration conventions are appropriate. It depends what you want to do but at a miniumum you need OS system calls for IO and memory allocation.

    如何与操作系统对话 - 这里的Mac程序集远不如Windows或Linux。您可能需要编写等效的C程序并使用'gcc -S'来查看哪些调用/堆栈恢复约定是合适的。这取决于你想要做什么但是在最低限度你需要OS系统调用IO和内存分配。

A good starting point is here.

这里有一个很好的起点。

#9


0  

If you've got Developer Tools installed, you can simply open Terminal and type as (GNU Assembler - part of Binutils).

如果你已经安装了Developer Tools,你只需打开Terminal并输入(GNU Assembler - Binutils的一部分)。

#10


0  

For PPC try Lightsoft

对于PPC尝试Lightsoft

#1


13  

If you're using a PowerPC Mac, look into gcc inline assembler. Otherwise, look into nasm. I can't give any decent references to PPC ASM (they're few and far between), but I suggest the following things to learn x86 asm:

如果您使用的是PowerPC Mac,请查看gcc内联汇编程序。否则,请查看nasm。我不能给PPC ASM提供任何不错的参考(他们很少和很远),但我建议学习x86 asm以下内容:

  • The book Reversing by Eldad Eilam
  • 这本书由Eldad Eilam翻译

  • Compile simple C source with gcc -S and read the assembly generated
  • 使用gcc -S编译简单的C源并读取生成的程序集

  • Use Sandpile
  • Join #openrce on irc.freenode.net and use OpenRCE
  • 在irc.freenode.net上加入#openrce并使用OpenRCE

Also, if you're not in kernel mode then there's no chance of screwing anything up, really, and even if you are in kernel mode it's hard to really destroy anything.

此外,如果你不处于内核模式,那么就没有机会搞砸任何东西,真的,即使你处于内核模式,也很难真正破坏任何东西。

Edit: Also, get gcc and such from XCode not Macports or somesuch. You're in for a world of malformed Mach-O files if you don't. Not fun to diagnose file format issues when you're just starting asm hacking.

编辑:此外,从XCode获取gcc等,而不是Macports或其他。如果你不这样做,你就会陷入畸形的Mach-O文件世界。当你刚开始asm hacking时诊断文件格式问题并不好玩。

#2


5  

The assembler language is determined by the hardware platform, not the operating system. Given that OS X runs on Intel platform and is 64-bit, you should look for information on x64 (also called AMD64) assembler. Check the Wikipedia article (http://en.wikipedia.org/wiki/X86-64) for a lot of links to documentation about x64.

汇编语言由硬件平台决定,而不是由操作系统决定。鉴于OS X在Intel平台上运行且为64位,您应该查找有关x64(也称为AMD64)汇编程序的信息。查看*文章(http://en.wikipedia.org/wiki/X86-64),获取有关x64文档的大量链接。

Also, the OS X tools documentation might contains a lot of information about x64 assembler. In particular, the Netwide Assembler (NASM - http://developer.apple.com/documentation/DeveloperTools/nasm/nasmdoc0.html) might have documentation on how to build OS X applications using assembler.

此外,OS X工具文档可能包含有关x64汇编程序的大量信息。特别是,Netwide Assembler(NASM - http://developer.apple.com/documentation/DeveloperTools/nasm/nasmdoc0.html)可能有关于如何使用汇编程序构建OS X应用程序的文档。

#3


5  

To start learning assembly, you might want to start with simple C programs and ask GCC to generate the assembler code for it using the -S option:

要开始学习汇编,您可能希望从简单的C程序开始,并要求GCC使用-S选项为其生成汇编代码:

gcc -S hello.c -o hello.asm

You will then be able to understand how to call functions, pass arguments, etc.

然后,您将能够理解如何调用函数,传递参数等。

#4


3  

Nasm/yasm are your best bet; gcc inline syntax is quite crippling and can be very painful to use at times, plus there are literally some things it cannot do. Nasm's macro syntax is also much much more useful, a godsend in a language like assembly that has no built-in templating features.

Nasm / yasm是你最好的选择; gcc内联语法非常瘫痪,有时使用起来非常痛苦,而且实际上还有一些它无法做到的事情。 Nasm的宏语法也更有用,是像汇编这样没有内置模板功能的语言中的天赐之物。

#5


1  

XCode (ie. GCC) has great support for writing assembler. It's a fun thing to learn (although you're unlikely to need it much), and the worst you can do is crash the program you're writing, same as in C. Just Google for 'gcc inline asm x86 tutorial' and you should find plenty of starting points. Don't worry that some will seem to be Linux specific, they'll generally work just as well in XCode.

XCode(即GCC)对编写汇编程序有很大的支持。这是一个有趣的事情(虽然你不太可能需要它),你可以做的最糟糕的事情是崩溃你正在编写的程序,就像在C中一样。只是谷歌的'gcc inline asm x86教程'和你应该找到很多起点。不要担心某些内容似乎是特定于Linux的,它们通常在XCode中也能正常工作。

(edit) ...assuming you have an Intel Mac of course; if not then replace 'x86' with 'ppc'.

(编辑)...假设你当然有一台Intel Mac;如果没有,那么用'ppc'替换'x86'。

#6


1  

here

I programmed assembly on a Mac. It was Motorola 680x0 assembler using MPW. I've touched on the PowerPC assembler a few times in CodeWarrior and ProjectBuilder. Now ProjectBuilder is called XCode, and there is Intel. The assembler is one of the many tools within XCode.

我在Mac上编写了程序集。使用MPW的是Motorola 680x0汇编程序。我在CodeWarrior和ProjectBuilder中几次触及PowerPC汇编程序。现在ProjectBuilder被称为XCode,而且还有Intel。汇编程序是XCode中的众多工具之一。

I originally learned assembler on the Apple II: the 6502 machine language monitor built in ROM, the Sweet16 mini-assembler, and others. Later, I used Intel 80186 assembler to speed up slow bits of C code, and work paid for a one day course on Intel 80186 assembler at a university. Later, I had to maintain some 680x0 assembly for the Mac. That was a long time ago.

我最初学习了Apple II上的汇编程序:内置ROM的6502机器语言监视器,Sweet16迷你汇编器等。后来,我使用英特尔80186汇编程序来加速C代码的慢速运行,并为一所大学的英特尔80186汇编程序的一天课程付费。后来,我不得不为Mac维护一些680x0的程序集。那是很久以前的事。

I don't think there is any reason not to do assembly. Learning is great. Learn all you can. Drop into a low enough level debugger and look at the disassembled code.

我认为没有任何理由不做集会。学习很棒。尽你所能。进入足够低级别的调试器并查看反汇编代码。

My advice is:

我的建议是:

Don't be scared.

不要害怕。

#7


0  

There's no reason why you shouldn't; there is nothing you can do in assembly language that you can't do in a higher level language like C.

没有理由你不应该这样做;在汇编语言中你无法做任何事情,你不能用更高级别的语言来做。

As far as tools go, you might want to install MacPorts and get the GNU assembler. That may or may not be the easiest way, but it's free and you can probably find tutorial documentation for writing Unix programs in GNU assembler somewhere on the net.

就工具而言,您可能希望安装MacPorts并获得GNU汇编程序。这可能是也可能不是最简单的方法,但它是免费的,您可以在网上某处找到在GNU汇编程序中编写Unix程序的教程文档。

#8


0  

There are two three things you to know need for writing assembly language on a system with an operating system (as opposed to 'bare metal' assembly which is a world of its own):

在具有操作系统的系统上编写汇编语言需要知道两件事(而不是“裸机”汇编,这是一个独立的世界):

  1. How the instruction set works - loads of resources for Intel X86 if you have an Intel Mac, still reasonable set for PPC for example Mac OS X Internals.

    指令集的工作原理 - 如果你有英特尔Mac,那么英特尔X86的资源负载,对于PPC来说仍然是合理的设置,例如Mac OS X Internals。

  2. How to assemble link your programmes - if you have the Developer tools installed you have GCC and associated tools

    如何组装链接程序 - 如果安装了Developer工具,则需要GCC和相关工具

  3. How to talk to the OS - here is where Mac assembly is a lot less well documented than Windows or Linux. It may be you have to write equivalent C programs and use 'gcc -S' to see what calling/stack restoration conventions are appropriate. It depends what you want to do but at a miniumum you need OS system calls for IO and memory allocation.

    如何与操作系统对话 - 这里的Mac程序集远不如Windows或Linux。您可能需要编写等效的C程序并使用'gcc -S'来查看哪些调用/堆栈恢复约定是合适的。这取决于你想要做什么但是在最低限度你需要OS系统调用IO和内存分配。

A good starting point is here.

这里有一个很好的起点。

#9


0  

If you've got Developer Tools installed, you can simply open Terminal and type as (GNU Assembler - part of Binutils).

如果你已经安装了Developer Tools,你只需打开Terminal并输入(GNU Assembler - Binutils的一部分)。

#10


0  

For PPC try Lightsoft

对于PPC尝试Lightsoft