Microprocessor Simulator 0 Help



Download 1.18 Mb.
Page28/82
Date18.03.2021
Size1.18 Mb.
#56105
1   ...   24   25   26   27   28   29   30   31   ...   82
sms32v50 (3)
sms32v50 (3), sms32v50 (6)

Parameters


Example - 09param.asm

  1. Write a procedure that doubles a number. Pass the single parameter into the procedure using a register. Use the same register to return the result.

  2. Write a procedure to invert all the bits in a byte. All the zeros should become ones. All the ones should become zeros. Pass the value to be processed into the procedure using a RAM location. Return the result in the same RAM location.

  3. Write a procedure that works out Factorial N. This example shows one method for working out factorial N. Factorial 5 is 5 * 4 * 3 * 2 * 1 = 120. Your procedure should work properly for factorial 1, 2, 3, 4 or 5. Factorial 6 would cause an overflow. Use the stack to pass parameters and return the result. Calculate the result. Using a look up table is cheating!

  4. Write a procedure that works out Factorial N. Use the stack for parameter passing. Write a recursive procedure. Use this definition of Factorial.
    Factorial ( 0 ) is defined as 1.
    Factorial ( N ) is defined as N * Factorial (N - 1).
    To work out Factorial (N), the procedure first tests to see if N is zero and if not then re-uses itself to work out N * Factorial (N - 1). This problem is hard to understand in any programming language. In assembly code it is harder still.



Download 1.18 Mb.

Share with your friends:
1   ...   24   25   26   27   28   29   30   31   ...   82




The database is protected by copyright ©ininet.org 2024
send message

    Main page