Question: Implement and test LC-3 assembly language subroutines PUTBIN, PUTHEX and PUTDEC to display an unsigned integer in either Binary, Hexadecimal or Decimal format respectively. The

Implement and test LC-3 assembly language subroutines PUTBIN, PUTHEX and PUTDEC to display an unsigned integer in either Binary, Hexadecimal or Decimal format respectively. The algorithms described below always output 16 binary digits (PUTBIN) or 4 hexadecimal digits (PUTHEX). The number of decimal digits displayed (PUTDEC) depends on the magnitude of the integer.

Algorithms:

Binary

loop 16 times

Test datum[15] and output x30 (ASCII 0) or x31(ASCII 1) accordingly

Left_Shift( datum )

endloop

Hexadecimal

loop 4 times

Rotate_Left( datum ) 4 places

//b15b14b13b12 b11b10b9b8 b7b6b5b4 b3b2b1b0 b11b10b9b8 b7b6b5b4 b3b2b1b0 b15b14b13b12

Mask bits[15:4]

// b11b10b9b8 b7b6b5b4 b3b2b1b0 b15b14b13b12 0000 0000 0000 b15b14b13b12

Output the ASCII char corresponding to hexadecimal digit in bits[3:0]

endloop

Decimal

Obtain the individual decimal digits via repeated division by 10. Each numeric digit is converted into its ASCII character equivalent. Since the digits are obtained in reverse order, they should be stored into memory as they are obtained to form a 0-terminated character string (see diagram). Finally, print the string via the TRAP x22 instruction.

I need to implement these algorithms in LC- 3 Assembly language to transform an integer into binary, hexadecimal, and decimal can someone explain to me these algorithms?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!