Assembly Language Functions, embaded system, EECE 237
;
; EECE 237 S15
; Lab #2 Demo Code
;
AREA Lab2, CODE, READONLY
;ENTRY
EXPORT binary_disp
EXPORT hex_disp
EXTERN LCD_write
;------------------------------------------------------------------------------------------------
; binary_disp
;
; Displays the binary representation of the 16 bit value passed as a parameter
; on the 2nd row of the LCD screen (using call s C function LCD_write)
;
binary_disp PROC
PUSH {R4-R7} ; Save R5 since we modify it
MOV R5, #15 ; Loop control variable
loop
MOV R0, #1 ; Row = 1 means second row
MOV R1, R5 ; Column
MOV R2, #'0' ; 0 to be written
PUSH {R0-R6, LR}
BL LCD_write ; Write the character to the LCD
POP {R0-R6, LR}
SUBS R5, R5, #1 ; If count < 16, keep writing
BGE loop
POP {R4-R7} ; Restore R5
MOV R0, #42 ; totally fake return value
BX LR ; return
ENDP
;------------------------------------------------------------------------------------------------
; hex_display
;
; Displays the hex representation of the 16 bit value passed as a parameter
; on the 1st row of the LCD screen starting at column 11(using call s C function LCD_write)
;
hex_disp PROC
PUSH {R4-R7} ; Save R5 since we modify it
MOV R5, #4 ; Loop control variable
MOV R0, #0 ; Row = 0 means first row
MOV R1, #11 ; Column
MOV R2, #'A' ; Poor man's ASCII conversion - A..F
hloop
ADD R2, R2, #1
hwrite
PUSH {R0-R6, LR}
BL LCD_write ; Write the character to the LCD
POP {R0-R6, LR}
ADD R1, R1, #1
SUBS R5, R5, #1 ; If count < 5, keep writing
BGE hloop
POP {R4-R7} ; Restore R5
BX LR ; return
ENDP
END