1 / 8

SAL – Part 3

SAL – Part 3. Operations Q & A.

Télécharger la présentation

SAL – Part 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SAL – Part 3 Operations Q & A

  2. Assume that at instruction fetch, operand load, or storage of a result takes 10 time units to complete. Instruction decode, operation execution, and program counter update each take 1 time unit to complete. How long does it take to execute the following code sequence? add D, E, F #instr 1 move G, F #instr 2

  3. instr 1 instr 2 fetch _____ _____ update PC _____ _____ decode _____ _____ load operand _____ _____ execute _____ _____ store _____ _____

  4. Does a compiler need to be written in assembly language? If so, why? If not, how is a machine language version of the compiler generated. A compiler need not be written in assembly language. The compiler can be written in a high-level language and then use it to compile itself to its assembly language representation. An assembler can then be used to translate it into machine language.

  5. Explain how to implement a boolean type variable in SAL. What is the variable’s type, and how is it used? We can use integer type variables. The value 0 can represent false and the value 1 can represent true.

  6. For the following SAL codes give a value for which code B would execute fewer instructions than code A.

  7. move result, 1 #code A move counter, exponent while: blez counter, endwhile mul result, result, base sub counter, counter, 1 b while endwhile: move result, 1 #code B move counter, exponent blez counter, endwhile loop: mul result, result, base sub counter, counter, 1 bgtz counter, loop endwhile:

  8. Write a SAL code for the following C code fragment. for (i=2;i<=z;i++){ if (0 == i%2){ sum = sum + i; } }

More Related