Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Assembly Chapter 1 Exercises, Study notes of Assembly Language Programming

Exercises 1-10 from Chapter 1 of Microcontrollers

Typology: Study notes

2016/2017

Uploaded on 09/20/2017

motivation-success
motivation-success 🇺🇸

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 1 Exercises
1. It will take 6 bits to represent 40 items: “Log2 40=5.32”
so the next integer is 6.
2. The largest unsigned integer that can be represented in 7
bits is 127. With 7 bits, the biggest number we can
represent will be 26 and the smallest is 20 or 1. We take the sum of all
the bits minus 1: “26 + 25 + 26 + 26 + 22 + 21 +20 – 1 = 128-1 = 127
3. To convert the value 120 to binary using 8 bits, we divide the number by
2, 8 times, if we have a rest, we put a 1, if there is no rest we put a 0. The
result is 0b01111000.
4. To convert 89 to HEX, we divide 89 by 16 = 5, the remainder is 9 which
will be the last HEX number. After dividing 5 by 16, the result is 0 and
the remainder is 5 which will be the first HEX. The result is 0x59.
5. To convert 0xF4 from HEX to Binary we split the number. Using 8 bits in
total, we know that F represents 15 which is 0b1111 in binary. We know
that 4 represents 0b0100 in binary. The final result will then be
0b11110100.
6. To convert 0xF4 to decimal, we know that HEX is on a 16 base. The first
bit is 4 and we multiply it by 160: “1*4=4”, the second bit is F(or 15) we
multiply by 161 : “16*15=240”. After adding the two numbers we get 244
in decimal.
pf2

Partial preview of the text

Download Assembly Chapter 1 Exercises and more Study notes Assembly Language Programming in PDF only on Docsity!

Chapter 1 Exercises

  1. It will take 6 bits to represent 40 items: “Log2 40=5.32” so the next integer is 6.
  2. The largest unsigned integer that can be represented in 7

bits is 127. With 7 bits, the biggest number we can represent will be 2^6 and the smallest is 2^0 or 1. We take the sum of all the bits minus 1: “ 2 6 +^2 5 +^2 6 +^2 6 +^2 2 +^2 1 +^2 0 – 1 = 128-1 =^^127 ”

  1. To convert the value 120 to binary using 8 bits, we divide the number by 2, 8 times, if we have a rest, we put a 1, if there is no rest we put a 0. The result is 0b01111000.
  2. To convert 89 to HEX, we divide 89 by 16 = 5, the remainder is 9 which will be the last HEX number. After dividing 5 by 16, the result is 0 and the remainder is 5 which will be the first HEX. The result is 0x59.
  3. To convert 0xF4 from HEX to Binary we split the number. Using 8 bits in total, we know that F represents 15 which is 0b1111 in binary. We know that 4 represents 0b0100 in binary. The final result will then be 0b11110100.
  4. To convert 0xF4 to decimal, we know that HEX is on a 16 base. The first bit is 4 and we multiply it by 16 0 : “14=4”, the second bit is F(or 15) we multiply by 16^1 : “1615=240”. After adding the two numbers we get^^244 in decimal.
  1. To convert the value 0b10110111 to decimal, we add all the results of the bits in power of 2: “2^7 + 2^5 +2 4 +2^2 +2 1 +2 0 = 128+32+16+4+2+1= 183 in decimal.
  2. To compute 0xB2 + 0x9F, we compute (F+2) =17, we then subtract 16= and carry 1 that we add to B+9+1= 21, we then subtract 16=5 and carry
    1. The final HEX will be 0x151.