Question

Assume we have CPU instructions that look like this: load register, address save register, address Where...

  1. Assume we have CPU instructions that look like this: load register, address

    save register, address
    Where the instruction load copies the data pointed to by the address into the register, and the instruction save copies the data from the register into the location pointed to by address. Assume “register” can be the values R0 and R1, where each “R#” is the name of a single register that can store a single byte. Assume the “address” is an integer constant number.

    Assume at address 52 is the beginning of a string “ABC”. Assume at address 1 is the printer.

    Using only the above two instructions, write code that sends each byte of the string to the printer.

Homework Answers

Answer #1

Address 52 is the beginning of a string "ABC". Since each ASCII character is one byte, we can assume than address 52 and two consecutive addresses stores "A", "B","C", i.e. address 52 stores "A", address 53 stores "B", address 54 stores "C".

So code to send each byte of the string to the printer,

load R0, 52 (Copies data at address 52 to register 0)

save R0, 1   (Copies data from the register 0 to the printer at address 1)

load R1, 53 (Copies data at address 53 to register 1)

save R1, 1   (Copies data from the register 1 to the printer at address 1)

load R2, 54 (Copies data at address 54 to register 2)

save R2, 1 (Copies data from the register 2 to the printer at address 1)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT