Code: The Hidden Language of Hardware and Software

  1. Best Friends
    • Friends can use flashlights to communicate (i.e. morse code)
    • In book, code means system for transferring info among people and machines
    • All facets of communication (audio, visual, etc) corresponds to some kind of code
  2. Codes and Combinations
    • Easier to send than receive because harder to map dots and dashes than letters
    • Could group based on combo length and organization
    • Each length grouping, doubles in size
    • number of codes = 2 ^ (number of dots and dashes)
    • Morse code is binary (only has dots or dashes)
    • Analyzing binary codes is combinatorial analysis
  3. Braille and Binary Codes
    • Braille uses 2*3 dots that are raised or not
    • Results in 2^6 or 64 combinations
    • after letters, includes various codes for common words, combinations of letters or special indicators such as caps
    • Escape codes let you change routine interpretation
  4. Anatomy of a Flashlight
    • Flash light consists of battery, wires, bulb
    • electricity happens when electrons dislodged from atoms
    • circuit takes from negative side to positive side
    • Resistance in bulb section causes it to glow and emit light
  5. Seeing Around Corners
    • If you wanted to connect wires so you and friend could have a lights, need common connection
    • Could use earth as one side of wire
    • Lets you communicate beyond line of sight
    • Trade offs with distance, thickness of wire and voltage required
  6. Telegraphs and Relays
    • Morse used electromagnetism to control metal lever that would make sounds representing dashes or dots
    • Relay system could amplify signal and resend in between
  7. Our Ten Digits
    • Our base 10 counting system arbitrary
    • Likely arose because 10 fingers
    • Current number system from arab world, positional system and invention of zero resulted in huge benefits
  8. Alternatives to Ten
    • Can create different base variations e.g. base 8
    • In base 8, each position represents 8’s
    • by position: 8^0, 8^1, 8^2, 8^3, etc.
    • Can create base 2 or binary
    • gets long very quickly
    • 1, 10, 11, 100, 101, 111 corresponds to 1,2,3,4,5
    • first position is how many 1’s, next how many 2’s, next how many 4’s, next how many 16’s
    • John Tukey realized binary digits would be very important with rise of computers so created word bit to shorten
  9. Bit by Bit by Bit
    • Bit is zero or one
    • simplest number system and basic building block of information
    • adding a digit doubles possibles
    • If you know how many codes you need can use base two log
    • log2 200 = 7.64 or 8 bits
    • Bits can represent anything, but most fundamentally are numbers
  10. Logic and Switches
    • Aristotle wrote extensively about logic in the Organon
    • George Boole invented mathematical way to represent logic
    • Made algebra more abstract and divorced it from concept of numbers
    • Operands refer to classes or sets
    • + or U is a union or an OR
    • x or n is an intersection or an AND
    • Circuit with parallel switches (OR) and sequential switches (AND) can use Boolean algebra to determine if something satisfies conditions
  11. Gates (Not Bill)
    • Logic gates decide whether electricity flows or not
    • switches are input devices and lightbulb is output device
    • Relays can be configured to create AND or OR circuits
    • An inverter changes the flow to the opposite
    • can create NOR (inverted AND) or NAND (inverted OR)
    • pic1
  12. A Binary Adding Machine
    • Adding binary digits result in a sum and a carry out
    • The carry out is described by an XOR operator
    • sum is described with an AND operator
    • combining these shown with a half adder
    • pic2
    • This only works for the first digit, but not other digits because must take in a carry in
    • pic3
    • This is simplified to a full adder
    • pic4
    • Computers function similarly
  13. But What about Subtraction
    • Minuend – Subtrahend = Difference
    • Can do subtraction and avoid borrowing
    • e.g. 32 – 28 = x
      • 32 – 28 + 99 + 1 – 100 = x
      • 32 + (99 – 28) + 1 – 100 = x
      • 32 + 71 + 1 – 100 = x
      • 104 – 100 = 4
    • Can do the same with binary. 111111 minus anything will just result in inverse
    • Don’t need to use signs (+/-) to represent negatives
      • -128 to 127 represented by 1000000 to 01111111
      • adding and subtracting easier, but need to watch out for overflow
    • When using binary and digits, need to know if signed (-128 to 127) or unsigned (0 to 255)
  14. Feedback and Flip-flops
    • Oscillators change between states by itself e.g. an inverter that feeds its output to itself
    • One cycle is called a period
    • 1/period is frequency of hertz
    • Can set up to have multiple stable states
    • “Flip-flop” circuits retain information
    • Can configure to count in binary
  15. Bytes and Hex
    • 8 bits is known as a byte
    • base 16 number system is hexadecimal
    • Each byte can be represented by two hexadecimal digits
    • A-F used to represent after 9
  16. An Assemblage of Memory
    • Telegraph relays when assembled into logic gates and then flip-flops can store information
    • Can use three select inputs to represent 8 values
    • This config of latches known as read/write memory or RAM (Random Access Memory)
    • Random access because each latch accessed by changing address inputs (select)
    • number of values in RAM array = 2^(Number of Address Inputs)
    • 1024×8 RAM, means can store 2^10 or 1028 1-byte values
    • 1024 bytes is kilobyte because 2^10 is roughly 10^3
    • 1024 kilobytes is a megabyte and etc..
    • Can use switches to select or write over values in any of the addresses
    • volatile memory because will disappear if lose electricity
  17. Automation
    • A latch that accumulates a running total of numbers is an accumulator
    • It often holds one number and then that number plus or minus a number
    • Can make an automatic adder more versatile by introducing instructions such as load, add, store
    • To do this need some kind of numeric code that indicates what the automated adder should do
    • Easiest way is with separate RAM array that is accessed at the same time
    • These two arrays are labeled Data and Code
    • The new automatic adder needs to be able to write sums into the original RAM array
    • Each code RAM corresponds to value in the Data RAM
    • Numeric codes often called instruction codes, operation codes, or opcodes
    • using low-order bytes, high order-bytes, and a carry latch, can add values with more than 8bits
    • if we make each instruction 3 bytes, with a code, and two bytes for addresses, can have one RAM array
    • The conditional jump (controlled repetition or looping) is what separates computers from calculators
    • This is a digital computer and has four parts: a processor, memory, at least one input device, and at least one output device
      • Memory: 64-KB RAM array
      • Input/Output: switches and lightbulbs
      • Processor: everything else
    • Processor is also called a central processing Unit or CPU
    • Processor has several components
      • Accumulator: latch that holds a number
      • Arithmetic Logic Unit or ALU: 8-bit inverter and 8-bit adder. adds or subtracts in this example
      • Program Counter: 16-Bit counter
      • operation codes that processor responds to AKA machine codes/ machine language
    • If you were writing, assembly language first then machine language
  18. From Abaci to Chips
    • Herman Hollerith helped automate the census by creating hole punch system
    • Created and sold punch-card equipment with Tabulating Machine Company
    • In 1915, President Thomas Watson changed name to International Business Machines or IBM
    • While we covered primarily digital, most inventions were analog
    • Programs used to be written on paper tape with punched holes
    • code and data in memory is more recent concept
    • Vacuums could replace relays, but problems with that too
    • Alan Turing helped design Colossus to break German Enigma machine
    • J. Presper Ekert and John Mauchly designed ENIAC using 18,000 vacuum tubes in 1945
    • John Von Neumann helped design successor or the EDVAC
    • Computer should have as much memory as possible and used to store both code and data
    • instructions sequential in memory and addressed with a program counter that allowed conditional jumps (stored-program concept)
    • von Neumann architecture but also von Neumann bottleneck, significant time spent fetching instructions
    • John Bardeen and Walter Brattain in 1947 at Bell Labs wired a new amplifier out of germanium (a semiconductor)
    • This was the first transistor
    • resistance of semiconductors can be manipulated
    • semiconductors can be doped or combined with impurities
    • N-type semiconductors (negative) and P-type semiconductors (positive)
    • Semiconductors can be made into amplifiers by sandwiching P-type with two N-types (NPN transistor)
    • These three pieces known as collector, base, and emitter
    • turning voltage off on base, turns off transistor
    • In 1956, Shockley started Shockley Semiconductor Laboratories in Palo Alto
    • Vacuums and transistors originally developed for amplification, but could be used for switches in logic gates
    • Kilby and Noyce are both credited for invention of integrated circuit (single piece of silicon with transistors, resistors, and other electrical components)
    • In 1965, Gordon Moore, noticed that technology was improving in such a way that number of transistors that could fit on a single chip would double every year
    • In 1970, IBM put whole processors on a single chip (4004)
    • Three measures for comparing microprocessors: 1) bits, 4004 was 4, 2) clock speed, and 3) addressable memory
  19. Two Classic Microprocessors
    • The 8080 and 6800 two most historically significant chips
    • These were single-chip microprocessors
    • Took inputs and outputs and required an oscillator to make it go
    • microprocessor requires energy and synchronized clock inputs
    • The 8080 had A0 – A15 for address 2^16 or 65,536 bytes of memory
    • 8-bit microprocessor means can read or write 8-bits at a time
    • RETURN
  20. ASCII and a Cast of Characters
    • using code to represent text is known as coded character set
    • ASCII or American Standard Code for Information Interchange developed to help computers communicate with text (7bit)
    • Control characters can be used to format text
    • Unicode was developed as an alternative taking into account other languages (16 bit)
  21. Get on the Bus
    • processor most important, but storage important because flash doesn’t retain information without power
    • boards communicate by means of a bus (signals provided to every board on computer: address, data output, data input, control)
    • RETURN
  22. The Operating System
    • when computer is first turned on, won’t be productive without software
    • need initialization code for when microprocessor is reset
    • once turned on, computer starts operating at a given address after instructions are written there
    • inputting machine code very tedious and difficult (0’s and 1’s)
    • keyboard designed to interrupt microprocessor when pressed
    • Can save code in ROM (read-only memory)
    • can store data in file system
    • file system is almost always part of a larger collection of software known as an operating system
    • UNIX popular because can be adapted to run on a variety of computers
  23. Fixed Point, Floating Point
    • Computers deal with numbers as discrete values
    • Number of discrete values you can represent directly related to number of bits available
    • fractions can be represented with binary-coded decimal (BCD)
    • common to store two BCD digits in 1 byte, don’t use two’s complement so need a sign bit
    • This is fixed-point format, bc decimal is always fixed at a particular number place
    • works good if you know the numbers aren’t going to get too large
    • Alternative is floating-point, good for storing small and large, based on scientific notation
  24. Languages High and Low
    • bytes of machine code associate with short mnemonics such as MOV, ADD, CALL, HLT
    • An assembler can take assembly-language program and output an executable file written in machine code
    • Fairly simple because assembly to machine is 1-to-1 conversion
    • Working in assembly is tedious and isn’t portable since works differently with different chips
    • High-level programming refers to anything other than assembly
    • Languages need a syntax and a compiler
      • converts the statements to machine code
    • They are easier to learn, write, concise, portable
    • High level language can’t use features specific to certain processors
    • FORTRAN is the oldest high-level language and is still in use today
    • Interpreters read source code and executes it directly
  25. The Graphical Revolution
    • One way in which we can put the extra power and speed of computers is by improving the user interface
    • Computers originally weren’t interactive
    • Step from character to graphic displays started in 1950’s, but very slowly
    • increased interactivity
    • GUI started at PARC
    • Graphical OS require much more space
    • Almost never written in assembly language
    • OO helped programmers think about objects on screens in a way the user perceived them
    • OO doesn’t let you do anything more, but provides a superior structure to problems
    • Raster graphics (bitmap graphics) encodes an image as a rectangular array of bits that correspond to the pixels of an output device
    • Graphics Interchange Format (GIF) is very popular bitmap file format since uses lossless compression
    • Digitized sound made a big splash in 1983
    • Introduction of sound, music, and video into personal computer was known as multimedia
    • Internet allows computers to communicate through protocols

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s