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

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
msivask1
Asked:
msivask1
  • 5
  • 3
1 Solution
 
Infinity08Commented:
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
 
msivask1Author Commented:
encoding y86 instructions
add( [2ff+bx], cx )
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
 
msivask1Author 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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
msivask1Author 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
 
Infinity08Commented:
>> 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
 
msivask1Author Commented:
sorry...i was not able to understand your point..

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

        http://en.wikipedia.org/wiki/Endianness
0
 
msivask1Author 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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now