Question
Problem 6: (10 points) Write a machine-language program to add the three numbers 8, -5 and -2 and output the sum on the output device.
Problem 6: (10 points)
Write a machine-language program to add the three numbers 8, -5 and -2 and output the sum on the output device. Note-the inputs can be hard coded in data storage at the end of your code. The accumulator holds 16 bits so use 16-bit Twos Complement for the -7 and do not use the subtract instruction. Write it in a format suitable for the loader and execute it on the PEP/8 simulator. You may only use instructions in Fig 4.6. (Use the Fig 4.6 revised found with the HW2 assignment) You shall submit:
- A written algorithm
- Your commented program similar to the Machine Language (hex) of Fig 4.35
- The hexadecimal program suitable for the Pep/8 loader. (Cut & paste the text into your document so I can check your code)
- A screenshot of your program output screen
- Explain the range of numbers that this will work correctly
4.35
4.6
Pep/8 link (write code in this program)
http://computersystemsbook.com/4th-edition/pep8/
Machine Language (bin) 1100 0001 0000 0000 0001 0001 0111 0001 0000 0000 0001 0011 1010 0001 0000 0000 0001 0101 1111 0001 0000 0000 0001 0000 0101 0001 0000 0000 0001 0000 Address 0003 0006 0009 000C 000F 0010 0011 0013 0015 0000 0000 0000 0101 0000 0000 0000 0011 0000 0000 0011 0000 Address Machine Language (hex) C10011 :A first number 710013 :Add the two numbers A10015 Convert sum to character F10010 Store the character 510010 :0utput the character 0003 0006 0009 000C 000F 0010 0011 0013 0015 :Stop :Character to output - 00 0005 :Decimal 5 0003:Decimal 3 0030 :Mask for ASCII char Instruction Specifier HEX Instruction 0000 0001 0000 0010 0000 0011 Stop execution Returm from trap Move stack pointer (SP) to accumulator (A) Move NZVC flags to accumulator (A) 0000 010a 0000 01la 0000 100a 0000 101a 0000 110a 0000 111a 0001 000a 0001 001a 0001 010a 0001 011a 0001 100r 0001 101r 0001 110r 0001 111r 0010 000r 0010 001r Branch unconditional Branch if less than or equal to Branch if less than Branch if equal to Branch if not equal to Branch if greater than or equal to Branch if greater tharn Branch if V Branch if C Call subroutine 06 or 07 08 or 09 OC or OD Bitwise invert register r Negate register r Arithmetic shift left register r Arithmetic shift right register r Rotate left register r Rotate right register r or 19 or 1D 001001n 0010 laaa 24 - 27 28 2F Unimplemented opcode, unary trap Unimplemented opcode, nonunary trap 0011 0aaa 0011 laaa 0100 0aaa 0100 laaa 0101 0aaa 30 37 38 3F 40 47 Unimplemented opcode, nonunary trap Unimplemented opcode, nonunary trap Unimplemented opcode, nonunary trap Character input Character output 0101 Inn 0110 0aaa 0110 laaa 50 57 58 5F 60 67 Return from call with n local bytes Add to stack pointer (SP) Subtract from stack pointer (SP) 1000 raaa 1001 raaa 1010 raaa 011 raaa 80 8F 90 9F AO AF BO BF Add to register r Subtract from register r Bitwise AND to register r Bitwise OR to register r Compare register r 1100 raaa CO CF Load register r from memory Machine Language (bin) 1100 0001 0000 0000 0001 0001 0111 0001 0000 0000 0001 0011 1010 0001 0000 0000 0001 0101 1111 0001 0000 0000 0001 0000 0101 0001 0000 0000 0001 0000 Address 0003 0006 0009 000C 000F 0010 0011 0013 0015 0000 0000 0000 0101 0000 0000 0000 0011 0000 0000 0011 0000 Address Machine Language (hex) C10011 :A first number 710013 :Add the two numbers A10015 Convert sum to character F10010 Store the character 510010 :0utput the character 0003 0006 0009 000C 000F 0010 0011 0013 0015 :Stop :Character to output - 00 0005 :Decimal 5 0003:Decimal 3 0030 :Mask for ASCII char Instruction Specifier HEX Instruction 0000 0001 0000 0010 0000 0011 Stop execution Returm from trap Move stack pointer (SP) to accumulator (A) Move NZVC flags to accumulator (A) 0000 010a 0000 01la 0000 100a 0000 101a 0000 110a 0000 111a 0001 000a 0001 001a 0001 010a 0001 011a 0001 100r 0001 101r 0001 110r 0001 111r 0010 000r 0010 001r Branch unconditional Branch if less than or equal to Branch if less than Branch if equal to Branch if not equal to Branch if greater than or equal to Branch if greater tharn Branch if V Branch if C Call subroutine 06 or 07 08 or 09 OC or OD Bitwise invert register r Negate register r Arithmetic shift left register r Arithmetic shift right register r Rotate left register r Rotate right register r or 19 or 1D 001001n 0010 laaa 24 - 27 28 2F Unimplemented opcode, unary trap Unimplemented opcode, nonunary trap 0011 0aaa 0011 laaa 0100 0aaa 0100 laaa 0101 0aaa 30 37 38 3F 40 47 Unimplemented opcode, nonunary trap Unimplemented opcode, nonunary trap Unimplemented opcode, nonunary trap Character input Character output 0101 Inn 0110 0aaa 0110 laaa 50 57 58 5F 60 67 Return from call with n local bytes Add to stack pointer (SP) Subtract from stack pointer (SP) 1000 raaa 1001 raaa 1010 raaa 011 raaa 80 8F 90 9F AO AF BO BF Add to register r Subtract from register r Bitwise AND to register r Bitwise OR to register r Compare register r 1100 raaa CO CF Load register r from memoryStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started