Solve computational problems using assembly and machine
language.
As an example, suppose you are writing a program in a
text file to read and display a number. This program could be
written as follows:
Wombat 1.1 A function is defined as follows: f(n) = n-2 for n<1 n +5 for n = 1 m2 - 2n +1 forn > 1 Write Wombatl machine language program that reads an input integer value n, and computes and displays the output of the above function f(n). In the binary version of your programs that can be executed on the CPUSim simulator, you are also required to write as comments the line number/address, equivalent decimal version of the binary and appropriate comments to explain each line in your program. The decimal version of the program represents cach binary line as two decimal values (first value is the opcode - 4 bits; second value is the operand memory address - 12 bits). Therefore, each line of your program should be formatted as follows: Binary-number, Semi-colon, Line-number/address, Decimal-opcode, Decimal-operand address, Comments
- 0 х example - Notepad File Edit Format View Help þ011000000000000; 0: 30 0010000000101000; 2: 240 0110000000101010; 4: 6 42 1010000000011100; 6: 10 28 1011000000100000; 8: 11 32 0001000000101000; 10: 1 40 0111000000101100; 12: 7 44 0010000000101110 ; 14: 246 0001000000101000 ; 16: 1 40 0111000000101000; 18: 7 40 0111000000101000; 20: 7 40 0110000000101110; 22: 6 46 0101000000110000; 24: 5 48 1001000000100100 ; 26: 9 36 0001000000110010; 28: 1 50 1001000000100100; 30: 9 36 0001000000101000; 32: 1 40 Read n into acc Store n at location 40 Subtract constant 1 from acc jumpz to location 28 if n = 1 (5n + 5 = 8) jumpn to location 32 if n < 1 (n+1) Load n from location 40, for n > 1 (n^3 - 3n + 5) Multiply stored n value with constant 3 Store 3n value to location 46 Load n from location 40 again Multiply stored n value with value in acc to get n^2 Multiply stored n value with value in acc to get n^3) Subtract 3n from n^3 Add constant 5 to value in acc Jump to location 36 to write the answer Load Constant 8 from location 48 Jump to location 36 to write answer Load n from location 40, for n < 1
Solve computational problems using assembly and machine language. As an example, suppose you are writing a program in a
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Solve computational problems using assembly and machine language. As an example, suppose you are writing a program in a
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!