/CASM/ - C&Assembly general
Anonymous 01/21/25(Tue)02:09:32 | 7 comments | 1 images | 🔒 Locked
What are you working on anon?
Tensor Library in C: https://github.com/apoorvnandan/tensor.h
Writing a Linux debugger: https://blog.tartanllama.xyz/writing-a-linux-debugger-setup/
FFMPEG assembly lessons (disable suggestions and/or download as PDF): https://docs.google.com/document/d/1cemgw6mZBWyIx7ARLv2mscpcJQQsNXK9MNspZvqtoxI/edit?pli=1&tab=t.0
https://docs.google.com/document/d/1tbnZv5jlDvw2z2yJ_Ip2p9q5SI27XJg4ZwHiY5hNdaE/edit?tab=t.0
https://docs.google.com/document/d/1zP-iO0vJTcEx1iMx3p0KQ5yJSQ64pXQf1R342pP6kPM/edit?tab=t.0
Raylib game library: https://www.raylib.com/
Commenting practices: https://lkml.iu.edu/hypermail/linux/kernel/1607.1/00627.html
Tensor Library in C: https://github.com/apoorvnandan/ten
Writing a Linux debugger: https://blog.tartanllama.xyz/writin
FFMPEG assembly lessons (disable suggestions and/or download as PDF): https://docs.google.com/document/d/
https://docs.google.com/document/d/
https://docs.google.com/document/d/
Raylib game library: https://www.raylib.com/
Commenting practices: https://lkml.iu.edu/hypermail/linux
Noah !ZSjvHtAFy6 01/21/25(Tue)02:14:25 No.103977150
im working on tensor stuff because I am trying to understand the AI api stuff.
Anonymous 01/21/25(Tue)06:12:41 No.103978781
I'm working on writing my own shell, but I'm at the very beginning of it. I'm also using diet libc to make it the smallest possible binary, currently it's 35kbyte but only does the most basic shell stuff, you can type in commands and it executes them. Probably I'll rewrite the relevant c standard functions to make it smaller, so in the end it will be library independent.
Anonymous 01/21/25(Tue)07:26:54 No.103979186
Anonymous 01/21/25(Tue)10:41:19 No.103980794
>>103977118
Can any Linux System programmer anons here tell me how to handle signals in x86_64 asm?
What I am doing right now (nasm syntax):
>sigaction to register the handler
where dg1.ssa0 is 24 bytes of static mem in .bss, in line with the 'struct sigaction' declaration in the sigaction.h header to act as 'oact'. And ssa1 is static in .data with the first qword containing the pointer to the handler function which does nothing but does a sys_write for a confirmation message to stdout and then sys_rt_sigreturn, the mask and flags set to 0 and same for the sa_restorer.
I then call sys_pause to suspend the process, but when I issue the SIGINT via ^C or htop, it just quietly exits, without printing the confirmation message.
New to this whole business and verifiably stupid so please be patient with me. Thanks.
pastebin: https://pastebin.com/fBydsDHp
Ignore the printbuffer, It's just a part of this template I've saved for easily starting new programs using my own in construction library.
Can any Linux System programmer anons here tell me how to handle signals in x86_64 asm?
What I am doing right now (nasm syntax):
>sigaction to register the handler
mov r10d, 0x4
mov rdx, dg1.ssa1
mov rsi, dg1.ssa0
mov edi, SIGINT
mov eax, sys_rt_sigaction
syscall
where dg1.ssa0 is 24 bytes of static mem in .bss, in line with the 'struct sigaction' declaration in the sigaction.h header to act as 'oact'. And ssa1 is static in .data with the first qword containing the pointer to the handler function which does nothing but does a sys_write for a confirmation message to stdout and then sys_rt_sigreturn, the mask and flags set to 0 and same for the sa_restorer.
I then call sys_pause to suspend the process, but when I issue the SIGINT via ^C or htop, it just quietly exits, without printing the confirmation message.
New to this whole business and verifiably stupid so please be patient with me. Thanks.
pastebin: https://pastebin.com/fBydsDHp
Ignore the printbuffer, It's just a part of this template I've saved for easily starting new programs using my own in construction library.
Anonymous 01/21/25(Tue)13:09:26 No.103982323
>>103977118
C has nothing to do with assembly more than any other compiled language. C doesn't even have a simple and easy to learn compiler like traditional Pascal. Lisp and Forth are a lot closer to asm than C is. You grow the system and compiler from the ground up. You extend the language the same way you extend assembly with macros.
C has nothing to do with assembly more than any other compiled language. C doesn't even have a simple and easy to learn compiler like traditional Pascal. Lisp and Forth are a lot closer to asm than C is. You grow the system and compiler from the ground up. You extend the language the same way you extend assembly with macros.
Anonymous 01/21/25(Tue)13:56:36 No.103982837
>>103980794
>dg1.ssa0 is 24 bytes of static mem in .bss, in line with the 'struct sigaction' declaration
struct sigaction is 152 bytes on linux
>dg1.ssa0 is 24 bytes of static mem in .bss, in line with the 'struct sigaction' declaration
struct sigaction is 152 bytes on linux
Anonymous 01/21/25(Tue)14:14:16 No.103983030
>>103982837
I checked the sigaction.h for sysv linux in glibc's source and only saw a union between a sigset_t and a void *(), teo ints and another void *(). Maybe wrong arch, although I'm sure it was x86_64. Can you share the struct definition?
Thanks for the heads up btw anon
I checked the sigaction.h for sysv linux in glibc's source and only saw a union between a sigset_t and a void *(), teo ints and another void *(). Maybe wrong arch, although I'm sure it was x86_64. Can you share the struct definition?
Thanks for the heads up btw anon