Skip to main content
added 16 characters in body
Source Link
EasyasPi
  • 5k
  • 17
  • 22

Behold, the world's least efficienta prime searcher that is so slow you'd swear it was Python.

Behold, the world's least efficient prime searcher.

Behold, a prime searcher that is so slow you'd swear it was Python.

Minor fixes
Source Link
EasyasPi
  • 5k
  • 17
  • 22
main:
        push    {r0, r1, lr}
        mov     r1, sp
        adr     r0, printf_strprintf_scanf_str
        bl      scanf

Note that due to how pop works in Thumb, it isn't really that useful to do tail calls because we cannot pop directly into lr without a wide instruction.

printf("%d", r1)

main:
        push    {r0, r1, lr}
        mov     r1, sp
        adr     r0, printf_str
        bl      scanf

Note that due to how pop works in Thumb, it isn't really that useful to do tail calls.

main:
        push    {r0, r1, lr}
        mov     r1, sp
        adr     r0, printf_scanf_str
        bl      scanf

Note that due to how pop works in Thumb, it isn't really that useful to do tail calls because we cannot pop directly into lr without a wide instruction.

printf("%d", r1)

added 18 characters in body
Source Link
EasyasPi
  • 5k
  • 17
  • 22

Then, we can pop the result from scanf we stored into r0, and argv into r1 as thea "non-zero" value for our short circuit loop.

Immediately return true for values <= 2. This is exactly why we pushed and popped r1.

Then, we can pop the result from scanf we stored into r0, and argv into r1 as the "non-zero" value for our short circuit loop.

Immediately return true for values <= 2.

Then, we can pop the result from scanf we stored into r0, and argv into r1 as a "non-zero" value.

Immediately return true for values <= 2. This is exactly why we pushed and popped r1.

Source Link
EasyasPi
  • 5k
  • 17
  • 22
Loading