pgmfi.org

Hacking up Honda's ECU
It is currently Mon Dec 09, 2024 4:54 pm

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Nov 29, 2005 2:00 pm 
Offline

Joined: Tue Jul 27, 2004 2:29 am
Posts: 474
Location: Baton Rouge, LA
Ok, this may seem like a stupid question, but I am going to ask it anyway. I'm reading this book on RISC assembly right now, and in the first few pages it mentions that there is usually a one to one relationship between assembly and machine code. If that is the case, then theoretically, making a universal dissassembler should be as easy as reading in the machine code and breaking it into characters instead of 1's and 0's. There is probably a really simple reason why this doesn't work. I just need somebody to clarify.

--Darren


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 29, 2005 3:23 pm 
Offline
Senior Developer

Joined: Tue Jul 27, 2004 2:21 am
Posts: 677
Location: New Jersey
Machine code is relative to the processor being used, so each processor has a different set of codes. For example 03 means jump in OKI processors, it means something else for other processors.

If know all the instructions by heart, you can write code entirely in machine language. For example if you want to jump to byte 4020h on the code you can simply write 032040h on an OKI processor.

The advantage of having assembly language is that it is simply nicer to read. When you compare 032040h to J 04020h, it's easier to tell right away that we mean a jump instruction with the second one.

When they say assembly language and machine code have a "one-to-one" relation it just means that when you break down an assembly code, one line of code equals one instruction of machine code. While in higher level languages, it's not necessarily so.

Here's a code in C
Code:
If (a > b) c = a;
Else c = b;

Now here's how it translates in Assembly (my x86 assembly is not so good)
Code:
MOV A, EAX
MOV B, EBX
MOV EAX, C
CMP EAX, EBX
JA NEXT
MOV EBX, C
NEXT:
...


As you can see when translated to assembly, 2 lines of C code can mean many lines of assembly code. However, every line of assembly code is one instruction of machine code.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 29, 2005 9:00 pm 
Offline

Joined: Tue Jul 27, 2004 2:29 am
Posts: 474
Location: Baton Rouge, LA
John, you are the man.

Ok, so machine code is not completely 1's and 0's. As you stated, 03 would be acceptable machine code. So would it be safe to say that there is actually a level lower than machine code where that 03 would be represented by say 011? Is that even relevant at this point?

I'm just trying to get a deeper understanding for how this works. As you may or may not know I'm trying to get into this 05 Accord ECU and I want to understand what I am dealing with once I find a way to get the rom off of it.

Speaking of which, if anybody has any clues as to how to pull a rom off this Hitachi chip, I'm all ears.

--Darren


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 19, 2005 8:47 pm 
Offline

Joined: Tue Jul 27, 2004 3:01 am
Posts: 2945
Location: Tampa bay, Florida
When he used 03, he was referring to the HEX value of the Binary number used in machine code. Just like using asm is easier to understand than using machine code.. it is easier to interpret the value 0x03 rather than 00000011.b There is still a one to one translation from binary to hex


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 20, 2005 2:18 am 
Offline

Joined: Tue Jul 27, 2004 2:29 am
Posts: 474
Location: Baton Rouge, LA
Interesting. I started reading up on how this is done in my pic chip book, aswell as that book I borrowed about RISC chips. I figured out what it means when somebody says, "My computer has a 64-bit chip"

Apparently that means that the chip can understand an instruction with 64 1's and 0's. The implications of that could mean that there would need to be less instructions needed to do the same thing on that chip. Also, I was talking to a buddy of mine and he hypothesized that that could also be why those chips support more than 4 gb of memory, unlike the 32-bit chips we're used to working with. Because the more memory you have, the longer the address, and the entire address probably can't fit into a 32-bit instruction if you are trying to have more that 4gb of memory.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 20, 2005 2:30 am 
Offline

Joined: Tue Mar 22, 2005 9:26 pm
Posts: 260
Addressing is different than instructions. The bit size the processor is, is the instruction size. You have that part right. Addressing is done through a different logic block. So instructuction size of the processor can be different from the addressing bits.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 20, 2005 3:31 am 
Offline

Joined: Tue Jul 27, 2004 2:29 am
Posts: 474
Location: Baton Rouge, LA
The way I understood it was, lets say you wanted to move a literal value to a certain register. On a pic chip you would do something like

movlw b'11111111'
movwf PORTB

Since its a 14-bit chip, when you move w to PORTB which defined as like 85h, the first 4 bits of the instruction were the movlw part, lets say movlw is 03h, in binary we're looking at 0011 followed by the 85h in binary: 10000101

so the command would be

001110000101

but that's only 12 bits....

ok I don't have the book in front of me, but as far as I understood, there are only like 20 commands for a 16f84a pic chips, so I don't see the need for than say 5 bits for the instruction.

If the 64-bit thing was only for the instruction and didn't include the address, then theoretically a 64-bit chip can have 18446744073709551615 instructions.

I would tend to think that maybe only the first 8 bits of that determines the instruction and the rest of it determines the parameters of that instruction, ie what memory address is being copied to what other memory address. If only 8 bits are used for the instruction, that leaves you open for 255 instructions, which would seem about right.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 20, 2005 4:21 am 
Offline

Joined: Tue Mar 22, 2005 9:26 pm
Posts: 260
Here this will help you out perfectly.

http://en.wikipedia.org/wiki/64-bit


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group