Question

In: Computer Science

Question 1) Given the byte value: 0xad a) What is the equivalent decimal notation as an...

Question 1)

Given the byte value:

0xad

a) What is the equivalent decimal notation as an unsigned value?

b_ What is the equivalent decimal notation as a signed value?




Question 2)

Below are integer values and the location where each is stored, which may be an address in memory or a register:

Value    Location
0xc       0x130
0x82     0x134
0x5       %rdi
0x134    %rsi

What are the values of the following operands? You may answer in decimal or hexadecimal, but if you answer in hexadecimal, you must use the "0x" prefix:

Operand:

a) %rsi

b) (%rsi)

c) 20(%rsi,%rdi,4)

Question 3)

Assume that a variable "x" exists and its address is stored in %rdx.
For each specification below, write an assembly instruction that copies the value of variable "x" to the %rax/eax register.

a. Data type of "x": unsigned int



b. Data type of "x": unsigned long

Question 4)

Below are values that are stored in memory or registers, as noted:
value    address/register
0x11     0x130
0x13     0x138
0xab     0x140
0xff    0x148
0x138   %rsi
0x3     %rcx
0x1       %rdx

Compute the result, in hexadecimal, of each of the following assembly instructions and note the location where each result will be stored:

subq %rcx, 8(%rsi)

a) Result (answer below):

b) Location:


incq %rdx

a) Result (answer below):

b) Location:

Solutions

Expert Solution

1)
Hexadecimal     Binary
    0           0000
    1           0001
    2           0010
    3           0011
    4           0100
    5           0101
    6           0110
    7           0111
    8           1000
    9           1001
    A           1010
    B           1011
    C           1100
    D           1101
    E           1110
    F           1111
Use this table to convert from hexadecimal to binary
Converting AD to binary
A => 1010
D => 1101
So, in binary 0xAD is 10101101

a)
=> 10101101
=> 1x2^7+0x2^6+1x2^5+0x2^4+1x2^3+1x2^2+0x2^1+1x2^0
=> 1x128+0x64+1x32+0x16+1x8+1x4+0x2+1x1
=> 128+0+32+0+8+4+0+1
=> 173
Answer: 173

b)
since left most bit is 1, this number is negative number.
so, follow these steps below to convert this into a decimal value.
I. first flip all the bits. Flip all 0's to 1 and all 1's to 0.
   10101101 is flipped to 01010010
II. Add 1 to above result
01010010 + 1 = 01010011
III. Now convert this result to decimal value
=> 1010011
=> 1x2^6+0x2^5+1x2^4+0x2^3+0x2^2+1x2^1+1x2^0
=> 1x64+0x32+1x16+0x8+0x4+1x2+1x1
=> 64+0+16+0+0+2+1
=> 83
Answer: -83


Related Solutions

Convert the following to a decimal, scientific notation, and engineering notation Decimal to scientific and engineering...
Convert the following to a decimal, scientific notation, and engineering notation Decimal to scientific and engineering notation: 270, 14600, 0.000456, 0.022, 0.000000051, 66500000, 423000, 0.78 Scientific notation to decimal and engineering notation,4.5x10^4, 6.8x10^-8, 2.7x10^5, 7.22x10^-2, 9.52x10^-5, 1.89x10^2, 3.6x10^7, 8.62x10^-10 engineering notation to decimal and scientific notation,12k, 68p, 2.1G, 82T, 7.1n, 100m, 1.8k
What is the advantage of using scientific notation over decimal notation? What is the difference between...
What is the advantage of using scientific notation over decimal notation? What is the difference between weight and mass?
CIDR notation - First 2 answers given: If the dotted decimal subnet mask is given then...
CIDR notation - First 2 answers given: If the dotted decimal subnet mask is given then give me the CIDR notation If the CIDR notation subnet mask is given give me the dotted decimal notation 255.255.240.0            ______________________________________ /30                      ______________________________________ What network does this address belong to? 3- 200.198.44.220/26       _____________________________ 112.55.78.120/16        _____________________________ What is the broadcast address for this network? (The easiest way to get the broadcast address is to figure out the next network and subtract 1 or put all...
Prove that {0n1n2n:n≥1} is not a regular language. The decimal notation for a number is the...
Prove that {0n1n2n:n≥1} is not a regular language. The decimal notation for a number is the number written in the usual way, as a string over the alphabet {0,1,⋯9}. For example, the decimal notation for 13 is a string of length 2. In unary notation, only the symbol “I” is used; thus 5 would be represented as IIIII in unary notation. Show that each of the following is or is not a regular language. (For regular languages, write down its...
/* * Change the value pointed to by ptr byte-by-byte so that when returned as an...
/* * Change the value pointed to by ptr byte-by-byte so that when returned as an integer * the value is 351351. * * Hint: Remember that an int is 4 bytes. * * Hint: Remember how little endian works for data storage, how is it different between an multiple bytes(int) and a single byte? * * Hint: It will be easiest to start convert 351351 into binary form and starting seeing how the endian works from there. * *...
Part 2: Signed values: Convert each as indicated. 8. Decimal to Hexadecimal (1 byte, one's complement)...
Part 2: Signed values: Convert each as indicated. 8. Decimal to Hexadecimal (1 byte, one's complement)      a. -18      b. -41
Part 2: Signed values: Convert each as indicated. 7. Decimal to Hexadecimal (1 byte, signed magnitude)...
Part 2: Signed values: Convert each as indicated. 7. Decimal to Hexadecimal (1 byte, signed magnitude)      a. -18      b. -41
1) Consider the following infix expressions. What is the equivalent postfix (reverse Polish notation) expression? 16/(5+3)b)...
1) Consider the following infix expressions. What is the equivalent postfix (reverse Polish notation) expression? 16/(5+3)b) A*B+C*Dc) X × Y + W × Z + V × U 2) Consider the postfix (reverse Polish notation) 10 5 + 6 3 - /. What is the equivalent infix expression?
Give the mask in the dotted-decimal notation: a. For a block of Class A which results...
Give the mask in the dotted-decimal notation: a. For a block of Class A which results in 32 subnets b. Which combines 2048 Class C blocks into a supernet c. For a block of Class B which results in 64 subnets d. Which combines 16 Class B blocks into a supernet
1. Give the binary equivalent of the decimal number of 11.77 (assume fixed point, no more...
1. Give the binary equivalent of the decimal number of 11.77 (assume fixed point, no more than 6 bits left and right of the decimal point)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT