掌機 - GKD Pixel - Assembly - Button



按鍵A是連接到PB-9,LCD背光則是由PC-14控制

PINL


MASK


PAT1


PAT0


GPIO組合設定表


main.s

    .extern _start
    .set noreorder
 
    .equiv LCD_BL,  14
    .equiv DELAY,   0x100000

    .equiv PA,      0xb0010000 
    .equiv PB,      0xb0011000 
    .equiv PC,      0xb0012000 
    .equiv PD,      0xb0013000 

    .equiv PXPINL,  0x0000 
    .equiv PXMSK,   0x0020 
    .equiv PXPAT1,  0x0030
    .equiv PXPAT0,  0x0040
 
    .text
    .ascii "LPSM"
 
    .rept 2044
    .byte 0
    .endr
 
_start:
    li $9, 0xffffffff
    li $8, PA + PXMSK
    sw $9, 0($8)
    li $8, PB + PXMSK
    sw $9, 0($8)
    li $8, PC + PXMSK
    sw $9, 0($8)
    li $8, PD + PXMSK
    sw $9, 0($8)
 
    li $9, 0
    li $8, PA + PXPAT1
    sw $9, 0($8)
    li $8, PB + PXPAT1
    sw $9, 0($8)
    li $8, PC + PXPAT1
    sw $9, 0($8)
    li $8, PD + PXPAT1
    sw $9, 0($8)
 
    li $9, 0xffffffff
    li $8, PA + PXPAT0
    sw $9, 0($8)
    li $8, PB + PXPAT0
    sw $9, 0($8)
    li $8, PC + PXPAT0
    sw $9, 0($8)
    li $8, PD + PXPAT0
    sw $9, 0($8)

    li $9, (1 << 9)
    li $8, PB + PXPAT1
    sw $9, 0($8)

loop:
    li $8, PB + PXPINL
    lw $9, 0($8)
    sll $9, 5
    not $9
    li $8, PC + PXPAT0
    sw $9, 0($8)
    b loop
    nop

完成