csci 10 :: book learning challenge 15 (due mon, dec 5)
Submitting your work:

Complete this exercise on your own.

Fill in all of the "Answer" boxes, then print the answer grid that you see after you press "Prepare for printing".

Staple all pages together and submit to the instructor on the date listed above.

Questions:

Read AoA V3 10.2, V4 2.2, V4 2.3, V4 2.4, V4 2.5, V4 2.6, V4 2.11, V4 2.12 and answer the following:

Your name:
  1. What is wrong with the following HLA program?
    program MyProgram;

    #include ("stdlib.hhf")

    begin MyProgram;

    START_LOOP:

         stdout.put("Hello user!");

    jmp START_LOOP;

    end MyProgram;
    Answer:
  2. What is the output of the following HLA program?
    program MyProgram;

    #include ("stdlib.hhf")

    begin MyProgram;

    mov(10, al);
    mov(1, cl);

    START_LOOP:

         cmp(cl, al);
         jae END_LOOP;

         stdout.put((type uns8 cl), " ");
         inc(cl);
         jmp START_LOOP;

    END_LOOP:

         stdout.put(nl, "End.", nl);

    end MyProgram;
    Answer:
  3. What is the output of the following HLA program?
    program MyProgram;

    #include ("stdlib.hhf")

    begin MyProgram;

    mov(10, al);
    mov(10, cl);

    START_LOOP:

         cmp(cl, al);
         jae END_LOOP;

         stdout.put((type uns8 cl), " ");
         inc(cl);
         jmp START_LOOP;

    END_LOOP:

         stdout.put(nl, "End.", nl);

    end MyProgram;
    Answer:
  4. Does the code in question #3 above behave more like a while-endwhile loop or a repeat-until loop in HLA?
    Answer:
  5. What is the output of the following HLA program?
    program MyProgram;

    #include ("stdlib.hhf")

    begin MyProgram;

    mov(10, al);
    mov(10, cl);

    START_LOOP:

         stdout.put((type uns8 cl), " ");
         inc(cl);
         cmp(cl, al);
         jae END_LOOP;

         jmp START_LOOP;

    END_LOOP:

         stdout.put(nl, "End.", nl);

    end MyProgram;
    Answer:
  6. Does the code in question #5 above behave more like a while-endwhile loop or a repeat-until loop in HLA?
    Answer:
  7. Convert the following high-level loop into assembly.
    mov(0, cl);
    while (cl < 5) do

         stdout.put("*");
         inc(cl);

    endwhile;

    Answer:
  8. Convert the following high-level loop into assembly.
    mov(0, cl);
    repeat

         stdout.put("*");
         inc(cl);

    until (cl == 5);

    Answer:
  9. Convert the following high-level loop into assembly.
    for (mov(0, cl); cl<5; inc(cl)) do

         stdout.put("*");

    endfor;

    Answer:
  10. Convert the following high-level loop AND the decision inside of it into assembly.
    mov(0, cl);

    forever

         if (cl < 5) then
              stdout.put("*");
              inc(cl);
         else
              break;
         endif;

    endfor;

    Answer:

Total points for this book learning challenge:

150 points