x86 Assembly on Mac OS X 156
Quicksilver31337 asks: "I am currently taking an Assembly course which requires that I be able to compile ASM for the intel x86; however, I am stubbornly a Mac user. Having no desire to switch from my Powerbook, what can I do to work with, compile, and run x86 ASM short of running VirtualPC?" While Mac OS X does use gcc and its associated tool-chain, an old Slashdot discussion seems to imply that cross-compiling is better under OpenDarwin than Mac OS X. Has anyone tried cross-compiling under both operating systems? If so, what suggestions on setting up a working tool-chain do you have?
DOSBox + NASM (Score:5, Informative)
Re:DOSBox + NASM (Score:5, Informative)
Re:DOSBox + NASM (Score:2, Informative)
Emulation or new hardware... (Score:5, Insightful)
My advice is go to a computer show, buy an old, fully-functional 386, 486, or Pentium based machine, and install either DOS or Linux or *BSD. You could probably get one for less than $50.
Choice... (Score:5, Insightful)
Re:Choice... (Score:5, Informative)
http://www.testdrive.hp.com/ [hp.com]
Re:Choice... (Score:2)
Sourceforge [sourceforge.net] sort of falls into this last category -- and their toolset is unsurpassed. Unfortunately, you can't just pay a fee and an account. You have to come up with
ummm yeah .. (Score:2, Interesting)
not the best suggestion so far, i think. you know how easy it is to crash x86 with assembly?
what i do: use VirtualPC. like the article submitter, i am 100% devoted to my powerbook
Re:ummm yeah .. (Score:2, Informative)
It's true enough that it's easy to write a program that crashes in assembler, but that's true of any other language, too.
If the OP is wri
Re:ummm yeah .. (Score:2)
Re:ummm yeah .. (Score:2)
So basically, trivial. Fork bombs used to capture as much imagination as beowulf clusters today and only faded with dominance of Windows, which is too easily crashed to be a challenge. They may yet bring down Linux/*BSD if maximum allowed processes really work on consuming system resources, such as disk bandwidth.
Anyway, assembly will come in handy in selecting uninterruptible instructions that take the most clock cycles or generate faults which take a whil
Re:Emulation or new hardware... (Score:1)
Re:Emulation or new hardware... (Score:2)
Re:Emulation or new hardware... (Score:2)
Since he is learning ASM, would a 486 or early pentium be "fast enough"?
If so, why not try hitting a local thrift store and looking what they have -- keep the receipt as well for your taxes.
When you are done with it, throw on a lightweight linux distro and donate it back to them. :)
Re:Emulation or new hardware... (Score:2)
And if like me you were a poor student whose landlord would not turn the heat above 50, you can set up a beowolf cluster of old 386s and 486s to make c
Re:Emulation or new hardware... (Score:5, Insightful)
Going to school is supposed to broaden your horizons (or in more mercenary terms: build up your resume), and that's not going to happen if you cling to your PowerBook like a life preserver. In my college years in the neolithic period I got exposed to TRS-80s (Z80 assembly), IBM PCs, DEC VAXen, a *nix box of some kind, and the C64 in my dorm room, and that diversity of experience made me a better geek... the kind who today is comfortable with OS X, MacOS, Windows, Linux, BSD, BeOS, EPOC, PalmOS, and just about anything else I might find in front of me.
Look, eventually your architecture of choice is going to die off or fade into irrelevancy. (And I'm not saying that because it's an Apple; they'll probably be around in 20 years, but they won't still be using OS X on PPC). You'll have to adapt. So you might as well start making yourself cross-platform now, before you end up as just a one-trick pony.
Re:Emulation or new hardware... (Score:2)
Re:Emulation or new hardware... (Score:2)
Well... (Score:3, Informative)
Re:Well... (Score:2, Interesting)
Don't (Score:5, Insightful)
Re:Don't (Score:2)
Emulation and ASM (Score:2, Insightful)
I'd say ask the professor what he/she thinks of using Bochs first. If they aren't totally against it, it should be fine. Freshman year, it felt like I was the only one in my CS course with linux at home, but
Re:Emulation and ASM (Score:3, Insightful)
Re:Emulation and ASM (Score:2)
Re:Emulation and ASM (Score:2)
--jeff++
Re:Emulation and ASM (Score:2)
I'm so sorry. XSPIM / PCSPIM are really crappy to work with. Friends of mine are currently in our MIPS course, and I hear non-stop bitching about it. There's been discussions about potentially writing a replacement for it, but I don't know how fruitful they will be.
Re:Don't (Score:2)
Depending one what he's supposed to do, there is always free shell accounts [ductape.net] under unix/linux which may work.
Horse nuggets. (Score:5, Informative)
Bochs is every bit as real an implementation of the x86 as a Pentium 4. In the outrageously unlikely event that bochs doesn't run this guy's assembly code correctly, he should report a bug, just as he would do in the even more outrageously unlikely event that an Intel processor runs his code wrong.
Re:Horse nuggets. (Score:2)
Re:Don't (Score:1, Funny)
Re:Don't (Score:3, Interesting)
"Half of learning assembly is testing it out on a *live* machine. You're not learning assembly if you're just using cross-assembling, and you're not *really* learning it if you're emulating."
In a word: wrong. In many ways.
First, emulation is *more* useful because more data can be (potentially) gathered during runs.
Second, being forced to cycle a power switch is "educational"?
Third, the student will *not* be required to know the COMPLETE ins-and-outs of the hardware (eg, register level access to
Re:Don't (Score:2)
And, if you do run QEMU or BOCHS, you can run the tool-chain for x86 there as well (QEMU would be preferred, because the tools will simply integrate into the command-line and `make' correctly).
You could share the disk image between QEMU and bochs too; build and test with QEMU and then restart the image with Bochs if you need the debugging features that Bochs offers.
Re:Don't (Score:2)
I know of at least 5 major Universities that do MIPS for the majority of there assembly situations and they certainly don't have there students find MIPS machines. I know of others that use processors that don't even really exist in real hardware but have instruction sets similar to MIPS.
Whether you run the assembly on the target architecture or in an emulator means absolutely nothing. All that matters is you understand how to use the instructions availible to you in an eff
VPC is fine (Score:3, Informative)
Re:VPC is fine (Score:2)
Try this (Score:1)
and
NASM [sourceforge.net]
Re:Try this (Score:3, Informative)
Wine - Wine Is Not an Emulator.
(it doesn't interpret the x86 instructions , i.e. it works on x86 only)
--
My stuff [homelinux.org]
Re:Try this (Score:2)
The short answer is 'probably never'. Remember, Wine Is Not a (CPU) Emulator. The long answer is that we probably don't want or need to integrate one in the traditional sense.
Integrating a CPU emulator in Wine would be extremely hard, due to the large number of Windows APIs and the complex data types they exchange. It is not uncommon for a Windows API to take three or more pointers to structures compos
bochs (Score:2, Interesting)
-Erik
Your only option (Score:3, Informative)
I'm not sure I understand the question (Score:2)
Re:I'm not sure I understand the question (Score:2)
No, he doesn't want to cave in and spend the $ on Virtual PC license. Let me paraphrase what he is saying.
I love Mac's!! I ain't gonna spend $$$ on Virtual PC, and I sure as hell ain't letting a standard beige box invade my kingdom. What are my options for compiling and testing my assembly code for the x86?
Re:I'm not sure I understand the question (Score:3, Insightful)
I feel sorry for the guy, even if he is a Mac bigot. I got to do my assembly programming class on a Vax, which is practically as easy as writing in C.
Re:I'm not sure I understand the question (Score:2)
It Isn't Worth It (Score:4, Insightful)
I hate using anything other than my PowerBook these days, but I honestly can't see any good arguments for not just sucking it up and working with the most appropriate hardware for the task.
Re:It Isn't Worth It (Score:1)
Talk to your professor (Score:1)
Talk to your professor, that's what they're there for! I'm sure they've had other students who either didn't have computers or had Macs like yourself.
Some sound advice has already been given.. (Score:4, Interesting)
QEMU (Score:2, Insightful)
Re:QEMU (Score:2)
The complete solution (Score:1)
Re:The complete solution (Score:2)
Wine Is Not an Emulator.
Re:The complete solution (Score:2)
Qemu. (Score:5, Interesting)
Now, what I would suggest you do is get a copy of QEMU [bellard.free.fr]. I assume you are familiar enough with Terminal and the shell prompt to get it working since you're stepping into the world of assembly, but if all else fails you can get QemuX or some other QEMU GUI off of VersionTracker [versiontracker.com].
Depending on what mode you're writing your assembly in, you'll need to install some sort of OS into QEMU. Some candidates are FreeDOS, MS-DOS, or even Linux. Use whatever your class is using. Emulators are very handy for writing assembly because you can debug the program at the "CPU" level, so when your program pukes you can get a better glimpse at what is going on. This is why many developers design inside of VMWare.
I hope this helps!
Re:Qemu. (Score:3, Informative)
what? of course you can cross-compile assembly. assembly is just another language - you can teach any computer that language.
as86/bin86 can be compiled under OSX. write your code on your powerbook, compile, send it to a real PC for testing/running
Re:Qemu. (Score:1)
Re:Qemu. (Score:2)
Re:Qemu. (Score:2)
Re:Qemu. (Score:2)
Nonsense. Cross-compiling is when the host machine - i.e. the one running the compiler - is of a different architecture than the target. That's all. Whether or not the source language is portable to a different target is completely irrelevant.
Use Virtual PC (Score:3, Informative)
I've tried Virtual PC (Score:1)
You want QEMU! (Score:5, Informative)
Then download a x86 Linux Live CD ISO, for example Knoppix [knoppix.org].
Then:
$ qemu -cdrom knoppix.iso -boot d
Simple as that. Networking will work out of the box.
You can also install Debian on a virtual harddrive using:
$ dd if=/dev/zero of=sarge.hdimage bs=1000000 count=2000
$ qemu -hda sarge.hdimage -cdrom debian-netinst.iso -boot d
When installed, start QEmu with:
$ qemu -hda sarge.hdimage
Even better, after installation, copy the kernel and the initrd to your Mac (using sftp) and start qemu with:
$ qemu -hda sarge.hdimage -kernel kernel-file -initrd initrd-file -append "root=/dev/hda1 console=ttyS0,38600" -nographics
Then you will get the console on a virtual serial port (which is your current terminal window) and it doesn't have to emulate any graphics at all.
Re:You want QEMU! (Score:2)
Re:You want QEMU! (Score:2)
If you install another dist you'll have to copy the line that says 1:blabla/bin/gettyblabla and replace the 1: by S0:
Also verify that
Cross compiling to what? (Score:2)
QEMU does well... (Score:1, Informative)
AC
Here's my advice, you may hear lots similar (Score:5, Funny)
Dear Auntie Slashdot,
I'm going on a course to learn how to stab people. But I don't like knives, nasty sharp things, I much prefer my sock full of spagetti. Can you suggest a way I can stab people with a sock full of pasta?
Also, I don't want to ride a bicycle, any way I can learn how to ride one while on a train?
etc. etc.
bochs (Score:2)
I've personally done ARM cross compiling with GCC on an x86, and I found the experience to be torture. cross compiling sucks when you have to set up the compiler and environment yourself. Maybe it works the first time, but as soon as you have a problem, it's just h
qemu (Score:4, Informative)
virtualPC, bochs, qemu, all fine (Score:5, Informative)
Your prof sincerely will NOT CARE that you used virtualPC or whatever, as long as you did the assignment. He WILL care if you're some whiny fanboy who can't stop moaning about how kludgy and crocky the x86 architecture is and how you sing love songs to your powerpc mac every night and how you had to condescend to use an emulator only IF this dinosaur of a professor who stoops so low to use this architecture might deign to look up to your lofty height and permit you to use an emulator blah blah. Just use the damn emulator and hand in the assignment. Chances are he won't notice, and if he does, then go buy a cheap old PC and get on with life.
GCC? (Score:2, Informative)
And what does that have to do with the price of tea in china?
We're talking about Assembly here...you wouldn't use gcc.. you'd use GAS (which is awful).
NASM will compile on OSX, but it uses AT&T syntax, rather than intel syntax.
Odds are good that you're going to be learning Intel syntax.
AT&T syntax: movl %eax, %ebx
Intel syntax:
Maybe I'm being too simple ... (Score:2, Informative)
If this is for school (Score:2)
Do what Mac Zealots have always done... (Score:5, Funny)
Re:Do what Mac Zealots have always done... (Score:2, Interesting)
Re:Do what Mac Zealots have always done... (Score:2)
Re:Do what Mac Zealots have always done... (Score:2)
Or even if it doesn't net any extra credit, there's still the purely academic reasons for doing so. That is why people go to university right? To learn? In the last year, I've done assignments for courses I couldn't take because of scheduling, purely for the enjoyment of doing it.
Re:Do what Mac Zealots have always done... (Score:2)
Re:Do what Mac Zealots have always done... (Score:2)
Code the assignment in PPC assembly and hand that in. And insist PPC is a superior architecture to code for...
[sigh] Surely I'm not the only one who remembers back when Macs ran on 68K CPUs?
Cross compiling won't help (Score:2)
I'd be shocked if your uni didn't have an x86 machine that you can SSH to. Easiest to just use that.
Re: "I am stubbornly a Mac user" (Score:2, Insightful)
I know quite a few engineers who used to work at Apple, and decided OS X wasn't a "Macintosh." Apple had other ideas. They're now writing Windows code.
I think the native platform for x86 is the best choice for x86 development. If you can't figure out how to use it, you have no reason to be studying software.
remote connection (Score:1, Insightful)
Linux/x86 or even Darwin/x86 (Score:2)
Re:Linux/x86 or even Darwin/x86 (Score:2)
Don't use vnc, use ssh and X11, both of which are supported by default by OSX and will integrate much better with the local os. An ssh session to a remote unix box will behave just like a local session with the OSX console app, and X11 apps will get managed by the OSX window manager, but diehard mac users may find it strange that the menu is at the top of the window.. Other than that, it works well. VNC on the other hand will give you one large monolithic window containing a whole window manager a
Reminds me of a letter I once read... (Score:3, Funny)
I need to build a brick fireplace but I am a fervent hammer user. I realize that a hammer might not be the right tool to lay down the mortar, but I believe very strongly in the hammer and believe that ultimately, the trowel is an inferior tool designed only for trogladytes and people who actually know the definition of "trogladytes." What is the best way to use my hammer to accomplish my goal?
Signed,
Go Hammer, Go Hammer Go
Qemu or BOCHS (Score:2)
Have gcc 3.3.2 win32 cross compiler (Score:4, Informative)
I use both gcc and CodeWarrior, and generally haven't had any problems with either.
I have OS X binaries for Win32 gcc 3.3.2 compilation (using mingw32) available here as a torrent [annodominari.com]
My assembly course (Score:5, Interesting)
Computer lab (Score:2)
Emulators/Simulators (Score:2)
An interesting piece of information for all the raving zealots on both sides of the argument to note: the first AMD64 (Opteron/Athlon 64) port of Linux was done on a software simulator, before any hardware was available.
Software isn't a bad choice, especially nowadays with good free emulators such as bochs. The kind of things you'll be doing for a cl
obvious (Score:2)
what am i missing? the answer is so obvious.
When I went back to college... (Score:2)
I used SoftPC (remember that?) and it all went just fine. Using emulation software to complete these sorts of courses was often better than doing it natively: I could run the DOS applications i
Re:You don't understand the problem (Score:1)
Re:You don't understand the problem (Score:2, Informative)
Your response:
* ignores the posters question.
* offers no insight
* offers no work-arounds or solutions
* doesn't explain anything at all
* serves only to put the poster beneath you.
Sounds like flamebait to me...
An emulator is perfectly fine for a class. He could also get a shell account (http://www.testdrive.hp.com/ [hp.com]). He could pick up a cheap x86 box. Etc.
But you fail to mention any of these and prefer instead to insult th
Re:You don't understand the problem (Score:3, Informative)
Re:You don't understand the problem (Score:2)
In being so dismissive of his capabilities and potential to improve those capabilities, you've not simply sounded like a troll
Re:You don't understand the problem (Score:5, Insightful)
I'm a professional developers working for a manufacturer of precision instrumentation. I don't see any problems with what he's trying to do. Although, he'd be wise to test it on real hardware before giving it to the prof...
Re:You don't understand the problem (Score:2)
There's no need for him to buy or work on an x86. I don't work on a PIC or AVR; but I write and test PIC and AVR code. I may not have real hardware to test against for months w
Re:You don't understand the problem (Score:3, Informative)