;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;SECTION NUMBER: ; ;GROUP MEMBER NAMES: ;1. ;2. ;3. ;4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Register Usage ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; R0- x-cordinate for Draw_Block Trap ; R1- y-cordinate for Draw_Block Trap ; R2 - Global X-coordinate; start point for displaying characters - DONOT TAMPER for local use ; R3 - Address in memory where bitmap for char is present ; R4 ; R5 ; R6 ; R7 - only store local values; You should be very careful when tampering with R7; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Memory Locations being used ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SCROLL_LOOP_COUNTER: memory location for storing current value for scroll loop counter ; COLUMN_LOOP_COUNTER: memory location for storing current value for column loop counter ; ROW_LOOP_COUNTER: memory location for storing current value for row loop counter ; BITMAP_A: Stores the address from where the bitmap of A starts (Look into hw6_bitmap.asm) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Hints to get you started: ; look for TODOs corresponding to each task in the code and you need to fill in few instructions as per the comment ; Test after adding few lines of code and see if it behaves the you want it to ; You should be using lc3os_mod.asm as your OS ; You must load bitmap file as file before running the program ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; program start ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .ORIG x3000 ; Start program at x3000 START: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; clear frame buffer on start ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; R5 is the pointer to the where the pixels will be written to the display LD R5,VIDEO ; Black pixel value LD R6,BLACK ; The size of the entire frame buffer (We are going to write the value of BLACK in the entire frame buffer) LD R3,TOT_SIZE INIT_FRAME_LOOP: ;I repeat this same operation 8 times, that way we can speed up the overall loop ;(8 writes/11 instructions instead of 1 write/4 instructions) STR R6,R5,#0 ; In this loop, we are storing the pixel in the appropriate location, then incrementing R5 STR R6,R5,#1 STR R6,R5,#2 STR R6,R5,#3 STR R6,R5,#4 STR R6,R5,#5 STR R6,R5,#6 STR R6,R5,#7 ADD R5,R5,#8 ;increment R5 by 8 ADD R3,R3,#-8 ;subtracting 8 because this operation is done 8 times. BRp INIT_FRAME_LOOP ; Initial start point -- GLOBAL X LD R2, X_START ; TODO initialize SCROLL_LOOP_COUNTER memory location to 10 LD R5, SCROLL_LOOP_COUNTER ADD R5, R5, #10 ST R5, SCROLL_LOOP_COUNTER SCROLL_LOOP: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; clear the display area ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LD R6,BLACK ; Black pixel value LD R3,DISPSIZE ; The size of the entire frame buffer (We are going to write the value of BLACK in the entire frame buffer) LD R5, VIDEO ; R5 is the pointer to the where the pixels will be written to the display LD R0, Y_START ; LD R1, FOUR_ROW_WIDTH ; Loop for updating R5 to coordinate (0, Y_START) SET_Y_OFFSET: ADD R5, R5, R1 ADD R0, R0, #-1 BRp SET_Y_OFFSET ; This loop is similar to init_frame_loop but clears only rows 6-13 CLR_DISPLAY_LOOP0: STR R6,R5,#0 ;I repeat this same operation 8 times, that way we can speed up the overall loop (8 writes/18 instructions instead of 1 write/4 instructions) STR R6,R5,#1 STR R6,R5,#2 STR R6,R5,#3 STR R6,R5,#4 STR R6,R5,#5 STR R6,R5,#6 STR R6,R5,#7 ADD R5,R5,#8 ADD R3,R3,#-8 ; Checking to see if the entire frame buffer has been written into BRp CLR_DISPLAY_LOOP0 ;subtracting 8 because this operation is done 8 times. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; first char ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Update X for first character -- local X AND R0, R0, #0 ADD R0, R2, #0 ; Update Y for first character LD R1, Y_START ; Put the address of Bitmap for char to be drawn LD R3, BITMAP_CHAR_A ; Load value BITMAP_WIDTH LD R6, BITMAP_WIDTH ; initialize ROW_LOOP_COUNTER to BITMAP_WIDTH ST R6, ROW_LOOP_COUNTER ROW_LOOP0: ; Load value BITMAP_WIDTH LD R4, BITMAP_WIDTH ; initialize COLUMN_LOOP_COUNTER to BITMAP_WIDTH ST R4, COLUMN_LOOP_COUNTER COLUMN_LOOP0: ; TODO load the bitmap value to R4 LDR R4, R3, #0 ; TODO (part 1): call conditional "TRAP 0x40" - dependent on value read into R4 BRz SKIP_TRAP0 TRAP x40 SKIP_TRAP0: ; TODO increment x ADD R0, R0, #1 ; TODO increment R3 to go to next location which contains bitmap for next element ADD R3, R3, #1 ; TODO: Load COLUMN_LOOP_COUNTER value from memory LD R4, COLUMN_LOOP_COUNTER ; TODO: decrement loop count ADD R4, R4, #-1 ; TODO: Update COLUMN_LOOP_COUNTER in memory ST R4, COLUMN_LOOP_COUNTER ; TODO: branch to column loop if positive BRp COLUMN_LOOP0 ; increment Y i.e. Y = Y + 1 ADD R1, R1, #1 ; decrement X by BITMAP_WIDTH i.e. X = X-7 LD R4, NEG_BITMAP_WIDTH ADD R0, R0, R4 ; Load ROW_LOOP_COUNTER value from memory LD R6, ROW_LOOP_COUNTER ; decrement the counter; counter = counter - 1 ADD R6, R6, #-1 ; Store the updated value back into memory ST R6, ROW_LOOP_COUNTER ; branch to column loop if positive BRp ROW_LOOP0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; end of first char ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; second char ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; TODO: Update X for next char - Add char length and little space LD R4, BITMAP_WIDTH ADD R0, R0, R4 LD R4, SPACE_BETWEEN_CHAR ADD R0, R0, R4 ; TODO: Update Y for next char LD R1, Y_START ; TODO: Update Bitmap Address for next char LD R3, BITMAP_CHAR_B ; initialize row loop counter to BITMAP_WIDTH LD R6, BITMAP_WIDTH ST R6, ROW_LOOP_COUNTER ROW_LOOP1: ; initialize column loop counter to BITMAP_WIDTH LD R4, BITMAP_WIDTH ST R4, COLUMN_LOOP_COUNTER COLUMN_LOOP1: ; load the bitmap value to R7 LDR R4, R3, #0 ; conditional TRAP to draw BRz SKIP_TRAP1 TRAP x40 SKIP_TRAP1: ; increment x ADD R0, R0, #1 ; increment R3 to go to next location which contains bitmap for next element ADD R3, R3, #1 ; Load COLUMN_LOOP_COUNTER value from memory LD R4, COLUMN_LOOP_COUNTER ; decrement loop count ADD R4, R4, #-1 ; Update COLUMN_LOOP_COUNTER in memory ST R4, COLUMN_LOOP_COUNTER ; branch to column loop if positive BRp COLUMN_LOOP1 ; increment Y i.e. Y = Y + 1 ADD R1, R1, #1 ; decrement X by BITMAP_WIDTH i.e. X = X-7 LD R4, NEG_BITMAP_WIDTH ADD R0, R0, R4 ; Load ROW_LOOP_COUNTER value from memory LD R6, ROW_LOOP_COUNTER ; decrement the value by 1 ADD R6, R6, #-1 ; Store into memory ST R6, ROW_LOOP_COUNTER ; branch to row loop if positive BRp ROW_LOOP1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; end of second char ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; TODO: update GLOBAL X ADD R2, R2, #-1 ;;;; wait for some time LD R0, SPIN_TIME SPIN0: ADD R0, R0, #-1 BRp SPIN0 LD R0, SPIN_TIME SPIN1: ADD R0, R0, #-1 BRp SPIN1 ; TODO: Load value of SCROLL_LOOP_COUNTER from memory LD R5, SCROLL_LOOP_COUNTER ; TODO Decrement the value by 1 ADD R5, R5, #-1 ; TODO Store the SCROLL_LOOP_COUNTER in memory ST R5, SCROLL_LOOP_COUNTER ; TODO: Branch to SCROLL_LOOP if SCROLL_LOOP_COUNTER is positive BRp SCROLL_LOOP ; stop HALT SPIN_TIME: .FILL 32767 ; start from row - 6 i.e. Y = 6 Y_START: .FILL 6 ; global start for X i.e. X = 1 X_START: .FILL 1 ; Space between 2 characters - 1 block SPACE_BETWEEN_CHAR: .FILL 1 ; Space taken by each character CHAR_LEN: .FILL 7 ; Counter for SCROLL_LOOP SCROLL_LOOP_COUNTER: .FILL 0 ; Counter for COLUMN_LOOP COLUMN_LOOP_COUNTER: .FILL 0 ; Counter for ROW_LOOP ROW_LOOP_COUNTER: .FILL 0 ; Start Address of Bitmap of A in memory BITMAP_CHAR_A: .FILL 0x5000 ;; TODO: FILL IN ADDRESS for BITMAP_B here BITMAP_CHAR_B: .FILL 0x5031 ;;; assuming 7x7 bitmap available row wise BITMAP_WIDTH: .FILL 7 NEG_BITMAP_WIDTH: .FILL -7 VIDEO: .FILL 0xC000 ; color value for BLUE COLOR: .FILL 0x001F ; color value for BLACK BLACK: .FILL 0x0000 ; color value for WHITE WHITE: .FILL 0xffff DISPSIZE: .FILL 0xE00 TOT_SIZE: .FILL 0x3E00 ROW_WIDTH: .FILL 0x80 FOUR_ROW_WIDTH: .FILL 0x200 ; Memory locations for register saving DB_R0: .FILL 0x0 DB_R1: .FILL 0x0 DB_R2: .FILL 0x0 DB_R3: .FILL 0x0 DB_R4: .FILL 0x0 DB_R5: .FILL 0x0 DB_R6: .FILL 0x0 DB_R7: .FILL 0x0 .END