// -------MAKEFILE------- # Change this line to point to your own installation of qemu-system-arm 4.1.0. QSA = ~/Applications/QEMU/qemu-4.1.0/build/arm-softmmu/qemu-system-arm main: main.s arm-none-eabi-as -o main.o main.s arm-none-eabi-ld -o main main.o run: main $(QSA) -machine raspi2 -kernel main clean: rm -f main rm -f *.o // -------ASSEMBLY PROGRAM------- // Exports .globl _start // Data .section .data .align 2 Counter: .int 0 // Code .section .text .align 2 _start: address .req r0 counter .req r1 color .req r2 hwords .req r3 // Read the counter from memory, increment it, and write it back. // Commenting out the fourth line results in only one stripe being // drawn, while leaving it in results in up to four stripes being // drawn. ldr address, =Counter ldr counter, [r0] add counter, #1 str counter, [r0] // Use the counter to determine the starting offset from the top // of the screen ldr address, =0x3C100000 // screen base address add address, counter, lsl #16 // For extra clarity, use the counter to decide what color to write mov color, #0 add color, counter, lsl #2 mov r4, #4 sub r4, r4, counter add color, r4, lsl #9 // Write 4000 half-words starting at the computed offset mov hwords, #4000 loop$: strh color, [address] add address, #2 subs hwords, #1 bne loop$ halt: b halt