writing a a program in machine code

Reply

Join Date: Jan 2007
Posts: 49
Reputation: Purple Avenger is an unknown quantity at this point 
Solved Threads: 0
Purple Avenger Purple Avenger is offline Offline
Light Poster

Re: writing a a program in machine code

 
0
  #11
Jan 28th, 2007
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.
Last edited by Purple Avenger; Jan 28th, 2007 at 12:27 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 8
Reputation: Garni is an unknown quantity at this point 
Solved Threads: 1
Garni Garni is offline Offline
Newbie Poster

Re: writing a a program in machine code

 
0
  #12
Apr 19th, 2007
Originally Posted by ang19 View Post
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 3
Reputation: JW1234 is an unknown quantity at this point 
Solved Threads: 0
JW1234 JW1234 is offline Offline
Newbie Poster

Re: writing a a program in machine code

 
0
  #13
Apr 9th, 2009
Originally Posted by ang19 View Post
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 3
Reputation: JW1234 is an unknown quantity at this point 
Solved Threads: 0
JW1234 JW1234 is offline Offline
Newbie Poster

Re: writing a a program in machine code

 
0
  #14
Apr 9th, 2009
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 !!!!!!!!!!!!)
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 921
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: writing a a program in machine code

 
0
  #15
Apr 10th, 2009
Lets take a look at a simple MASM32 program. Avoided invoke and macros for clarity.
  1. .386
  2. .model flat, stdcall
  3.  
  4. MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
  5. ExitProcess PROTO :DWORD
  6.  
  7. includelib \masm32\lib\user32.lib
  8. includelib \masm32\lib\kernel32.lib
  9.  
  10. .data
  11. msg_title db "Title", 0
  12. msg_str db "Text.", 0
  13.  
  14. .code
  15. start:
  16.  
  17. push 0
  18. push offset msg_title
  19. push offset msg_str
  20. push 0
  21. call MessageBoxA
  22.  
  23. push 0
  24. call ExitProcess
  25.  
  26. end start

A brief C version.
  1. #include <windows.h>
  2.  
  3. int main()
  4. {
  5. MessageBox(0, "Text.", "Title", MB_OK);
  6. return(0);
  7. }

Now, something you might see in a disassembler(@'s are xx's)
  1. 5469746C6500
  2. 546578742E00
  3.  
  4. 6A00
  5. 6800xxxxxx
  6. 6806xxxxxx
  7. 6A00
  8. E8xxxxxxxx
  9. 6A00
  10. E8xxxxxxxx
  11.  
  12. FF25xxxxxxxx
  13. 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.
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,529
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 190
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso

Re: writing a a program in machine code

 
0
  #16
Apr 10th, 2009
JW1234:

Binary code and machine code are the same thing.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC