Skip to content

Commit

Permalink
[Chaper 12] Fixed output
Browse files Browse the repository at this point in the history
  • Loading branch information
below committed Jul 30, 2020
1 parent 94c9745 commit 1c709d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Chapter 12/debug.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
mov r1, #\reg
add r1, #'0' @ for %c
ldr r0, =ptfStr @ printf format str
mov r9, sp
str r1, [r9]
str r2, [r9, #8]
str r3, [r9, #16]
str r1, [sp, #-32]
str r2, [sp, #8]
str r3, [sp, #16]
bl _printf @ call printf
add sp, sp, #32
pop {r0-r4, lr} @ restore regs
.endm

Expand Down
3 changes: 2 additions & 1 deletion Chapter 12/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ loop: MOV X0, X20 // move pointer to parameter 1 (X0)
FMOV S2, W0 // move back to fpu for conversion
FCVT D0, S2 // convert single to double
FMOV X1, D0 // return double to X1
STR X1, [SP] // Push X1 onto the stack
STR X1, [SP, #-16]! // Push X1 onto the stack
ADRP X0, prtstr@PAGE // load print string
ADD X0, X0, prtstr@PAGEOFF
BL _printf // print the distance
ADD SP, SP, #16

ADD X20, X20, #(4*4) // 4 points each 4 bytes
SUBS W19, W19, #1 // decrement loop counter
Expand Down

0 comments on commit 1c709d8

Please sign in to comment.