assign4_design - clearAll: sets all the variables to 0....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Pseudocode : Main: Call clearAll to clear all variables (RAM[1000], RAMindex, Rindex, d, s, a, n, R[10], N, i, j, k, counter, t, u,  v, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9) Open file stream to begin reading first line of text. Read first line of text, set this to N, and N2 (temporary N) Start a while loop for while (N2>0) Start reading each line of program with fgets Get each digit of the three digit instructions into t, u, and v. based on these numbers, each of the following  instructions will be called: set1, set2, set3, set4, add1, add2, multiply1, multiply2, goto. If it encounters a  1xx, N2 will be decremented and the next program will begin to be read. Call buildOutput when the program has ended. Once N2 is zero, the whole program will close the file stream and return 0.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: clearAll: sets all the variables to 0. set1(d,n): sets R[d] to n set2(d,s): sets R[d] to value of R[s] set3(d,a): sets R[d] to RAM[R[a]] set4(s,a): sets RAM[R[a]] to R[S] add1(d,n): adds n to R[d] add2(d,s): adds R[s] to R[d] multiply1(d,n): multiplies R[d] by n and stores it in R[d] multiply2(d,s): multiplies R[d] by R[s] and stores it in R[d] goto(d,s): if (R[s]!=0), then RAMindex is set to d, and the program continues from the new RAMindex. buildOutput: This will output a table using: N X, where N is a number from 0-9, and X is the number of times Nxx was seen in the program. There will be counters (c1, c2, c3,… c9) that increment each time an instruction of that opcode is called. This should give you a working program....
View Full Document

This note was uploaded on 05/01/2008 for the course EE 312 taught by Professor Shafer during the Spring '08 term at University of Texas.

Page1 / 2

assign4_design - clearAll: sets all the variables to 0....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online