From 383bdfc144c75d2a6eaea6002839f7c59d957368 Mon Sep 17 00:00:00 2001 From: Scott Allen Date: Mon, 28 Aug 2017 21:31:10 -0400 Subject: [PATCH] fix and clarify Sprite assembly comments --- src/Sprites.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Sprites.cpp b/src/Sprites.cpp index 29d684b..459e7f9 100644 --- a/src/Sprites.cpp +++ b/src/Sprites.cpp @@ -341,19 +341,20 @@ void Sprites::drawBitmap(int16_t x, int16_t y, [x_count] "l" (rendered_width), // lower register [sprite_ofs] "z" (bofs), [buffer_ofs] "x" (Arduboy2Base::sBuffer+ofs), - [buffer_ofs_jump] "a" (WIDTH-rendered_width), // lower register - [sprite_ofs_jump] "a" ((w-rendered_width)*2), // lower register + [buffer_ofs_jump] "a" (WIDTH-rendered_width), // upper reg (r16-r23) + [sprite_ofs_jump] "a" ((w-rendered_width)*2), // upper reg (r16-r23) // [sprite_ofs_jump] "r" (0), [yOffset] "l" (yOffset), // lower register [mul_amt] "l" (mul_amt) // lower register - // NOTE: We also clobber r28 and r29 but sometimes the compiler - // won't allow us so in order to make this work we don't tell it - // they we clobber them. Then we need to guarantee that the - // the compiler doesn't put one of our own variables into r28/r29. + // NOTE: We also clobber r28 and r29 (y) but sometimes the compiler + // won't allow us, so in order to make this work we don't tell it + // that we clobber them. Instead, we push/pop to preserve them. + // Then we need to guarantee that the the compiler doesn't put one of + // our own variables into r28/r29. // We do that by specifying all the inputs and outputs use either // lower registers (l) or simple (r16-r23) upper registers (a). - : // clobbers r28 and r29 + : // pushes/clobbers/pops r28 and r29 (y) ); break; }