;; ;; Author: Bill Slough ;; ;; Example of a subroutine in the LC-3 assembly language ;; ;; Lights one pixel on the video display ;; .ORIG x3000 LD R0,ROW LD R1,COLUMN LD R2,RED JSR DRAW_PIXEL ; draw_pixel(2, 8, RED) STOP HALT ROW .FILL 2 ; which row? COLUMN .FILL 8 ; which column? RED .FILL x7C00 ; desired color ROWS .FILL 124 ; Number of rows of the video display COLS .FILL 128 ; Number of columns of the video display DRAW_PIXEL ;; Draw a pixel on the graphics display unit ;; R0 - row ;; R1 - column ;; R2 - color ST R3,SAVE_R3 ; Save the registers modified within this routine ST R4,SAVE_R4 ADD R3,R0,#0 ; LD R4,PIXELS_PER_ROW ; MUL R3,R3,R4 ; ADD R3,R3,R1 ; R3 = PIXELS_PER_ROW * row + column LD R4,VIDEO_ADDR ADD R4,R4,R3 ; R4 = address of desired pixel STR R2,R4,#0 ; Video[row,column] = color LD R3,SAVE_R3 ; Restore the registers and exit LD R4,SAVE_R4 RET SAVE_R3 .BLKW 1 ; Save area for registers SAVE_R4 .BLKW 1 VIDEO_ADDR .FILL xC000 ; base address of the video display PIXELS_PER_ROW .FILL 128 ; number of pixels per row .END