87.4k views
4 votes
Write a machine-language program to add the three numbers 2, –3, and 6 and output the sum on the output device. Write it in a format suitable for the loader and execute it on the Pep/8 simulator.

User Kymberlie
by
4.5k points

2 Answers

2 votes

Final answer:

To add the numbers 2, -3, and 6 using machine-language on the Pep/8 simulator, you can use the provided assembly code.

Step-by-step explanation:

To write a machine-language program to add the three numbers 2, -3, and 6 and output the sum on the Pep/8 simulator, you can use the following assembly code:

lda 2 ; Load the first number into the accumulator
add -3 ; Add the second number to the accumulator
add 6 ; Add the third number to the accumulator
out ; Output the sum to the output device
hlt ; Halt the program

After writing the code in a text editor, save it with a .p8 extension, and load it into the Pep/8 simulator. Then, execute the program to see the sum displayed on the output device.

In this program, the 'lda' instruction is used to load a value into the accumulator, 'add' is used to perform addition, 'out' is used to output the result, and 'hlt' is used to halt the program.

User MasterAler
by
4.1k points
2 votes

Answer:

Below is the code ...hope it meet the requirements

lda 0, i

adda 6, i

suba 3, i

adda 2, i

STA 0x0010 ,d

CHARO 0x0010 ,d

.end

Step-by-step explanation:

User Bojangles
by
4.6k points