CS225,  Fall 2006,  Friday Sept. 1, Day 4 Hit reload!

Read: Reread Ch.4 to p. 155, "Hardware."  First only Accumulator A, and IndeX register X, Program Counter PC, Instruction Register IR, form of instructions as instruction specifier (4+ bits for opcode, often 1 for register, 1-3 for Addressing mode) plus Operand specifier (2 bytes) if any.
4.2, pp.155-160, load LDr, store STr, add ADDr, subtract SUBr, p. 164-5, Character output CHARO  (rest later)
4.3 pp. 166-173, Von Neumann cycle.  Be sure to go thru the cycle pp.170-1.
5.1 pp. 190-195, starting Assembly Language. 
Add
to known instructions : ASLr arithmetic shift left. (shift all bits one place left, fill in with 0) (There's also ASRr)
Von Neumann cycle:  Fetch instruction, increment PC (and get remainder of instruction if any), execute instruction, repeat.

Day 4HW:  Due Day 5.  (* problems/parts have answers in the back.  )

Text p. 183.  #1 (sizes of things.  Hint: p. 148-9 have the data.) # 3,  #7 and #9b (decode programs from hex, writing out what the instructions are from pp.153-4.  Figure out what it will do.  You can type in the machine code to PEP, it shows how on p. 183, and run it to check.)

With PEP:  
A a) Repeat the class work, inserting the Load and ASL instructions shown below into the last program, step it following the PC and the ops.  The program with the inserted instructions is below. 
b)  Find IR contents for LDA and ASLA, turn to binary and check that codes match book, p. 153-4  Write them down in binary.
c) Alter the instructions so they act on the Index Register (register X) instead of on A.
d)  Arithmetic Shift Left does something to the number in the register.  You know this action by another name. (Hint:  What's the binary/hex for 1 and 2?  3 and 6?  5 and 10?) Examine the action, changing the value loaded in if you like for more data, and try to see what it's doing.  Tell me in class.

B) a) Type in the program in Fig. 4.32 (p. 169) as a machine language program (it shows how on p. 183) and step through it.  In Batch I/O you'll see the output appear as you step it.  It won't step.  Run it.
     b) Modify it so that it the output is Hip instead of Hi. (Careful!) Print out your machine language code and your output to Hand in.

C)  We have memory locations 0000 to FBCE for user programs and data.  (Above that is system stuff)  Remembering that each location holds one byte, and assuming (unrealistically) that no data  storage is needed,
a) How many unary instructions can be stored?
b) How many non-unary (like Load) instructions can be stored?
D) The addressing mode space can be as much as 3 bits.  How many different addressing modes can be specified in 3 bits?  Are they all used by PEP8?

PROGRAM 1  Due Day 6 (Wednesday)
Write a correct assembly language program which does this:
a) Uses an assembler directive  (dot command) to place the string Hi  into memory when the program is loaded.
b) On running, loads the two-bite string Hi into the A register.
c)  Adds 6 to it.  (Where will you get the 6?  Store it in memory beforehand.)
d) Stores the result back in the location of the original string.
e) Outputs the two characters of the result.
Run, Debug, Hand in the original source, the listing, and the output.


.........

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

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
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

............

To Sievers Home Page
CS225-Fall06/Day4.htm 
10pm, 8/31/06
This page belongs to Sally Sievers who is solely responsible for its content. Please see our statement of responsibility.