Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3.2 - Write a program that displays the contents of ten bytes of the main memory

ID: 669685 • Letter: 3

Question

3.2 - Write a program that displays the contents of ten bytes of the main memory in hexadecimal format on a line of a display device. The ten bytes start at location LOC in the memory, and there are two hex characters per byte. The contents of successive bytes should be separated by a space when displayed.

3.9 - Assume that a memory location BINARY contains a 16-bit pattern. It is desired to display these bits as a string of 0s and 1s on a display device that has the interface depicted in Figure 3.3. Write a RISC-style program that accomplishes this task.

Explanation / Answer

3.9- Please attach the figure in question for better solution to it.

3.2-

In hexadecimal the values 10 to 15 are represented by A-F. to convert them to ASCII add $37 to their binary number. Similary for 0-9 in hex,add $30 to their binary number.

the output status bit is b4 in register Status, and the output data register
is Output.


                   Move #10,R0                        Use R0 as counter
                   Move #LOC,R1                       Use R1 as pointer
Next            Move (R1),R2                       Get next byte
                   Move R2,R3
                   Shift-right #4,R3                  Prepare bits b7 -b4
                   Call Convert
        Move R2,R3                        Prepare bits b3-b0
                   Call Convert
        Move $20,R3                       Print space
                    Call Print
        Increment R1
                   Decrement R0
                   Branch> 0 Next                    Repeat if more bytes left
                    End

Convert       And #0F,R3                  Keep only low-order 4 bits
        Compare #9,R3
                   Branch>= 0 Letters                  Branch if [R3]>= 9
                   Or #$30,R3                          Convert to ASCII, for values 0 to 9
                    Branch Print

Letters Add #$37,R3                       Convert to ASCII, for values 10 to 15
Print              BitTest #4,Status                    Test output status bit
      Branch=0 Print Loop back if equal to 0
     Move R3,Output                              Send character to output register
                      Return

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote