|
Example 1:
int a;
float b;
a + b
Results in:
1. Convert a to a float representation
2. Add the 2 float values
|
Example 2:
short a;
int b;
a + b
Results in:
1. Convert a to an int (64 bits) representation
2. Add the 2 int values
|
byte (1 byte integer (whole number) representation for values between -127..128) short (2 byte integer (whole number) representation for values between -32767..32768) int (4 byte integer (whole number) representation) |
|
The value 3 (three dots) is represented as follows: As byte type using 1 byte (8 bits): 00000011 As short type using 2 bytes (16 bits): 0000000000000011 As int type using 4 bytes (32 bits): 00000000000000000000000000000011 |
The value -3 is represented as follows: As byte type using 1 byte (8 bits): 11111101 As short type using 2 bytes (16 bits): 1111111111111101 As int type using 4 bytes (32 bits): 11111111111111111111111111111101 |
|
Example:
The representation of the value 3 in 8 bits is: 00000011 When we convert this 8 bit representaion into a 16 bit representation, the result is: 0000000000000011 Because: The binary number represents the (same) value 3 !!! |
|
|
|
|
is called:
|
|
EXT.W Dn Converts an 8-bits 2's complement representation in reg Dn to a 16 bits 2's complement representation (in reg Dn) In other words: convert a byte typed value in reg Dn into a short typed value EXT.L Dn Converts a 16-bits 2's complement representation in reg Dn to a 32 bits 2's complement representation (in reg Dn) In other words: convert a short typed value in reg Dn into a int typed value |
Examples:
(1) Starting with: +----------+----------+----------+----------+ D0 = | 10101010 | 01010101 | 10101010 | 11111110 | +----------+----------+----------+----------+ ^^^^^^^^ This byte represents the byte typed value "-2" After "EXT.W D0", we will have: +----------+----------+----------+----------+ D0 = | 10101010 | 01010101 | 11111111 | 11111110 | +----------+----------+----------+----------+ ^^^^^^^^^^^^^^^^^^^ This WORD represents the short typed (same) value "-2" ! (2) Starting with: +----------+----------+----------+----------+ D0 = | 10101010 | 01010101 | 11111111 | 11111100 | +----------+----------+----------+----------+ ^^^^^^^^^^^^^^^^^^^ This WORD represents the short typed value "-2" After "EXT.L D0", we will have: +----------+----------+----------+----------+ D0 = | 11111111 | 11111111 | 11111111 | 11111110 | +----------+----------+----------+----------+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This LONG WORD (= 32 bits) represents the int typed value "-2" ! |
How to run the program:
|
|
|
The value 3 (three dots) is represented as follows: Using 4 bytes (32 bits): 00000000000000000000000000000011 Using 2 bytes (16 bits): 0000000000000011 (= truncate upper 16 bits) Using 1 byte (8 bits): 00000011 (= truncate upper 24 bits) |
The value -3 is represented as follows: Using 4 bytes (32 bits): 11111111111111111111111111111101 Using 2 bytes (16 bits): 1111111111111101 Using 1 byte (8 bits): 11111101 |
|