View on GitHub

Computer Architecture and Operating Systems

Course taught at Faculty of Computer Science of Higher School of Economics

Lecture 5

Pseudo instructions, macros, and includes. Conditions, loops, loads, and stores.

Lecture

Slides (PDF, PPTX).

Outline

Examples:

Workshop

Outline

Tasks

  1. Write a program that inputs two integer values x and y and prints all the values in the range min(x, y)..max(x, y).

  2. Write a program that fills an array of 32 integers from values from the standard input. It reads values in a loop and finishes reading when all 32 values are read or when value 0 is read.

  3. Write a program that inputs two positive integer values N and D, finds their quatient (Q) and remainder (R) using the algorithm below, prints the result.

    function divide_unsigned(N, D)
        Q := 0; R := N
        while R ≥ D do
           Q := Q + 1
           R := R − D
        end
       return (Q, R)
    end
    
  4. Write your own macros print_hex and print_bin for printing values in hexadecimal and binary formats respectively. What if you want to print immediate values? What kind of macro do you need in this case?

  5. Write a program that inputs two unsigned integer values x and y, calculates x ** y (x raised to the power of y), and prints the result. The exponentiation should be implemented as a multiplication in a loop. If an overflow occurs, the program must exit the loop and print an error message.

Homework

Solve the following tasks:

  1. DoubleSum
  2. DigitSum
  3. PlusMinus
  4. EvenBack
  5. NoDups

Commit the programs to your private GitHub account. Place them into the folder ca/lab05.

References