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

LC-3 ASSEMBLY LANGUAGE CODE TEMPLATE: .ORIG x3000 ; Program begins here ;-------

ID: 3786684 • Letter: L

Question

LC-3 ASSEMBLY LANGUAGE

CODE TEMPLATE:

.ORIG x3000           ; Program begins here
;-------------
;Instructions
;-------------
LD R6, Convert_addr       ; R6 <-- Address pointer for Convert
LDR R1, R6, #0           ; R1 <-- VARIABLE Convert
;-------------------------------
;ENTER CODE HERE
;--------------------------------

HALT
;---------------  
;Data
;---------------
Convert_addr .FILL xD000   ; The address of where to find the data


.ORIG xD000           ; Remote data
Convert .FILL xABCD       ; <----!!!NUMBER TO BE CONVERTED TO BINARY!!!

;---------------  
;END of PROGRAM
;---------------  
.END

Objective The purpose of this assignment is to give students practice with Lyo, left-shifting, multiplying by 2, and useful 2's complement logic. High Level Description Load any valid number into a register from the memory address specified in your assn 3template and output it to the console as 16-bit two's complement binary (i.e. the native format of the LC-3) Note: Valid numbers are (#-32768, #327671 (decima or [x0000, xFFFF] (hex) Your Tasks You do not yet know how to take a multi-digit decimal number from user input and convert it to binary, so for this assignment you are going to get the assembler to do that part for you: you will use the .FILL pseudo-op to take a literal (decimal or hex, as you wish) and translate it into 16-bit two's comp. binary, and store that value in the indicated memory location; and then you will Load that value from memory into R1 You MUST use the provided assn3.asm template to set this up: it ensures that the number to be converted is always stored in the same location (the memory address specified in your template) so we can test your work; make sure you fully understand the code we provide At this point, your value will be stored in R1: it is now your job to extract the 1's and 0 sfrom the number and print them out to the console one by one, from left to right. Important things to consider: Recall the difference between a positive number and a negative number in 2's complement binary: if the most significant bit (MSB) is 0, the number is positive; if it is 1, the number is negative The BR instruction has parameters (n, z, p) which tell it to check whether a value is anch negative, zero, or positive (or any combination thereof). Once you are done inspecting the MSB, how would you shift the next bit into its place so you could perform the next iteration? (hint: the answer is in the objectives) Pseudocode: for(i 5 downto 0) if bit[i] is a 0) print a 0 else print a 1 shift left

Explanation / Answer

<------------------------------- Comments- Start-------------------------------------------->

//there ia a problem in understanding your code. I don't find how to proceed. I am providing you with one sample. Tell me if i need to add something or do something.

//This code will give you the output in Binary

<------------------------------- Comments- End-------------------------------------------->

DATA SEGMENT

     NUM DW 1234H

     RES DB 10 DUP ('$')

DATA ENDS

CODE SEGMENT

        ASSUME DS:DATA,CS:CODE

START:       

    MOV AX,DATA

    MOV DS,AX

   

    MOV AX,NUM

      

    LEA SI,RES

    CALL HEX2DEC

   

    LEA DX,RES

    MOV AH,9

    INT 21H

            

    MOV AH,4CH

    INT 21H        

CODE ENDS

HEX2DEC PROC NEAR

    MOV CX,0

    MOV BX,10

   

LOOP1: MOV DX,0

       DIV BX

       ADD DL,30H

       PUSH DX

       INC CX

       CMP AX,9

       JG LOOP1

     

       ADD AL,30H

       MOV [SI],AL

     

LOOP2: POP AX

       INC SI

       MOV [SI],AL

       LOOP LOOP2

       RET

HEX2DEC ENDP           

   

END START