1
\$\begingroup\$

What does #high(434) actually mean I know it is some value but how do you compute the value when I debug the command mov r7,#high(434) I get 1 in register 7 why ?

\$\endgroup\$
1
  • \$\begingroup\$ It means "the high byte of the 16 bit value 434". This is 434/256 == 1. \$\endgroup\$
    – Janka
    Commented Oct 26, 2017 at 12:53

1 Answer 1

5
\$\begingroup\$

You mention 8051, which is a 8 bit machine. 8 bits can directly express values from -128 to +127 when signed, and 0 to 255 when unsigned.

Sometimes you want to use multiple bytes to store numbers outside this range. However, the machine still only works on one byte at a time. The #high (and presumably #low) functions give you the individual byte values of a 16 bit number.

In your example, you are working with the number 434. That is 1B2 in hexadecimal. To store that in two bytes, the high byte is set to 1, and the low byte to B2h (= 178 decimal). The #high function returns the high byte value, so 1.

As another example, consider #high(22135). 22135 = 5677h. The high byte value is 56h = 86, and the low byte 77h = 119. #high(22135) would therefore return 86.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.