10_toy - 2/3/08 1 Introduction to Computer Science •...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2/3/08 1 Introduction to Computer Science • Sedgewick and Wayne • Copyright © 2007 • http://www.cs.Princeton.EDU/IntroCS 5. The TOY Machine 2 What is TOY? An imaginary machine similar to:  Ancient computers.  Today's microprocessors. 3 Why Study TOY? Machine language programming.  How do Java programs relate to computer?  Key to understanding Java references.  Still situations today where it is really necessary. Computer architecture.  How does it work?  How is a computer put together? TOY machine. Optimized for simplicity , not cost or performance. multimedia, computer games, scientific computing, MMX, Altivec 4 Inside the Box Switches. Input data and programs. Lights. View data. Memory.  Stores data and programs.  256 16-bit "words."  Special word for stdin / stdout. Program counter (PC).  An extra 8-bit register.  Keeps track of next instruction to be executed. Registers.  Fastest form of storage.  Scratch space during computation.  16 16-bit registers.  Register 0 is always 0. Arithmetic-logic unit (ALU). Manipulate data stored in registers. Standard input, standard output. Interact with outside world. 2/3/08 2 5 Data and Programs Are Encoded in Binary Each bit consists of two states:  1 or 0; true or false.  Switch is on or off; wire has high voltage or low voltage. Everything stored in a computer is a sequence of bits.  Data and programs .  Text, documents, pictures, sounds, movies, executables, … M = 77 10 = 01001101 2 = 4D 16 O = 79 10 = 01001111 2 = 4F 16 M = 77 10 = 01001101 2 = 4D 16 6 Binary People http://www.thinkgeek.com/tshirts/frustrations/5aa9/zoom/ 7 Binary Encoding How to represent integers?  Use binary encoding.  Ex: 6375 10 = 0001100011100111 2 +2 11 +2 7 +2 12 +2 6 +2 5 +2 2 +2 1 +2 6375 10 = +2048 +128 4096 +64 +32 +4 +2 +1 6375 = 0 13 1 12 1 11 0 10 0 15 0 14 1 7 ? 6 0 9 0 8 1 6 0 4 1 1 1 0 0 3 1 2 1 5 0 Dec 1 2 3 4 5 6 7 Bin 0000 0001 0010 0011 0100 0101 0110 0111 8 Dec 9 10 11 12 13 14 15 Bin 1000 1001 1010 1011 1100 1101 1110 1111 8 Hexadecimal Encoding How to represent integers?  Use hexadecimal encoding.  Binary code, four bits at a time.  Ex: 6375 10 = 0001100011100111 2 = 18E7 16 0 13 1 12 1 11 0 10 0 15 0 14 1 7 ? 6 0 9 0 8 1 6 0 4 1 1 1 0 0 3 1 2 1 5 +2 2 + 7 × 16 0 1 8 E 7 + 14 × 16 1 + 8 × 16 2 6375 10 = 1 × 16 3 +2 2 + 7 + 224 + 2048 = 4096 Hex 0 1 2 3 4 5 6 0 Dec 1 2 3 4 5 6 7 Bin 0000 0001 0010 0011 0100 0101 0110 0111 7 Hex 8 9 A B C D E 8 Dec 9 10 11 12 13 14 15 Bin 1000 1001 1010 1011 1100 1101 1110 1111 F 2/3/08 3 9 Machine "Core" Dump Machine contents at a particular place and time.  Record of what program has done.  Completely determines what machine will do....
View Full Document

This note was uploaded on 09/21/2009 for the course COMPUTER computer 1 taught by Professor Abedauthman during the Fall '08 term at Aarhus Universitet.

Page1 / 12

10_toy - 2/3/08 1 Introduction to Computer Science •...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online