CS225,  Fall 2006,  Wednesday Nov. 1, Day 29 Hit reload! After class


HW Day 29, Due Friday Day 30 
Get ready to Go See Oren in Blithe Spirit!

Thinking more about TicTacToe, (TopDown and flowchart are updated to reflect class work) and
Program 9, assigned Day 28, Due Fri. Day 30, Nov. 3
 Interactive program.  Have the user input a number  0, 1, or 2, and print out a "fortune" for each case.  You may ignore the problem of screening for wrong responses.  Use a Jump table and BR with x mode.   EXTRA CREDIT:  Program a Default line (like p. 325 #34 has.)

Amnesty extended: 
Any  old "Programs" handed in  by Friday at 3pm will be only 1 day late.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Notes: 
Start with TicTacToe structure.  Top Down
 
See TicTacToe page for details of class work.
  Spent whole class on it.

Start here, when time allows
+ + + + + + + + + + + +
In PEP:  Used indexed addressing mode (x) for arrays.    Oprnd = Mem[Oprndspec + X] 
    A label (symbol) labels
the address of the first byte of the first item, the Index register holds the offset.
  
If X = 0, this is the equivalent of direct addressing. 
   If Oprndspec = 0,
this is something different:  the address of the operand is in the X register! 
      
LDA 0, x would store the contents of A at the address given by X
           X is special: Can't put an address in A and then go get/put at that memory space.


     br main
m:  .block 2
num: .equate 9
main: lda num, i
     ldx m, i
     sta 0, x
     stop
.end

    Many architectures build this in as a fundamental operation--do something to the data in the memory location whose address is in Register R.  It's like Direct.   Oprnd= Mem[R].  ( Isn't that *n in C++?)
(Imaginary) LdA Mem[X]  = LdA 0, x (real).

Fancier Addressing modes:  Investigate n (indirect),  sf, sx, sfx, "cold" using RTL (p. A4)

What we don't see, with these modes, is "secret" registers (programmed in "microcode") that do all the work.
   They have also the ability to move data from register to register. 
Suppose we have 3 secret registers (call them B, C, D) and another operation
MoveR,  R, which simply copies the contents of one register to another. 
  MoveB,  D would copy D into B.  B<--D
Suppose also we could use registers as operands, so
     AddA X  would add (the contents of) X to A (storing in A).   A<--A+X.
For instance,  the Operand in x mode could be calculated something like this,  ending up in register D: 
Oprnd <-- Mem[OprndSpec + X]
   MoveB, X
   AddB OprndSpec, i
   LDD  Mem[B]
Then our assembly language instruction would do what it wanted to on the number in D.

Analyze the remaining instructions this way; find  "microcode" analyses that put the Operand in register D.  (What good are these modes anyhow?)

(The trend in chip architecture is to have more registers "on top", more between-register operations, and fewer explicit addressing modes.  Make the programmer/compiler do the work of programming the equivalent of the addressing mode.)


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