what do I need to start writing in machine language?

angel picture angel · Aug 28, 2011 · Viewed 8k times · Source

I want to start learning the machine language, you know the 0010011 type language. What program if any, can I use to write in machine language? please, I know you guys are going to tell me that "there are better languages out there or why would you want to learn that" kind of comments. I am aware of that so please don't post any of those comments. thanks.

Answer

Pete Wilson picture Pete Wilson · Aug 28, 2011

Bravo! I'm an old-time, long-time ASM programmer and the last one to sneer at your very worthy project. I still know that the Z-80 opcode for CALL is really 0xC9 (or, as you might put it, 1100 1001). In my opinion, you will benefit from the exercise.

I propose, though, that instead of starting with bits you start with assembly code. Then, when you get comfortable, it's a quick shift to machine language. You can do this easily with any version of Visual Studio and, I'd think, with any reasonable IDE.

EDIT So sorry: I should have said "any version of Visual Studio that compiles your program into machine code," meaning at least VS for C/C++. I know less than nothing about C#, but I have the impression that the C# compiler emits a translated version of your code in something called "Intermediate Language" (IL). Therefore (as I read it) there's no clean way to include assembly-language source code in a C# source program. There's a discussion of how to call a DLL from a C# program here:

http://www.codeproject.com/KB/cs/unmanage.aspx

Your easiest and best bet (maybe your only bet) is to install Visual Studio Express for C/C++ and then to explore the use of the .asm directive:

http://msdn.microsoft.com/en-us/library/aa258994%28v=vs.60%29.aspx .

Stick with the C language; ignore the C++ language for now. You'll have to learn enough C to input, compile, and run a small C-language demo program (by convention and history this is a program called hello.c that you can find anyplace). Then you can insert a section of .asm and work with the debugger to experiment with that section.

Yes, I said you'd benefit from the exercise, but I didn't say it would be easy -- it's difficult: you have to learn a lot about what's under the hood. The subject could reasonably be a one-semester course.

But you can do it, with persistence over time. That is precisely where the benefit lies.

Go for it!