与Mac OS X的64位处理器上运行32位汇编 [英] run 32 bit assembly on 64 bit processor with mac os x

查看:864
本文介绍了与Mac OS X的64位处理器上运行32位汇编的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的64位的Mac上运行OS X 10.9.5上运行32位汇编​​的一个问题。我也有NASM 08年11月2号安装。我目前正在读汇编语言一步一步由Jeff Duntemann。在这本书中,他规定了在Linux操作系统的32位汇编​​指令。我怎么能在我的64位Mac OS X的计算机上运行该程序。

I have a problem with running 32 bit assembly on my 64 bit mac running os x 10.9.5. I also have NASM 2.11.08 installed. I am currently reading Assembly Language Step by Step by Jeff Duntemann. In the book he specifies instructions for 32 bit assembly on a linux operating system. How can I run this program on my 64 bit mac os x computer.

; eatsyscall.asm

SECTION .data           ; Section containing initialised data
EatMsg: db "Eat at Joes!",10
EatLen: equ $-EatMsg    

SECTION .bss            ; Section containing uninitialized data 

SECTION .text           ; Section containing code

global  _start          ; Linker needs this to find the entry point!

_start:
    nop         ; This no-op keeps gdb happy...
    mov eax,4       ; Specify sys_write call
    mov ebx,1       ; Specify File Descriptor 1: Standard Output
    mov ecx,EatMsg      ; Pass offset of the message
    mov edx,EatLen      ; Pass the length of the message
    int 80H         ; Make kernel call

    MOV eax,1       ; Code for Exit Syscall
    mov ebx,0       ; Return a code of zero 
    int 80H         ; Make kernel call

我曾尝试与组装它

I have tried assembling it with

nasm -f elf -g -F stabs eatsyscall.asm

然后我尝试用

I then try to link it with

ld -o eatsyscall eatsyscall.o

但我得到这个错误

but I get this error

ld: warning: -arch not specified
ld: warning: -macosx_version_min not specified, assuming 10.6
ld: warning: ignoring file eatsyscall.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): eatsyscall.o
Undefined symbols for architecture x86_64:
  "start", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for inferred architecture x86_64

这应该运行,对吧?我认为,英特尔的64位处理器都能够运行32位程序的功能。或者是有没有办法运行32位Linux系统上的64位MAC写汇编程序?

This should run, right? I thought that Intel's 64 bit processors were capable of running 32 bit programs. Or is there no way to run an assembly program written for 32 bit linux systems on a 64 bit mac?

我是否需要安装一些一套32位的库能够链接这个文件?我应该使用的东西比其他NASM如GCC?或者是程序本身不正确写入。感谢您的帮助!

Do I need to install some set of 32 bit libraries to be able to link this file? Should I use something other than NASM such as GCC? Or is the program itself not written correctly. Thanks for the help!

推荐答案

将不会在Mac上,周期运行的可执行的Linux版本。在虚拟机上在Mac上安装Linux,如果你想运行杰夫Duntemann的东西。在code可以转化为 -f macho64 很容易,但有关于坏的错误,在NASM,08年2月11日(?) - ˚Fmacho64

An executable for Linux won't run on a Mac, period. Install Linux on a virtual machine on your Mac, if you want to run Jeff Duntemann's stuff. The code can be translated to -f macho64 fairly(?) easily, but there's a bad bug in Nasm-2.11.08 on -f macho64 :(

有一个候选发布版 - HTTP://www.nasm。美国/酒吧/ NASM / releasebuilds / 2.11.09rc1 / MacOSX的/ - 这可能修复它。有人需要对其进行测试。也许不适合初学者的好工作。您应该能够使用gcc与Mac,但不使用分步实施方案。 NASM将工作在Mac上......但不是现在......如果你可以安装Linux,现在是这样。

There's a release candidate - http://www.nasm.us/pub/nasm/releasebuilds/2.11.09rc1/macosx/ - which "may" fix it. Someone needs to test it. Perhaps not a good job for a beginner. You should be able to program using gcc with your Mac, but not using "Step by Step". Nasm will work on your Mac... but not right now... Install Linux if you can, for now.

这篇关于与Mac OS X的64位处理器上运行32位汇编的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆