Computer Science 220
Assembly Language & Computer Architecture
Fall 2011, Siena College
Lecture 0x01: Binary Arithmetic; Signed Representations; Signed Arithmetic
Date: Thursday, September 8, 2011
Agenda
- Announcements
- First lecture assignment due now.
- Labs: looking for 1-3 people who can move from Tuesday lab
to Wednesday lab.
- Accessing class examples: ~jteresco/shared/cs220 in our labs and
on olsen.
- Unix tip of the day: cd
- Lab 0 aftermath
- Character representations
- Memory model and pointers
- Unsigned math
- Signed math
- signed representations
- addition
- multiplication
Lecture Assignment 0x01
Due at the start of class, Tuesday, September 13.
Please submit answers to these questions
either as a hard copy (typeset or handwritten are OK) or by email to
jteresco AT siena.edu by the start of class. Please use a clear subject line
when submitting by email (e.g., CS 220 Lecture
Assignment 0x01, Joe Student). We will discuss these
questions at the start of class, so no late submissions are
accepted.
This lecture assignment will be graded
more carefully and strictly than most. Please plan accordingly.
- Represent each of the following quantities using each of the following
8 bit representations, where possible: unsigned, signed magnitude, 1's
complement, 2's complement. Values are given in base 10, and
characters are ASCII. Express each as both an 8-bit binary number and
a 2-digit hexadecimal number.
For example, to represent the value -17, the unsigned
representation is not possible, the signed magnitude representation is
100100012 or 9116, the 1's complement representation
is 111011102 or EE16 and the 2's complement
representation is 111011112 or EF16. (5 points)
- 0
- 11
- -42
- 42
- -127
- 127
- -128
- 128
- 255
- the character '6' (see man ascii)
- Compute the following binary 2's complement problems in 4 bits. Which
answers to you trust and why (your reasons should refer to values that
can easily be checked by computer such as values of carry bits)? (2 points)
0001 0001 1001 1111
+0101 +0111 +1111 +0101
---- ---- ---- ----
- The following problems are expressed in 8 bit, hexadecimal, 2's
complement. Compute the result as 16 bit 2's complement expressed
in hex. Which answers do you trust? (3 points)
FF FF 01 4c 7f 80
+ 11 + FF + 7F x 04 x 7f x 80
---- ---- ---- ---- ---- ----
Examples
- show_bytes - examine endianness