From 57f02f16e96a1a24466eeb6f1dadbd5353c6b2e6 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 22 Jan 2019 03:47:47 +0000 Subject: [PATCH] Fix byte ordering in GENERATE/NSECTS. --- src/compiler/machines/aarch64/rules3.scm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/compiler/machines/aarch64/rules3.scm b/src/compiler/machines/aarch64/rules3.scm index 9e764240d..5529cb44e 100644 --- a/src/compiler/machines/aarch64/rules3.scm +++ b/src/compiler/machines/aarch64/rules3.scm @@ -793,10 +793,10 @@ USA. (define (generate/nsects nsects) (let ((n (vector-length nsects))) (define (adjoin/be byte word bits) - (bitwise-ior (shift-left byte bits) word)) - (define (adjoin/le byte word bits) bits (bitwise-ior byte (shift-left word 8))) + (define (adjoin/le byte word bits) + (bitwise-ior (shift-left byte bits) word)) (define adjoin (case endianness ((BIG) adjoin/be) @@ -806,13 +806,15 @@ USA. ((i (* (quotient (+ n 7) 8) 8)) (words (LAP))) (if (< 0 i) - (let subloop ((j 0) (word 0)) - (if (< j 8) - (let ((byte (if (< (+ i j) n) (vector-ref nsects (+ i j)) 0))) - (subloop (+ j 1) (adjoin byte word (* j 8)))) - (loop (- i 8) - (LAP (DATA 64 U ,word) - ,@words)))) + (let ((i (- i 8))) + (let subloop ((j 0) (word 0)) + (if (< j 8) + (let ((byte + (if (< (+ i j) n) (vector-ref nsects (+ i j)) 0))) + (subloop (+ j 1) (adjoin byte word (* j 8)))) + (loop i + (LAP (DATA 64 U ,word) + ,@words))))) words)))) (define (generate/constants-block constants references assignments -- 2.25.1