Quiz 9.2

DIRECTIONS: Read each question carefully. Then click on the dot next to the answer that most closely fits the question. Try to answer all questions on this quiz and when you are done, click on the grade me button at the bottom.


Coverage: Section 9.4

  1. Which programming methodology of the 1960s strongly condemned the use of goto statements?
flowcharting
structured programming
spaghetti coding
object oriented programming

  1. Which control structures of HLLs (high level languages) are implemented by the use of goto statements?
while loops
if then elses
switches (case statements)
all of the above

  1. What is a label in an assembler program?
a word-like name that stands for a memory address
a word-like name that stands for a machine instruction
a memory address
a comment only meant to help you remember the logic of your code

  1. When writing the assembler equivalent of a while loop, which instruction would always be put at the bottom of the loop code?
NOP
RET
JMP
JZ

  1. How do many computers (including the CSC-1) compare two numbers for equality, or greater/lesser relationships?
they have special instructions for comparisons
they subtract the two numbers and check the resulting condition code
they incorporate the comparison directly into special jump instructions
they can't

  1. If you looked at hundreds of while loops and if then elses and compared the assembler code that they created, which instruction would be found in all of them, regardless of what other code they might contain?
JMP
JZ
RET
NOP

  1. What do we call various tricks and techniques that produce shorter or faster code?
minimization
orthogonalization
internalization
optimization

  1. Which computer did Steven Levy write about in "Insanely Great" where he mentioned that the project leader pushed the programmers to make the operating system code faster so as to reduce boot time?
IBM PC
IBM 360
Macintosh
Apple II

  1. If computers do not have explicit I/O instructions, they rely on what for input and output?
memory-mapped I/O
special I/O chips
the human's ability to just peek into memory and find the answer
all computers have explicit input and output instructions, silly!

  1. Which chunk of assembler code could implement the following while loop skeleton?
         while (x != y) { ...
    
     WHILE:    LOD X
               SUB X
               JZ  ENDWHILE
               ...

     WHILE:    LOD X
               SUB Y
               JNZ ENDWHILE
               ...

     WHILE:    LOD X
               SUB Y
               JZ  ENDWHILE
               ...

  1. What does the following mean in CSC-1 assember?
              =1000
              X:        NUM  18
    
There are 1000 memory words in memory, each having the number 18. They are collectively known as the array "X".
There is an integer variable called "X" that initially has the value 18 and its memory address is 1000.
The number 1000 is stored in a memory word named "X" whose address is 18.

  1. Which if-then statement below is correctly encoded by the following assembler fragment?
         IF:     LOD X
                 SUB Y
                 JP  THEN
                 JMP ENDIF
         THEN:   STD X
         ENDIF:  NOP
    
if (x > y) { y = x - y; }
if (x < y) { x = x - y; }
if (x > y) { x = x - y; }