CS225,  Fall 2006,  Wednesday Sept. 6, Day 6 Hit reload!After class:  agonizing reappraisal

Read behind:  (Re)read Ch. 4, pp. 147-173, skipping Neg and Deci, Deco.  (Re)read Ch 5, p.189-200, Disassemblers p.207-8 (new)
Read ahead:
  3.2, pp. 95-104  (how to do negative numbers)
HW Day 6, Due Friday Day 7 
Textbook 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.  (This is a repeat from day 4.  Half of 3,  9b , and D were discussed in class.  Check the rest of Day 4's HW and repair anything, hand it in again repaired.) 
 Textbook p. 227  #1 (disassemble), #5c, #6a,b (assemble pseudo-ops),
 #9 (hand trace program with AND)  Then type it in and run it; check that your prediction was correct.

A  from last time, due on Friday.  Pep 8.02's flags are supposed to be functioning!. 
A) Tracing:  (Get templates ) a) Trace Program A below, Memory trace and Program trace, including flags (on the computer).  Started in class.
     b) Note how Ldbyte and Stbyte affect the registers, the memory locations, and the flags.
   Hand in the trace.
     c)Underline instructions where N or Z were "set" (turned to 1) and check that each corresponds to:
                 a number with 1 in the leftmost (Most significant) bit; a Zero number.
     d) The Add instruction adds 2 numbers with F's in the leftmost hex digit.  If you do the binary addition, you'll get a carry out of the left side.  Does the C get set (= 1) at this instruction?  Circle the C value for this instruction.

Now go back and work on Program 1. Try to finish by Friday. Check the link for some new hints and comments.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Day 5 HW? 
I didn't collect it, didn't get a sense of what was difficult. Do I need to go over And and Or?  Remaining questions? For the subtracting 1 program, I want the results in Hex:  copy them from the Accumulator as you step.
 I'll expect it Friday unless I get email questions on this material.

- - - - - - - - - - - - - - - - - - - - - - - - - -  - -
Postpone B, C, D.  (C is pretty accessible now.  B and C may be also.   )

B) a) Make a program that will: study the behavior of  ASL and ASR, including the flags.  (ASR shifts right: fills in on the left with 0 if MSB was 0, with 1 if MSB was 1.  Check both kinds of numbers)
     b) And study the logical ops And Or Not.  (All in the same program? or not; your choice).   Check that the ops and the flags operate as they are supposed to.
     Hand in:  Listing(s), What numbers you operated on, the resulting numbers, and the resulting flags.

C)  CR(carriage return) and LF(line feed) are both used as paragraph-enders by various programs.  (Properly, you should need both, CRLF.)  How does PEP8 interpret these when outputting?  What does PEP8 use if you use \n?  Does it interpret any other of the Ascii "control-characters" as actions, and/or what does it do when you output them?
Write a simple program to find out:  Fill some memory locations with Ascii characters, interspersed with the Hex bytes (use\x as p.194) for these: CR (Carriage return), LF(linefeed), BS (backspace), HT (tab), VT (vertical tab), FF (form feed= new page), DEL (delete).  (Use the Ascii table  list I gave you, or the book's.)
Then write CHARO's for your whole list, step thru the program, and write up what you found.

D)  Program W below has a VonNeumann bug , pp 172-3 (assuming you can get it to assemble!)  Trace it and describe the bug.


Notes: 
Von Neumann machine:  No intrinsic distinction between data and program.  Programmer has to keep them separate.

Tracing: 
Get templates
    Trace program below, check out new ops and flags.
All flag activity documented Appendix pp. A7-8, Fig A-ll

Byte ops: only 2: LdbyteR, StbyteR  Mainly for moving characters around.  Load a byte only into the lower byte in the register (the upper byte stays what it was), Store the lower byte from the register to the memory byte of the operand.
  Flags: Note if you load a 00 byte into a register with non-0 stuff in the upper byte, it won't set the Z flag.  Design choice.
We got to here, sort of.  We didn't go through flags for specific ops.

Review instructions so far:
--Load from memory to register:  LDR, LDBYTER
--Store to memory from register:  STR, STBYTER
--1-operand instructions: Manipulate data within one registerASLR, ASRR, NOTR
--2-operand instructions:  Register OP memory location, result placed in Register:ADDR, SUBR, ANDR, ORR
--input/output: to or from a Memory location only:  CHARO
--Flow of controlSTOP
All flag activity documented Appendix pp. A7-8, Fig A-ll

--What is -1?, -2?  Do they satisfy the mathematical definition of a negative: 1 +( -1) = 0    2 +( -2 ) = 0.  Sec. 3.2 next.

Read ahead:
  3.2, pp. 95-104  (how to do negative numbers)

CHARI gets a single character from the input source.  You have two choices on the PC:  Batch I/O or Interactive Input from Keyboard.
Batch mode. You put all your input into the input window before running. The program  reads the first Ascii character from the input window  If you have more than one CHARI in the program, the next CHARI reads the next character, and so on. 
Run Fig. 5.6, p. 196. 

I haven't investigated the interactive input very much yet; trepidation....



;Program A to investigate Status Registers Z, C, N, Ldbyt &Stbyt HW Day5
;Sievers
;Sept 4, 2006
;This program uses Ldbyt, .block new
LDa 0x0016, d ;loads zeros into reg. A. Check flags.
LDa 0x0018, d ;loads F0f0 into A
ldbytea 0x0016,d ; loads a 00 byte into a
ldbytea 0x001d,d ;loads a not-0 byte into a (01)
stbytea 0x001a,d ; stores a byte from a to the memory saved for it
Adda 0x0018,d ; adds F0f0 to a
Suba 0x001e,d ; subtracts E0f1 from a
STOP ; STOP must be at the end of the instructions for the cpu to run
.word 0x0000
.word 0xF0F0
.BLOCK 2 ; reserves a block of "empty" space
.word 0x0001
.word 0xe0F1
.END ;END tells assembler we're done.




;Program F to investigate Negative numbers, HW Day 5
;Sievers  (Put YOUR NAME here)
;Sept 4, 2006
;This program repeatedly subtracts 1, starting from 1, so should find 0, -1, -2, etc.
LDa     0x00FF, d     ;should loads 0001 into reg. A.  It doesn't now. Fix it. (& change this comment)
Suba     0x00FF, d     ;should subtract 0001 from reg. A.  Fix it.
Suba     0x00FF, d     ;should subtract 0001 from reg. A.
Suba     0x00FF, d     ;should subtract 0001 from reg. A.
Suba     0x00FF, d     ;should subtract 0001 from reg. A.
Suba     0x00FF, d     ;should subtract 0001 from reg. A.
Suba     0x00FF, d     ;should subtract 0001 from reg. A.
Suba     0x00FF, d     ;should subtract 0001 from reg. A.
Suba     0x00FF, d     ;should subtract 0001 from reg. A.
STOP            ; STOP must be at the end of the instructions for the cpu to run
.word 0x0001
.END                ;END tells assembler we're done.

;PROGRAM W, HW Day 5
;Sievers
;Sept 8, 2006
;This program uses Load, Add, and Store
LDX 0x000B, d ;loads 2 bytes at address B into register X
AddX 0x000d,d ; adds the word at address d to contents of reg. X
STx 0x000c,d ;stores result
LDX 0x000c, d ;loads 2 bytes at address c into register X
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
.End



To Sievers Home Page
CS225-Fall06/Daya6.htm 
11pm, 9/5/06
This page belongs to Sally Sievers who is solely responsible for its content. Please see our statement of responsibility.