Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

07. (6 regular points - up to 14 extra points) [Steering Code BXF FF - please disregard] Write a program in the machine code (use

image text in transcribedimage text in transcribed

07. (6 regular points - up to 14 extra points) [Steering Code BXF FF - please disregard] Write a program in the machine code (use the code presented in the lecture and given after the problems). Solve problem A, problem B or problem C depi whether you see the letter A, B or C in the next line (and careful, the problems A, B and C differ as well in each exam ;)): Your problem: A Problem A (12 extra points): Write machine code that calculates the division of positive numbers 'm' (dividend) and 'n' (divisor), 'm' is stored in memory cell F016, and '-n' is stored in m cell F916. Assume, 'm' is a multiple of 'n' Store the result of the division in memory cell BB16. 'm' and 'n' are in 2's-complement code. Remember: Multiplication can be done by a series of additions, division can be done by a series of subtractions. Assume that there are no overflow issues whatsoever. Problem B (14 extra points): Write machine code that inverts a given number 'n' stored in memory cell AA16 up to the first bit (counting from the left, hence do the inversion one step a time from left to right using a loop). Remember 100000002 is 8016- Problem C (14 extra points) Write machine code that finds the "last number 1" (towards the less significant bits) in a given number 'n' being stored in memory cell AA16. Store the posi this number in memory cell BB16. The least significant bit has position 1, the most significant bit the position 8. If required: 100000002 is 8016, 000000012 4/3 MACHINE CODE INFORMATICS I Op-Code Ope- rand Description 1 RXY LOAD the register R with the bit pattern found in the memory cell whose address is XY. 2 RXY LOAD the register R with the bit pattern XY. 3 RXY STORE the bit pattern found in register R in the memory cell whose address is XY. 4 ORS MOVE the bit pattern found in register R to register S. 5 RST ADD the bit patterns in registers S and T as though they were two's complement representations and leave the result in register R. 6 RST ADD the bit patterns in registers S and T as though they represented values in floating-point notation and leave the floating-point result in register R. 7 RST OR the bit patterns in registers S and T and place the result in register R. 8 RST AND the bit patterns in registers S and T and place the result in regis- ter R. 9 RST EXCLUSIVE OR the bit patterns in registers S and T and place the re- sult in register R. ROTATE the bit pattern in register R one bit to the right x times. Each time place the bit that started at the low-order end at the high-order end. A ROX B RXY JUMP to the instruction located in the memory cell at address XY if the bit pattern in register R is equal to the bit pattern in register number 0. Otherwise, continue with the normal sequence of execution. (The jump is implemented by copying XY into the program counter during the execute phase.) 000 HALT execution. R, S, T, X and Y are placeholders for hexadecimal figures. R, S, T indicate the numbers of regis- ters, X and Y specify a memory cell or a number in op-code "A". 5/3 End 07. (6 regular points - up to 14 extra points) [Steering Code BXF FF - please disregard] Write a program in the machine code (use the code presented in the lecture and given after the problems). Solve problem A, problem B or problem C depi whether you see the letter A, B or C in the next line (and careful, the problems A, B and C differ as well in each exam ;)): Your problem: A Problem A (12 extra points): Write machine code that calculates the division of positive numbers 'm' (dividend) and 'n' (divisor), 'm' is stored in memory cell F016, and '-n' is stored in m cell F916. Assume, 'm' is a multiple of 'n' Store the result of the division in memory cell BB16. 'm' and 'n' are in 2's-complement code. Remember: Multiplication can be done by a series of additions, division can be done by a series of subtractions. Assume that there are no overflow issues whatsoever. Problem B (14 extra points): Write machine code that inverts a given number 'n' stored in memory cell AA16 up to the first bit (counting from the left, hence do the inversion one step a time from left to right using a loop). Remember 100000002 is 8016- Problem C (14 extra points) Write machine code that finds the "last number 1" (towards the less significant bits) in a given number 'n' being stored in memory cell AA16. Store the posi this number in memory cell BB16. The least significant bit has position 1, the most significant bit the position 8. If required: 100000002 is 8016, 000000012 4/3 MACHINE CODE INFORMATICS I Op-Code Ope- rand Description 1 RXY LOAD the register R with the bit pattern found in the memory cell whose address is XY. 2 RXY LOAD the register R with the bit pattern XY. 3 RXY STORE the bit pattern found in register R in the memory cell whose address is XY. 4 ORS MOVE the bit pattern found in register R to register S. 5 RST ADD the bit patterns in registers S and T as though they were two's complement representations and leave the result in register R. 6 RST ADD the bit patterns in registers S and T as though they represented values in floating-point notation and leave the floating-point result in register R. 7 RST OR the bit patterns in registers S and T and place the result in register R. 8 RST AND the bit patterns in registers S and T and place the result in regis- ter R. 9 RST EXCLUSIVE OR the bit patterns in registers S and T and place the re- sult in register R. ROTATE the bit pattern in register R one bit to the right x times. Each time place the bit that started at the low-order end at the high-order end. A ROX B RXY JUMP to the instruction located in the memory cell at address XY if the bit pattern in register R is equal to the bit pattern in register number 0. Otherwise, continue with the normal sequence of execution. (The jump is implemented by copying XY into the program counter during the execute phase.) 000 HALT execution. R, S, T, X and Y are placeholders for hexadecimal figures. R, S, T indicate the numbers of regis- ters, X and Y specify a memory cell or a number in op-code "A". 5/3 End

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions