| ▲ | Writing Portable ARM64 Assembly (2023)(ariadne.space) |
| 44 points by luu 3 days ago | 17 comments |
| |
|
| ▲ | t-3 4 hours ago | parent | next [-] |
| > You will also need to be aware of minor differences between the Darwin ABI and other platform ABIs. A notable example is that the x18 register is reserved by the Darwin ABI and is explicitly zeroed on context switches in some cases. This register is also reserved on Android, but not on GNU/Linux or Alpine. x18 is "the platform register", reserved for the OS. The ISA manual says not to touch it unless you know what you're doing. Also, I don't know but I could believe that android and non-googly linux use different ABIs (but probably not because everyone uses pretty much the same ABI on aarch64 from what I've seen), but surely Alpine is linux and has the same ABI as other linuxes. |
|
| ▲ | steve1977 3 hours ago | parent | prev | next [-] |
| > It just requires being aware of a few differences between the Mach-O and ELF ABIs, as well as knowing what Apple-specific syntax extensions to avoid. And completely ignoring PE and Windows on ARM. |
| |
| ▲ | makerofthings 3 hours ago | parent [-] | | I have been very successfully ignoring Windows on Arm since it first appeared :) | | |
| ▲ | steve1977 2 hours ago | parent [-] | | I understand the sentiment ;) But IMHO the title of the article is still a bit misleading or incomplete. |
|
|
|
| ▲ | crest 5 hours ago | parent | prev | next [-] |
| How is this code portable to other platforms if it assumes that clang implies macOS? |
|
| ▲ | pjmlp 4 hours ago | parent | prev [-] |
| Assembly was never portable, or do you think 6502 on Apple would work out of the box in a Gameboy or C64? |
| |
| ▲ | whobre 4 hours ago | parent | next [-] | | In 1981, one could write a z80 assembly program for cp/m and it would run on thousands of different computer models. | | |
| ▲ | pjmlp 3 hours ago | parent | next [-] | | As someone that was alive back then already, only if you never touched the hardware directly outside the CPU. Even the PC clones didn't had something like portable Assembly if you ventured outside 0x10h and 0x21h interrupts. | | |
| ▲ | MomsAVoxell 22 minutes ago | parent | next [-] | | I did it many times on CP/M and also DOS. Never ‘touching the hardware’ was attainable for a great deal many assembly programs. You could do a lot with 0x10h and 0x21h on DOS. | |
| ▲ | whobre 2 hours ago | parent | prev [-] | | Right. I am saying there is a difference between portable and non portable assembly code. If you interacted with the machine via call 05h interface, it was portable. If you accessed computer’s video memory buffer directly it wasn’t. | | |
| ▲ | MomsAVoxell 19 minutes ago | parent [-] | | Good portable assembly would stub the system stuff off, anyway, and once that was done for the cpu class in focus, it was very possible to have a thin HAL and write portable code. A great deal many successful products of the era were written in pure assembly this way. In any case, you could also get high performance multiplatform video/io assembly libraries on the market, soon enough, back in the day .. it begat a lot of Delphi units too, I seem to recall .. |
|
| |
| ▲ | steve1977 3 hours ago | parent | prev [-] | | of different CP/M computer models though, no? |
| |
| ▲ | foldr 4 hours ago | parent | prev [-] | | The article is perfectly clear: > The good news is that it is very easy to write assembly which targets Apple’s computers as well as the other 64-bit ARM devices running operating systems other than Darwin. | | |
| ▲ | pjmlp 3 hours ago | parent [-] | | As long as nothing outside the CPU itself gets used. | | |
| ▲ | foldr 3 hours ago | parent [-] | | Obviously. Who could possibly be writing ARM assembly code who is not also aware that system calls, etc. will vary across platforms? Sometimes you do seem to make negative comments just for the sake of it. | | |
| ▲ | pjmlp 2 hours ago | parent [-] | | So it isn't portable after all... | | |
| ▲ | foldr 2 hours ago | parent [-] | | If you can understand what someone means when they talk about a “small elephant”, then you can understand what they mean when they talk about “portable assembly”. In this case, the relevant point is that you can write ARM64 assembly routines that do useful work (e.g optimized matrix multiplication, or something like that) in such a way that they’ll work correctly on a number of different ARM64 platforms. |
|
|
|
|
|