CS225,  Fall 2004,  Wednesday Sept. 1, Day 3 Hit reload to get most current!

Notes from last lecture:Suppose your decimal number  = an2n + an-12n-1+...+a222+a121+a020, where the a's are all either 0 or 1.  Dividing by 2 lowers the power of all the 2i 's by one, and if a0 is 1 it is the remainder.  If a0 is 0, dividing by 2 has no remainder.  So we've found a0. Divide by 2 again; now a1 will be the remainder (or 0 if no remainder).....  Finally, an divided by 2 will give 0 and remainder 1, the most significant bit.

Handout: Getting started with Pep8   Link to Word file
Read: Ch.4 to p. 156, "Hardware."  First only Accumulator A, and IndeX register X, Program Counter PC, Instruction Register IR, form of instructions as instruction specifier (Opcode + possibly register + possibly + Addressing mode) and Operand specifier (2 bytes) if any.
Next, 156-160, load, store, add, subtract.

Day 3HW:  Due Day 4. 

Data in memory: A. a) Repeat class work: Copy "Program to examine memory" below into Source window in  Pep8, follow the Running a program instructions in the handout.   Examine the memory.
b) Replace the ASCII to be stored with your name.  Assemble, Load, Execute.  Examine the memory.  Follow the To hand in instructions, print your result.
c)  00 48 65 6C 6C 6F 21 21 21 21 01 02 03 04 zz   That's a machine language program.  Do File>New, copy it into the Object code pane.  Load it,  Execute it, Single step, and examine memory.
Change the machine language program so that  the ASCII string ends in **.   Write on paper from part b what was stored in memory by this program, address & contents( like figure 4.4 p. 142) in ascii where that "works," otherwise hex.  Also, type something after the zz (leave a space) and see if it loads and executes.  (It's supposed to stop loading at zz; should ignore anything else.  Does it?)

B)  Paste "a few instructions" below into the program below, before the STOP.  Run it, single stepping and watching the accumulator and other registers...(nothing to hand in, yet.)

;Program to examine memory
;Sievers
;Aug.30, 2006
;This program has no instructions except to stop running

STOP    ; STOP must be at the end of the instructions for the cpu to run
.ASCII  "ABC abc"  ;stores character data in sequential memory locations
.Byte 0x5a
.byte 0x5b
.word 0x5c
.word 513

.END                ;END tells assembler we're done.

(You can type stuff after .END and it will be ignored.)  


Object program  (machine ready, machine readable--as binary, of course) from above
00 41 42 43 20 61 62 63 5A 5B 00 5C 02 01 zz

Listing gives
address   Hex code   Mnemonic   Operand   Comment


A few instructions (insert before STOP)
LDA  0x000B, d     ;loads 2 bytes at address B into register A
ASLA                          ; shifts bits in register A left one bit
ASLA
LDA  0x000c, d     ;loads 2 bytes at address c into register A
ASLA

;Watch A, PC, IR and opcode and operand as you step: Note PC gives address of NEXT instruction.
 IR gives instruction specifier for instruction just completed, and opcode stuff matches.
Registers  show results of instruction just completed.
Find IR contents for LDA and ASLA, turn to binary and check that codes match book, p. 153-4

.
To Sievers Home Page
CS225-Fall06/Day3.htm 
10:30pm, 8/29/06

  This page belongs to Sally Sievers who is solely responsible for its content. Please see our statement of responsibility