Mandelbrot set viewer for the ARM Mbed platform

Dependencies:   mbed DmTftLibrary

Mbed Mandelbrot Viewer

Touch-based mandelbrot set viewer for the ARM Mbed platform. Designed with the NXP LPC1768 and the DisplayModule DM-TFT28-116. It should be easy to adapt for any DisplayModule product, especially if it has an I2C touch controller.

On screen options allow the user to switch between 256*(2^n) maxiters up to 4096, and three rendering kernels using floats, integers, and integers in ARMv7 ASM.

Committer:
ofrasier
Date:
Fri Dec 07 01:00:54 2018 +0000
Revision:
3:835c035b8b1c
Parent:
2:e8d2bde86ff9
Combined ADD-LSL

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ofrasier 1:a1d80c69e1f0 1 AREA drawASM, CODE, READONLY
ofrasier 1:a1d80c69e1f0 2 EXPORT escapeTime
ofrasier 1:a1d80c69e1f0 3
ofrasier 1:a1d80c69e1f0 4 ; ASM subroutine of escape time algorithm
ofrasier 1:a1d80c69e1f0 5 ; R0 contains cx
ofrasier 1:a1d80c69e1f0 6 ; R1 contains cy
ofrasier 1:a1d80c69e1f0 7 ; R2 contains maxiters
ofrasier 1:a1d80c69e1f0 8 ; R3 contains counter
ofrasier 1:a1d80c69e1f0 9 ; R4 contains zx
ofrasier 1:a1d80c69e1f0 10 ; R5 contains zy
ofrasier 1:a1d80c69e1f0 11 ; R6 contains 4 << 24 = 67108864 escape CMP
ofrasier 1:a1d80c69e1f0 12 ; R7 Lo
ofrasier 1:a1d80c69e1f0 13 ; R8 Hi registers for SMULL for zx^2
ofrasier 1:a1d80c69e1f0 14 ; R9 Lo
ofrasier 1:a1d80c69e1f0 15 ; R10 Hi registers for SMULL for zy^2
ofrasier 1:a1d80c69e1f0 16 ; R11 Lo
ofrasier 1:a1d80c69e1f0 17 ; R12 Hi are scratch registers
ofrasier 1:a1d80c69e1f0 18 escapeTime
ofrasier 1:a1d80c69e1f0 19 PUSH {R4, R5, R6, R7, R8, R9, R10, R11, R12}
ofrasier 1:a1d80c69e1f0 20 MOV R3, #0
ofrasier 1:a1d80c69e1f0 21 MOV R4, R0
ofrasier 1:a1d80c69e1f0 22 MOV R5, R1
ofrasier 1:a1d80c69e1f0 23 MOV R6, #67108864
ofrasier 1:a1d80c69e1f0 24 iterate_loop_start
ofrasier 1:a1d80c69e1f0 25 CMP R3, R2 ; Exit loop if counter >= maxiters
ofrasier 1:a1d80c69e1f0 26 BGE iterate_loop_end
ofrasier 1:a1d80c69e1f0 27 SMULL R7, R8, R4, R4 ; Compute zx^2 and zy^2
ofrasier 1:a1d80c69e1f0 28 SMULL R9, R10, R5, R5 ; R7:R8 = zx^2 R9:R10 = zy^2
ofrasier 1:a1d80c69e1f0 29 ADD R12, R8, R10 ; Only check zx^2 + zy^2 < 4 with high-order
ofrasier 1:a1d80c69e1f0 30 CMP R12, R6 ; bits. Okay to ignore low order sum and carry
ofrasier 1:a1d80c69e1f0 31 BGE iterate_loop_end ; Escape condition
ofrasier 1:a1d80c69e1f0 32 SMULL R11, R12, R4, R5 ; Compute zy = 2*zx*zy + cy
ofrasier 2:e8d2bde86ff9 33 ASR R11, #28 ; Perform right shift by 28 places on R11:R12
ofrasier 2:e8d2bde86ff9 34 BFI R11, R12, #4, #28
ofrasier 3:835c035b8b1c 35 ADD R5, R1, R11, LSL #1 ; Add cy to twice R11 and store in R5
ofrasier 1:a1d80c69e1f0 36 SUBS R11, R7, R9 ; Compute zx = zx^2 - zy^2 + cx
ofrasier 2:e8d2bde86ff9 37 SBC R12, R8, R10
ofrasier 2:e8d2bde86ff9 38 ASR R11, #28 ; Perform right shift by 28 places on R11:R12
ofrasier 2:e8d2bde86ff9 39 BFI R11, R12, #4, #28
ofrasier 2:e8d2bde86ff9 40 ADD R4, R11, R0 ; Add cx and store in R4
ofrasier 1:a1d80c69e1f0 41 ADD R3, #1 ; Increment counter and loop
ofrasier 1:a1d80c69e1f0 42 B iterate_loop_start
ofrasier 1:a1d80c69e1f0 43 iterate_loop_end
ofrasier 1:a1d80c69e1f0 44 ; Move counter to R0 as the ret value
ofrasier 1:a1d80c69e1f0 45 MOV R0, R3
ofrasier 1:a1d80c69e1f0 46 POP {R4, R5, R6, R7, R8, R9, R10, R11, R12}
ofrasier 1:a1d80c69e1f0 47 BX LR
ofrasier 1:a1d80c69e1f0 48 END