Hi have one querery regarding writing in machine code,

address- instruction
00000 001 10000
00001 010 10000
00010 100 10000
00011 110 10001
00100 111 00000
10000 000 00001
10001 000 11111

i dont know how to write a program in machine code, which adds up to the numbers stored in cell 11000 11001, 11010 and stores the sum in cell 11011.

any help would be much appreciated angela

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.

Hi you can write the Machine Code. Instead of writing mnemonics you can write opcodes in asm files , like
db 0aeh ;equal to far jmp instructions. Hope this will help u...

If you are that much of a masochist, you would have to get hold of the technical reference manual(s) for your processor, and look up how assembly language instructions are encoded into machine code.

Short of writing an operating system for a brand new model of computer, without any possibility of cross assembly, I can't imagine why anybody would want to do it.

Do universities teach that any more? I thought writing programs in machine code went out in the early 1960s, before punch cards were invented.

There are valid reasons why someone would want to write a program in machine code, though I can't myself see why anyone would need to deal in binary. Anyhow, you can hand assemble code by swapping mneumonics with their opcodes, which are mainly giving in hex.

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

Only two I can think of
1) academic purposes

2) on obscure os that does not have an assembler

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.

Obviously debuggers and such need to do it when they implement the ability to alter code on the fly, and OS internals often do a bit of it when applying patches to known broken apps before allowing them to execute. DOS 5 and later for example, patch the in memory image of applications built with a buggy version of the Rational Systems DOS extender before giving them control.

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. :)

We had assemblers though. The SP0 wasn't all that obscure (in aerospace circles that is). Shuttle uses it, and the Navy's Harpoon missile is using them somewhere.

The DOS loader stuff isn't very obscure. Millions of copies of DOS 5 and later shipped.

Sometimes you simply can't get a commercial tool to produce what you need either. There's some hand assembled stuff in the guts of OS/2 because we couldn't get a compiler or assembler to spit out what was needed.

Hi have one querery regarding writing in machine code,

address- instruction
00000 001 10000
00001 010 10000
00010 100 10000
00011 110 10001
00100 111 00000
10000 000 00001
10001 000 11111

i dont know how to write a program in machine code, which adds up to the numbers stored in cell 11000 11001, 11010 and stores the sum in cell 11011.

any help would be much appreciated angela

for coding anything in machine code we need to stick to the processor what that is going to interpret the machine code. But still i have a doubt how u r going to run this file where u have the binaries. What is the OS u r going to rely up on. Make sure these things first.

OR u can do 1 thing, boot any system with ur own machine code. then dump this machine code in memory somewhere. Then move the processor registers like Iinstruction Pointers, Segment Register accourdingly. So that processor will start executing ur code. that all i can say 4 now.

thx,
Garni

Hi have one querery regarding writing in machine code,

address- instruction
00000 001 10000
00001 010 10000
00010 100 10000
00011 110 10001
00100 111 00000
10000 000 00001
10001 000 11111

i dont know how to write a program in machine code, which adds up to the numbers stored in cell 11000 11001, 11010 and stores the sum in cell 11011.

any help would be much appreciated angela

This is not machine code this is BIANRY it is what assembly code is turned into, you need to be looking at how to learn ASSEMBLY LANGUAGE.

This can be written using a simple text editor like notepad and then with a suitable compiler like MASM or similar can be converted into an OBJECT file, this is then linked with a linker to produce an EXECUTABLE file if it is larger than 64K or a COM file if it is smaller than 64K

Cheers John

This is what an 8086 assmebly language program looks like

.model small
.stack
.data
message db "Hello world, I'm learning Assembly !!!", "$"

.code

main proc <--- Start of program
mov ax,seg message <--- Message Seg to AX
mov ds,ax

mov ah,09 <--- I/O function
lea dx,message
int 21h <--- Execute & Return

mov ax,4c00h <--- Move 004Ch to register AX
int 21h <--- Execute Function & return
main endp
end main

John (no clues guessing what it does !!!!!!!!!!!!)

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.

notice how this problem didn't get solved,
knowledge of this kind has disappeared and if you want it you must look for it everywhere. but people spitting in your face and slandering your language of choice is a bit annoying.

First,
Determine exactly what this code does or is intended to do.

Re-write that application in a language that you do know-
Berkeley BASIC comes to mind
-since you say you don't want to use K&H.

Second,
Assemble your new code. -
THEN
With a good Hex editor such as MASM or TASM or the like,
Compare your new asmbly code with this older asmbly code

Do While:
Continue to revise your high(er) level language subrt'n
UNTIL: your new ASM code matches the old ASM code.

At this point you'll have
(1) An app which creates this piece of code,
(2) An app that you can read ! and modify ! for future changes.
(3) Some good tools in-which to work with,
and
(4) Some good knowledge of ...well,
of a lot of things ...

like - what to stay away from the next time.


Shift-Stop

Hi have one querery regarding writing in machine code,

address- instruction
00000 001 10000
00001 010 10000
00010 100 10000
00011 110 10001
00100 111 00000
10000 000 00001
10001 000 11111

i dont know how to write a program in machine code, which adds up to the numbers stored in cell 11000 11001, 11010 and stores the sum in cell 11011.

any help would be much appreciated angela

Edited 6 Years Ago by Shift-Stop: keyboard didn't spell what I wished

"is there a way to decompile windows xp without any programming experience or experteese"

You might be able to disassemble it with a program like IDA Pro, but there is virtually no way of recovering the C source code.

>>is there a way to decompile windows xp without any programming experience or experteese

That's like asking "is there any way to build a skyscraper with no prior construction or building experience?". The simple answer, of course, is "Yes there is -- hire someone who knows that he/she is doing." I'm not saying you can get C or C++ code from disassembly, only that dissembly is possible.

Edited 5 Years Ago by Ancient Dragon: n/a

Then you should have asked the question in a new thread, rather than raising a long dead one back up.

As for the answer to your question, the original C++ compiler was written in C, and most C++ compilers today are written in either C or C++. I gather, however, that your real question is, 'how did they write the first compilers without a compiler to use?' The answer is, they used assembly language and an assembler. But how was the first assembler written? Simple: it was written in assembly language, and then hand-assembled into some representation of machine code (in octal or hex or what-have-you).

However, that would have been a long time ago; by the mid-1960s, high-level languages were dominating the field, though machine code and assembly came into use again briefly when the first personal computers came on the scene circa 1974. Today, when a new model of CPU is made, the software for it is first written on some existing system, then cross-compiled to the new system. It is exceedly rare for anyone to do any machiine-code programming today.

"is there a way to decompile windows xp without any programming experience or experteese"

You might be able to disassemble it with a program like IDA Pro, but there is virtually no way of recovering the C source code.

There is always a way to do anything that has been done, it is just sometimes very difficult.

This article has been dead for over six months. Start a new discussion instead.