CS241 Lecture Notes - Lecture 2: Arithmetic Logic Unit, Amiga Chip Ram, Instruction Register

33 views4 pages
Lecture 2: Data Representations and Machine Language
Recap: 2's complement can be computed by flipping the bits and adding one
ex. What is the 2's complement of -6 in 4 bits?
6 in binary: 0110
flip the bits: 1001
add 1: 1010
-6 in 2's complement with 4 bits: 1010
ex. Converting out of a 2's complement value.
First, is this a positive value or negative? The first bit will tell you! A nagetive value will have
MSB (most significant bit) set to 1.
1111 1011 (this is a negative)
You can flip and add one and that will work as well!
flip the bits: 0000 0100
add 1: 0000 0101 (this is 5, so we had -5 before in 2's complement)
or... (different approach)
1. treat number as unsigned binary (compute decimal as if it was unsigned, the result
represents N-b)
2. if the first bi was 0, you're done
3. if the first bit was 1, subtract 2^n (N) from the decimal value obtained (because N-b-N = -b)
ex. Comparison - 0111 < 1001?
This will depend on whether these numbers are signed or unsigned...
unsigned: 7 < 9 - true
signed: 7 < -7 - false
Most machine languages will have separate commands to perform signed/unsigned
comparisons (need to tell the processor)
How do you know which one it is? You don't...
ASCII Encoding
- A 7 bit encoding
ex. 1000011 could be upper case C because in binary it is 67 and that is the decimal value of
upper case C
Machine Language
- Computer doesn't just understand bits of 1 and 0, it needs the machine language to
understand them.
- A set of machine instructions.
Machine Instructions
A sequence of bis that have exactly one meaning on a particular architecture (different
architectures might have different machine language).
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Recap: 2"s complement can be computed by flipping the bits and adding one ex. 6 in binary: 0110 flip the bits: 1001 add 1: 1010. 6 in 2"s complement with 4 bits: 1010 ex. This will depend on whether these numbers are signed or unsigned unsigned: 7 < 9 - true signed: 7 < -7 - false. Most machine languages will have separate commands to perform signed/unsigned comparisons (need to tell the processor) 1000011 could be upper case c because in binary it is 67 and that is the decimal value of upper case c. Computer doesn"t just understand bits of 1 and 0, it needs the machine language to understand them. A sequence of bis that have exactly one meaning on a particular architecture (different architectures might have different machine language). In this course, we will be using mips 32 so instructions will be 32 bits. Registers (0-31): fast because they"re on the chip.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents