I want to write "Hello World" without glibc, for this I need to write my little libc, I made some simple functions that do not require system calls, but now I want to make the write function so that the puts function works, but for write I need the syscall function, and In order to make syscall you need to know семmbrebre, but I don’t know him at all, I even ventured to try to write hello world, after a long googling and after several dozens of compilations, I saw "Hello World!" I got GG
__asm__( ".data;" "msg:" ".ascii \"Hello, world!\n\";" // Строка для вывода "len = . - msg;" // Записуем в переменную len длину msg ); void _start() { __asm__( "mov r0, #1;" // Запись в поток #1 - stdout "ldr r1, =msg;" // Указатель на строку "ldr r2, =len;" // Длина строки "mov r7, #4;" // Номер системного вызова - 4 (write) "swi 0;" // Системный вызов ядра ); __asm__( "mov r0, #0;" // Возращаемое значение - 0 "mov r7, #1;" // Номер системного вызова - 1 (exit) "swi 0;" // Системный вызов ядра ); }
As far as I understand, for a system call, you need to write to a variable (or they are registries, I don’t know how the first differs from the second) r7 call number, and r1, r2, r3 ... variables passed to the variables, but how to write the syscall(номер вызова,Аргументы...)
function syscall(номер вызова,Аргументы...)
I don’t know, I’ll either have to write it completely in Assembler, which I’m definitely not able to, or I can write C and pass arguments to Assembler, I don’t know how either.
Can anyone help write the syscall function for the arm?