• Status: Solved
• Priority: Medium
• Security: Public
• Views: 269

# Encoding Assembly language Instruction

Bytes are arranged in order of increasing memory address and the H.O. byte of a constant always appears in the highest memory address..what does it mean?
0
• 5
• 3
1 Solution

Commented:
Obviously, I don't know the context, but the phrase means that the bytes of some object that is placed in memory will be arranged at increasing memory addresses. So, the first byte will be at address x, the second byte at address x+1, etc.

Furthermore, the high-order (H.O.) byte of a constant will always be at the highest memory address. So, for example, if a constant is 4 bytes long, and if it's stored at address x, then the high-order byte of the constant will be at address x+3, and the low-order byte at address x.

The high-order byte of a constant (integer) value is the byte that contains the highest order bits of the value. The highest order bits are the bits for the highest powers of 2. For example the binary value 100 (4 in decimal) has 1 as the high-order bit (the left-most bit).
0

Author Commented:
encoding y86 instructions
as per format, 8 bits are designated the following values
i       i     i         r       r      m    m     m
1    0     1       1       0     1      0      1

i i i   --   for add,sub...
r  r   --- destination bits 1 0 for cx
m m m --  source bits indexed address mode [xxxx+bx] is 101

so this is b5

since the instruction involves memory reference, extra 16 bits are also used to encode above ins.

the constant represented in the above indexing address mode is 2ff

that 2ff is represented using 16 bits that is 2 bytes by
ff,02 ....my boubt comes here.

1. why it is represented in reverse direction?
2. if it is in backward direction why is there a 0 in between?.it should not be just ff2?

as a whole the given ins is encoded as b5,ff,02..

0

Author Commented:
I understand the concept...
But i dont understand the reason for this arrangement
" Higher order byte of a constant will always be at the highest memory address"

Thank you so much...
0

Author Commented:
Got the point..neednot consider my recent question of why there is a 0 inbetween..
thank u ..just did not get the reason for this arrangement of bytes..
0

Commented:
>> just did not get the reason for this arrangement of bytes..

It's just a convention. A choice made in the design, for reasons of performance. If the low-order bits are in the lower addresses, that means they can be accessed more directly (most values will be small values anyway). It is also convenient for casting between integer types. For example, when casting from a 4 byte integer type to a 2 byte integer type, all that needs to be done is use the two low-order bytes, and they are right there, at the start address of the 4byte integer.
0

Author Commented:
sorry...i was not able to understand your point..

0

Commented:
Reading up on endianness should make things clearer. Here's a good start :

http://en.wikipedia.org/wiki/Endianness
0

Author Commented:
thank u...let me go through..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.