bat/tests/syntax-tests/highlighted/ARM Assembly/test.S
2020-10-05 07:12:24 +02:00

55 lines
7.8 KiB
ArmAsm
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.data
.balign 4
red: .word 0
green: .word 0
blue: .word 0
.text
.global grayscale
.func grayscale
grayscale:
assign:
 /* some comment */
 ldr ip, addr_red
 str r3, [ip]
 ldr ip, addr_green
 ldmfd r13!, {r3}
 str r3, [ip]
 ldr ip, addr_blue
 ldmfd r13!, {r3}
 str r3, [ip]
 stmfd r13!, {r4-r8}
 ldr ip, addr_red
 ldr r3, [ip]
 ldr ip, addr_green
 ldr r4, [ip]
 ldr ip, addr_blue
 ldr r5, [ip] /* another comment */
grayscale_loop:
 ldrb r6, [r1]
 mul r6, r3, r6
 add r1, r1, #1
 ldrb r7, [r1]
 mul r7, r4, r7
 add r1, r1, #1
 ldrb r8, [r1]
 mul r8, r5, r8
 add r1, r1, #1
 add r6, r6, r7
 add r6, r6, r8
 asr r6, r6, #8
 str r6, [r2]
 add r2, r2, #1
 sub r0, r0, #1
 cmp r0, #0
 bne grayscale_loop
 ldmfd r13!, {r4-r8}
 stmfd r13!, {r0-r1}
 bx lr
addr_red: .word red
addr_green: .word green
addr_blue: .word blue