i have one question. why would you want to write a program in machine code? I mean now with such advanced programming languages from c++ to even java is there any point to learning java.
mikeandike22
Nearly a Posting Virtuoso
1,496 posts since May 2004
Reputation Points: 33
Solved Threads: 19
Do universities teach that any more? I thought writing programs in machine code went out in the early 1960s, before punch cards were invented.
Ancient Dragon
Retired & Loving It
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
my dad used punchcards still at uni during the late 70's lol
jbennet
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,820
Solved Threads: 600
There are valid reasons why someone would want to write a program in machine code
Only two I can think of
1) academic purposes
2) on obscure os that does not have an assembler
Ancient Dragon
Retired & Loving It
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
Patches are frequently applied in machine code. NASA's procurement process for Space Shuttle flight software had the vendor providing a "signed off" image. Subsequent fixes after image sign off were applied as machine code patches. I had 20 words of patch space to work with in the Shuttle's SP0 cockpit display processor. Split 8 here and 12 over there. A reassemply/recertification of the load image to collect them up together was too economically painful to think about. We did hex patches.
You proved my second reason (obscure os) -- not many people have the opportunity to program for a space shuttle. :)
Ancient Dragon
Retired & Loving It
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
Lets take a look at a simple MASM32 program. Avoided invoke and macros for clarity.
.386
.model flat, stdcall
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
ExitProcess PROTO :DWORD
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.data
msg_title db "Title", 0
msg_str db "Text.", 0
.code
start:
push 0
push offset msg_title
push offset msg_str
push 0
call MessageBoxA
push 0
call ExitProcess
end start
A brief C version.
#include <windows.h>
int main()
{
MessageBox(0, "Text.", "Title", MB_OK);
return(0);
}
Now, something you might see in a disassembler(@'s are xx's)
5469746C6500
546578742E00
6A00
6800xxxxxx
6806xxxxxx
6A00
E8xxxxxxxx
6A00
E8xxxxxxxx
FF25xxxxxxxx
FF25xxxxxxxx
That right there would be 427 ones and zeros, not including another KB of padding, headers, and tables. So unless you're one hardcore programmer, coding in machine code is beyond the scope of convention.
P.S. No one uses binary while dealing with op-codes.
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116
JW1234:
Binary code and machine code are the same thing.
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354