|On Prob 3, my program seems to be working fine. My question is: when I |press 'x' and then 'y' to execute, it says "Execute: Bad instruction: |0." Is that a good thing or a bad thing? | It means that mem[PC] is 0, and so the little guy in the cpu fetched 0, and when trying to decode it, found that it didn't correspond to anything on the sheet (eg, 0 is a bad instruction). Guess#1: you need to set the PC to the start of your program, before running. Detailed explanation: As you entered your program, the inspector bumped up the PC by one for each instruction you entered. (This is to help you enter the program easily.) So when you finish putting instructions in (say) locations 101-109, the PC is 110. If you e'x'ecute immediately, it starts looking running at line# 110. Before pressing "x", you'll want to set the PC with "p 101". Guess#2: If you did do this, i'll bet your program ran the instruction in location 101, 102, 103, ..., 108, and 109, but then of course it keeps going, executing line number 110, 111, .... A "halt" instruction is the only thing that will stop the guy in the cpu from continuing his 4-step cycle. Let me know, if neither of these was the problem. -- ian barland (ian@cs.rice.edu) Instructor, Comp Sci, Rice U. From a fortune cookie: "Anyone who makes a blanket statement is a fool." ========================================= Placing constants into memory: || In problem 3, should the contents of mem2001 and mem2004 be hardcoded, || so the program will only work on the given values?? || In problem 4, should we pick an N and hardcode it into mem321? || |The answer you are looking for is "yes". | |That is, when running the machine inspector, |you'll go and insert the appropriate values into whatever memory |slots are necessary: |put the program at some point in memory, |and also make up some numbers, and stick them into mem[2001] and mem[2004] |and mem[321]. | Hmm. Just to be clear, the way my program for #3 is written right now, there | are lines in the program itself that say: | | (ldi 5) ;ACC<-5 | (stm 2001) ;mem2001<-ACC | (ldi 3) ;ACC<-3 | (stm 2004) ;mem2004<-ACC | | This is what I meant by hard-coding. In order to change the numbers I'm | multiplying or adding, I would actually have to change the assembly | instructions. I understood your message to mean this is not what you want. | Ah, i see. Yes, your approach is fine. Alternately, if you like, instead of having your program put data into mem[2001] and mem[2004], you can instead do this with the inspector, before e*x*ecuting your program: p 2001 5 p 2004 3