有人可以向我解释十六进制补偿吗?

时间:2022-05-08 01:27:46

I downloaded Hex Workshop, and I was told to read a .dbc file.

我下载了Hex Workshop,我被告知要读取.dbc文件。

It should contain 28,315 if you read offset 0x04 and 0x05

如果读取偏移量0x04和0x05,它应该包含28,315

I am unsure how to do this? What does 0x04 mean?

我不确定该怎么做? 0x04是什么意思?

6 个解决方案

#1


11  

0x04 is hex for 4 (the 0x is just a common prefix convention for base 16 representation of numbers - since many people think in decimal), and that would be the fourth byte (since they are saying offset, they probably count the first byte as byte 0, so offset 0x04 would be the 5th byte).

0x04是4的十六进制(0x只是数字的基数16表示的公共前缀约定 - 因为许多人认为是十进制),这将是第四个字节(因为它们说偏移量,它们可能将第一个字节计为字节0,所以偏移0x04将是第5个字节)。

I guess they are saying that the 4th and 5th byte together would be 28315, but did they say if this is little-endian or big-endian?

我猜他们说的是第4和第5个字节在一起是28315,但他们是否说这是小端还是大端?

28315 (decimal) is 0x6E9B in hexadecimal notation, probably in the file in order 0x9B 0x6E if it's little-endian.

28315(十进制)是十六进制表示的0x6E9B,如果它是little-endian,可能在文件中按顺序0x9B 0x6E。

Note: Little-endian and big-endian refer to the order bytes are written. Humans typical write decimal notation and hexadecimal in a big-endian way, so:

注意:Little-endian和big-endian指的是写入的顺序字节。人类通常以大端方式写十进制表示法和十六进制,所以:

256 would be written as 0x0100 (digits on the left are the biggest scale)

256将被写为0x0100(左边的数字是最大的比例)

But that takes two bytes and little-endian systems will write the low byte first: 0x00 0x01. Big-endian systems will write the high-byte first: 0x01 0x00.

但这需要两个字节,而小端系统将首先写入低字节:0x00 0x01。 Big-endian系统将首先写入高字节:0x01 0x00。

Typically Intel systems are little-endian and other systems vary.

通常,英特尔系统是小端的,其他系统也各不相同。

#2


2  

It's the 4th and the 5th XX code your viewing...

这是你观看的第4和第5个XX代码......

1   2  3  4  5  6
01  AB 11 7B FF 5A

So, the 0x04 and 0x05 is "7B" and "FF".

因此,0x04和0x05是“7B”和“FF”。

Assuming what you're saying, in your case 7BFF should be equal to your desired value.

假设你在说什么,在你的情况下,7BFF应该等于你想要的值。

HTH

#3


2  

Think of a binary file as a linear array of bytes.

将二进制文件视为线性字节数组。

0x04 would be the 5th (in a 0 based array) element in the array, and 0x05 would be the 6th.

0x04将是数组中的第5个(在基于0的数组中)元素,0x05将是第6个元素。

The two values in 0x04 and 0x05 can be OR'ed together to create the number 28,315.

0x04和0x05中的两个值可以一起进行“或”运算,以创建数字28,315。

Since the value you are reading is 16 bit, you need to bitshift one value over and then OR them together, ie if you were manipulating the file in c#, you would use something like this:

由于您正在读取的值是16位,您需要将一个值进行位移,然后将它们组合在一起,即如果您在c#中操作该文件,则可以使用以下内容:

int value = (ByteArray[4] >> 8) | ByteArray[5]);

Hopefully this helps explain how hex addresses work.

希望这有助于解释十六进制地址的工作原理。

#4


1  

0x04 in hex is 4 in decimal. 0x10 in hex is 16 in decimal. calc.exe can convert between hex and decimal for you.

十六进制中的0x04是十进制的4。十六进制中的0x10是十进制的16。 calc.exe可以为您转换十六进制和十进制。

Offset 4 means 4 bytes from the start of the file. Offset 0 is the first byte in the file.

偏移4表示文件开头的4个字节。偏移0是文件中的第一个字节。

#5


1  

Look at bytes 4 and five they should have the values 0x6E 0x9B (or 0x9B 0x6E) depending on your endianess.

查看字节4和5,它们应具有值0x6E 0x9B(或0x9B 0x6E),具体取决于您的字节顺序。

#6


0  

Start here. Once you learn how to read hexadecimal values, you'll be in much better shape to actually solve your problem.

从这里开始。一旦你学会了如何读取十六进制值,你就会更好地解决你的问题。

#1


11  

0x04 is hex for 4 (the 0x is just a common prefix convention for base 16 representation of numbers - since many people think in decimal), and that would be the fourth byte (since they are saying offset, they probably count the first byte as byte 0, so offset 0x04 would be the 5th byte).

0x04是4的十六进制(0x只是数字的基数16表示的公共前缀约定 - 因为许多人认为是十进制),这将是第四个字节(因为它们说偏移量,它们可能将第一个字节计为字节0,所以偏移0x04将是第5个字节)。

I guess they are saying that the 4th and 5th byte together would be 28315, but did they say if this is little-endian or big-endian?

我猜他们说的是第4和第5个字节在一起是28315,但他们是否说这是小端还是大端?

28315 (decimal) is 0x6E9B in hexadecimal notation, probably in the file in order 0x9B 0x6E if it's little-endian.

28315(十进制)是十六进制表示的0x6E9B,如果它是little-endian,可能在文件中按顺序0x9B 0x6E。

Note: Little-endian and big-endian refer to the order bytes are written. Humans typical write decimal notation and hexadecimal in a big-endian way, so:

注意:Little-endian和big-endian指的是写入的顺序字节。人类通常以大端方式写十进制表示法和十六进制,所以:

256 would be written as 0x0100 (digits on the left are the biggest scale)

256将被写为0x0100(左边的数字是最大的比例)

But that takes two bytes and little-endian systems will write the low byte first: 0x00 0x01. Big-endian systems will write the high-byte first: 0x01 0x00.

但这需要两个字节,而小端系统将首先写入低字节:0x00 0x01。 Big-endian系统将首先写入高字节:0x01 0x00。

Typically Intel systems are little-endian and other systems vary.

通常,英特尔系统是小端的,其他系统也各不相同。

#2


2  

It's the 4th and the 5th XX code your viewing...

这是你观看的第4和第5个XX代码......

1   2  3  4  5  6
01  AB 11 7B FF 5A

So, the 0x04 and 0x05 is "7B" and "FF".

因此,0x04和0x05是“7B”和“FF”。

Assuming what you're saying, in your case 7BFF should be equal to your desired value.

假设你在说什么,在你的情况下,7BFF应该等于你想要的值。

HTH

#3


2  

Think of a binary file as a linear array of bytes.

将二进制文件视为线性字节数组。

0x04 would be the 5th (in a 0 based array) element in the array, and 0x05 would be the 6th.

0x04将是数组中的第5个(在基于0的数组中)元素,0x05将是第6个元素。

The two values in 0x04 and 0x05 can be OR'ed together to create the number 28,315.

0x04和0x05中的两个值可以一起进行“或”运算,以创建数字28,315。

Since the value you are reading is 16 bit, you need to bitshift one value over and then OR them together, ie if you were manipulating the file in c#, you would use something like this:

由于您正在读取的值是16位,您需要将一个值进行位移,然后将它们组合在一起,即如果您在c#中操作该文件,则可以使用以下内容:

int value = (ByteArray[4] >> 8) | ByteArray[5]);

Hopefully this helps explain how hex addresses work.

希望这有助于解释十六进制地址的工作原理。

#4


1  

0x04 in hex is 4 in decimal. 0x10 in hex is 16 in decimal. calc.exe can convert between hex and decimal for you.

十六进制中的0x04是十进制的4。十六进制中的0x10是十进制的16。 calc.exe可以为您转换十六进制和十进制。

Offset 4 means 4 bytes from the start of the file. Offset 0 is the first byte in the file.

偏移4表示文件开头的4个字节。偏移0是文件中的第一个字节。

#5


1  

Look at bytes 4 and five they should have the values 0x6E 0x9B (or 0x9B 0x6E) depending on your endianess.

查看字节4和5,它们应具有值0x6E 0x9B(或0x9B 0x6E),具体取决于您的字节顺序。

#6


0  

Start here. Once you learn how to read hexadecimal values, you'll be in much better shape to actually solve your problem.

从这里开始。一旦你学会了如何读取十六进制值,你就会更好地解决你的问题。