vak: (Default)
[personal profile] vak
Если возникло желание разобраться с ассемблером, вовсе необязательно упираться именно в MMIX. Гораздо ближе будет архитектура ARM. А у меня макбук на процессоре Apple M2 и вовсе под рукой. Это тоже RISC процессор с 64-битной архитектурой. Но в отличие от MMIX вполне реальный и массово доступный. Да и всякие Raspberry Pi нынче везде.

Перепишу-ка я тот самый пример hi.S для архитектуры aarch64:
#define Halt    #1
#define Write   #4
#define StdOut  #1

        .text
        .align  2                   // Make sure everything is aligned properly

        .global _start
_start: mov     X0, StdOut          // Print to StdOut
        adr     X1, text            // Put address of text message into register X1
        mov     X2, #23             // Length of our string
        mov     X16, Write          // Unix write() system call
        svc     #0x80               // Call kernel to output the string

        mov     X0, #0              // Exit code
        mov     X16, Halt           // Unix _exit() system call
        svc     #0x80               // Call kernel to terminate the program

text:   .ascii  "Hi, aarch64 assembler!\n"
Компилируем, запускаем:
$ cc hi.S -o hi -e _start
$ ./hi
Hi, aarch64 assembler!
Кучу примеров для мака к книжке по ассемблеру ARM64 можно найти здесь: github.com/below/HelloSilicon
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org