ScottALot
Active Member
Hey Ya'll
So we're working with LC-3 assembly in my intro class, and we're working on some code that we have to modify to fulfill these requirements.
The code in question is
Any of you guys good with this?
So we're working with LC-3 assembly in my intro class, and we're working on some code that we have to modify to fulfill these requirements.
The code in question is
Code:
; inputs a 16-bit binary value from the keyboard (one bit at a time)
; puts the resulting value into register R3
; assume the user only types 0 or 1 (no error handling!)
.ORIG x3000
START
; initialize values
INIT LD R4, ASCIIDIFF ; to convert ASCII code to numberic value
AND R3, R3, R0 ; initialize number value to 0
LD R2, NBITS ; # bits to input (loop control)
; get a key from the keyboard
WAITKEY LDI R3, KBSR
BRzp WAITKEY
GOTKEY LDI R2, KBDR
; convert ASCII code to numeric value
CONVERT ADD R0, R0, R4
; shift register one position to the left (same as multiply by 2)
; then add in new bit value at the least-significant position
APPEND ADD R3, R3, R3
ADD R3, R3, R0
; decrement loop variable and iterate if non-zero
ITERATE ADD R2, R2, #-1
BRnp WAITKEY
; if the program gets here, then it's done and should stop
DONE HALT
; --- PROGRAM DATA ---
ASCIIDIFF .FILL XFFD0 ; difference between ASCII and numeric values
NBITS .FILL #16 ; # of bits to input
KBSR .FILL xFE00 ; keyboard status register address
KBDR .FILL xFE02 ; keyboard data register address
.END
Any of you guys good with this?