Skip to content

Commit

Permalink
[Chapter 13] Most importantly: Fixed distance. Also, made makefile nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
below committed Jul 30, 2020
1 parent 9d02e41 commit 5cd41ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Chapter 13/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// X20 - address to current set of points

.global main // Provide program starting address to linker
.align 4

//

Expand All @@ -14,7 +15,8 @@ main:
STP X19, X20, [SP, #-16]!
STR LR, [SP, #-16]!

LDR X20, =points // pointer to current points
ADRP X20, points@PAGE // pointer to current points
ADD X20, X20, points@PAGEOFF

MOV W19, #N // number of loop iterations

Expand All @@ -28,9 +30,11 @@ loop: MOV X0, X20 // move pointer to parameter 1 (r0)
FMOV S2, W0 // move back to fpu for conversion
FCVT D0, S2 // convert single to double
FMOV X1, D0 // return double to r2, r3
STR X1, [SP, #-16]!
ADRP X0, prtstr@PAGE // load print string
ADD X0, X0, prtstr@PAGEOFF
BL _printf // print the distance
ADD SP, SP, #16

ADD X20, X20, #(8*4) // 8 elements each 4 bytes
SUBS W19, W19, #1 // decrement loop counter
Expand Down
6 changes: 3 additions & 3 deletions Chapter 13/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ else
DEBUGFLGS =
endif

LDFLAGS = -lc -e main
CFLAGS = -lc -e main

all: distance matrixmultneon

%.o : %.s
as $(DEBUGFLGS) $(LSTFLGS) $< -o $@

distance: distance.s main.s
clang $(LDFLAGS) -g -o distance distance.s main.s
clang $(CFLAGS) $(DEBUGFLGS) -o distance distance.s main.s

matrixmultneon: matrixmultneon.s
clang $(LDFLAGS) -g -o matrixmultneon matrixmultneon.s
clang $(CFLAGS) $(DEBUGFLGS) -o matrixmultneon matrixmultneon.s

0 comments on commit 5cd41ac

Please sign in to comment.