LCD背光連接到PC-14
Output
Data
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 PXPAT1, 0x0030 .equiv PXPAT0, 0x0040 .text .ascii "LPSM" .rept 2044 .byte 0 .endr _start: 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) loop: xor $9, (1 << LCD_BL) li $8, PC + PXPAT0 sw $9, 0($8) li $8, DELAY 0: addi $8, $8, -1 bnez $8, 0b nop b loop nop
main.ld
OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips", "elf32-tradlittlemips") OUTPUT_ARCH(mips) ENTRY(_start) SECTIONS { . = 0; .text : { *(.text) } .data : { *(.data) } .bss : { *(.bss) } }
Makefile
all: mipsel-linux-gnu-as -o main.o main.s mipsel-linux-gnu-ld -T main.ld -o main.elf main.o mipsel-linux-gnu-objcopy -O binary main.elf main.bin flash: sudo dd if=main.bin of=/dev/sdX bs=1K seek=17 clean: rm -rf main.bin main.o main.elf
編譯、燒錄到MicroSD
$ make mipsel-linux-gnu-as -o main.o main.s mipsel-linux-gnu-ld -T main.ld -o main.elf main.o mipsel-linux-gnu-objcopy -O binary main.elf main.bin $ make flash sudo dd if=main.bin of=/dev/sdX bs=1K seek=17 1+1 records in 1+1 records out 1232 bytes (1.2 kB, 1.2 KiB) copied, 0.023186 s, 53.1 kB/s
完成