diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2024-09-11 07:32:44 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-09-12 20:10:45 -0700 |
| commit | b56a667ecdb9f34dbd60d247d4237bc008755979 (patch) | |
| tree | 52f200c6650f96d4d6d699ef64f642cc1621a05e /lib/std/start.zig | |
| parent | cf691543323be9bb663aac2d19f62412435a4d39 (diff) | |
| download | zig-b56a667ecdb9f34dbd60d247d4237bc008755979.tar.gz zig-b56a667ecdb9f34dbd60d247d4237bc008755979.zip | |
start: Rewrite arm code to work for thumb1 too.
0ecc6332b4eb1ced547ffa38f57471134aaa4d13 improved things for thumb2, but thumb1
has a much smaller permissible instruction set. This commit makes that work.
Diffstat (limited to 'lib/std/start.zig')
| -rw-r--r-- | lib/std/start.zig | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 5c94a4b591..a8109f7ed9 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -280,12 +280,14 @@ fn _start() callconv(.Naked) noreturn { \\ b %[posixCallMainAndExit] , .arm, .armeb, .thumb, .thumbeb => - \\ mov fp, #0 - \\ mov lr, #0 + // Note that this code must work for Thumb-1. + \\ movs v1, #0 + \\ mov fp, v1 + \\ mov lr, v1 \\ mov a1, sp - \\ mov ip, sp - \\ and ip, ip, #-16 - \\ mov sp, ip + \\ subs v1, #16 + \\ ands v1, a1 + \\ mov sp, v1 \\ b %[posixCallMainAndExit] , .csky => |
