Computer Science

Write an Assembly program that reads in a number of cents. The program will write out the number of dollars and cents separately.

Answers

Here is an example of an Assembly program that reads in a number of cents and writes out the number of dollars and cents separately: ORG 0000 ; Define the starting address MOV A, COUNT ; Move the current count into register A MOV B, #100 ; Load a divisor of 100 into register B DIV AB ; Divide A by B to get the result MOV DOLLARS, A ; Store the result in a label called DOLLARS MOV COUNT, R ; Store the remainder in a label called COUNT MOV A, COUNT ; Move the remainder into register A MOV B, #10 ; Load a divisor of 10 into register B DIV AB ; Divide A by B to get the result MOV CENTS, A ; Store the result in a label called CENTS STOP ; Stop the program COUNT DAT 0 ; Label for storing count DOLLARS DAT 0 ; Label for storing dollars CENTS DAT 0 ; Label for storing cents END ; End the program

Answered by Mark White

We have mentors from

Contact support