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

Assembly language program THis program includes • a stub for a logical right shi

ID: 3869581 • Letter: A

Question

Assembly language program

THis program includes • a stub for a logical right shift subroutine, • a stub for a subroutine to print the contents of R0, in binary, on the console, • a completed main program to test your right shift and print subroutines.

You must:

• Implement and test the (binary) print subroutine.

• Implement and test the logical right-shift subroutine.

.ORIG x3000

LEA R1, DATA ;R1 = Data Pointer

LOOP

LDR R0, R1, #0 ;R0 = Next Test Datum

BRZ EXIT ; Exit if 0(sentinel)

JSR NEWLN

JSR PRINT ;Print Original Datum

JSR NEWLN

JSR SHIFT ;Right Shift Datum

JSR PRINT ;Print Shifted Datum

JSR NEWLN

ADD R1, R1, #1 ;Advance Data Pointer

BRNZP LOOP

EXIT

TRAP x25 ;Halt Execution

DATA .FILL x0010 ;Test Data

.FILL x0F60

.FILL x842B

.FILL 0

;**********************************************************

NEWLN ;Subroutine to output a NewLine character

ST R7, NEW7 ;Save Registers

ST R0, NEW0

LD R0, CRLF ;R0 = NewLine

TRAP X21 ;Output

LD R0, NEW0 ;Restore Registers

LD R7, NEW7

RET

NEW0 .BLKW 1 ;Register Save Area

NEW7 .BLKW 1

CRLF .FILL x0A ;NewLine Char

;**********************************************************

PRINT ;Subroutine to display the content of R0 in Binary

ST R7, PRT7 ;Save Registers

LD R7, PRT7

RET

PRT7 .BLKW 1

CHR0 .FILL x30 ;ASCII '0'

;**********************************************************

SHIFT ;Subroutine to perform a Logical Right Shift on R0

RET

.END

Explanation / Answer

.ORIG x3000

LEA R1, DATA ;R1 = Data Pointer

LOOP

LDR R0, R1, #0 ;R0 = Next Test Datum

BRZ EXIT ; Exit if 0(sentinel)

JSR NEWLN

JSR PRINT ;Print Original Datum

JSR NEWLN

JSR SHIFT ;Right Shift Datum

JSR PRINT ;Print Shifted Datum

JSR NEWLN

ADD R1, R1, #1 ;Advance Data Pointer

BRNZP LOOP

EXIT

TRAP x25 ;Halt Execution

DATA .FILL x0010 ;Test Data

.FILL x0F60

.FILL x842B

.FILL 0

;

NEWLN ;Subroutine to output a NewLine character

ST R7, NEW7 ;Save Registers

ST R0, NEW0

LD R0, CRLF ;R0 = NewLine

TRAP X21 ;Output

LD R0, NEW0 ;Restore Registers

LD R7, NEW7

RET

NEW0 .BLKW 1 ;Register Save Area

NEW7 .BLKW 1

CRLF .FILL x0A ;NewLine Char

;

PRINT ;Subroutine to display the content of R0 in Binary

ST R7, PRT7 ;Save Registers

LD R7, PRT7

RET

PRT7 .BLKW 1

CHR0 .FILL x30 ;ASCII '0';

SHIFT ;Subroutine to perform a Logical Right Shift on R0

RET

.END

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