Programming thread

I've been fiddling with x86_64 assembly recently and it's way easier than I thought. Interfacing with C functions by the System V ABI is just as easy as being able to understand a simple diagram of how the stack frame is structured and how I can just add/substract from RBP to get a certain value. It's pretty cool, I'll have to learn more.
This is a good resource if anybody wants to know what I've read so far.
Reading the K&R C book never taught me how C functions are called, and learning assembly made it all clear. Maybe this is because the C function calling conventions and all these ABI choices were stablized after C's invention, but no modern C book explained it to me as well. I'm starting to think maybe the CIA is trying to hide low-level programming from us by making it hard to access.
I remember HolyC being able to use inline assembly using the asm {}; block and Rust seems to have an unsafe macro called asm!();, I might have to try them out, although I guess the calling conventions of TempleOS are different from the SysV ABI.

Forget the Leddit memes about assembly being hard, this is just elementary school math and logic all over again.
 
  • Informative
Reactions: Friendly Primarina
Anyone got project ideas or know a place for doing projects?
currently learning Python n just started with JS but I wanna do something with it other than making clocks and calculators.
You can do Kaggle challenges. That's more machine learning though.
 
I've been fiddling with x86_64 assembly recently and it's way easier than I thought. Interfacing with C functions by the System V ABI is just as easy as being able to understand a simple diagram of how the stack frame is structured and how I can just add/substract from RBP to get a certain value. It's pretty cool, I'll have to learn more.
This is a good resource if anybody wants to know what I've read so far.
Reading the K&R C book never taught me how C functions are called, and learning assembly made it all clear. Maybe this is because the C function calling conventions and all these ABI choices were stablized after C's invention, but no modern C book explained it to me as well. I'm starting to think maybe the CIA is trying to hide low-level programming from us by making it hard to access.
I remember HolyC being able to use inline assembly using the asm {}; block and Rust seems to have an unsafe macro called asm!();, I might have to try them out, although I guess the calling conventions of TempleOS are different from the SysV ABI.

Forget the Leddit memes about assembly being hard, this is just elementary school math and logic all over again.
The ABI isn't important for C programming by definition, you're working from inside C after all so the compiler takes care of all of that. Assembly really is just tedious, not hard.
 
The ABI isn't important for C programming by definition, you're working from inside C after all so the compiler takes care of all of that. Assembly really is just tedious, not hard.
Yeah you're correct, but I'd like to call my C functions from my assembly code, and the ABI defines how I should talk to my function.
Also assembly seems pretty useful for programs that I can write in TempleOS, where everything is done with software encoding and using SSE or AVX can drastically improve the rendering speed.
I remember the trans flag guy writing SSE instructions by hand for his TempleOS game's bomb effect because Terry died before he implemented SSE support to his compiler.
 
I remember the trans flag guy writing SSE instructions by hand for his TempleOS game's bomb effect because Terry died before he implemented SSE support to his compiler.
It's clang optimized C code that I tweaked so it can be assembled by NASM and uses TempleOS's function call style.
 
Anyone got project ideas or know a place for doing projects?
currently learning Python n just started with JS but I wanna do something with it other than making clocks and calculators.
Create scripts to scrape a lolcow community you enjoy and archive everything they do to a local database, then identify things that get deleted so you can specifically make fun of those.
 
It's clang optimized C code that I tweaked so it can be assembled by NASM and uses TempleOS's function call style.
>He doesn't write CVTSI2SD XMM0,RSI himself
ngmi
but for all seriousness simd is pretty cool, they can make code simpler and specifying the destination register instead of an extra MOV is really nice
 
Reading the K&R C book never taught me how C functions are called
This is because the ABI is ISA and OS dependent. Windows x86-64 uses a different ABI than Linux does for example. C also doesn't define how a pointer is implemented or things like stack frames etc. A good book to pirate if you're looking for a high-level overview of the concepts behind programming language implementations is Sebesta's Concepts of Programming Languages which is kind of the main book used in undergraduate courses (unless you're at a school that still teaches compilers to undergrads). Pirate a copy and give it a read.
 
A very cool article on DI in C++ for those who might wanna learn some.

For me, I'm learning it to practice and implement more generic solutions for embedded systems that can allow me to more easily plug new devices in place of the existing solution without having to change the whole dependency diagram or just change the whole system entirely from it being so tightly coupled.

For those of you doing embedded OS/systems, you probably know my pain of having to take tightly coupled code and shove a new part in due to a shortage. It sucks dick.
 
  • Like
Reactions: Fcret
Rust is based. Trannies be damned. Rust is a very very good language and I don't want to use C anymore bros.

C-cels be seething over Rust-Chads.

Algebraic data-types and monadic design patterns in my low-level language? Yes please.
 
  • Agree
Reactions: Faceless Whore
Hello, this question is C-centric because I am too autistic for Python or anything else.

Would you agree that there are 3 or 4 or what-have-you styles for command line arguments? Such as would be:

Code:
flex reentrant
flex -reentrant
flex --reentrant
cl /c (I guess this is the Microsoft style)

Does everybody writing a program just write their own code to parse these arguments? Isn't it all the same code, more or less?

What's been done to expedite that so we can all focus on the guts of our software?
 
There's also the contemptible Unix style:
Code:
tar -xvf
Which sets the three single-letter flags "x", "v", and "f".


You could use getopt if you really want to bother.

Thanks so much, this may be as close to what I'm looking for as I'll get. You are accommodating of my schizophrenia.

I am fascinated by the music software I've made, which parses my plaintext format into MIDI and sheet music. I'll make a proper thread for it soon, but here's the code: tfm.l (requires Flex), main.c, multi.c
 
Last edited:
Hello, this question is C-centric because I am too autistic for Python or anything else.

Would you agree that there are 3 or 4 or what-have-you styles for command line arguments? Such as would be:

Code:
flex reentrant
flex -reentrant
flex --reentrant
cl /c (I guess this is the Microsoft style)

Does everybody writing a program just write their own code to parse these arguments? Isn't it all the same code, more or less?

What's been done to expedite that so we can all focus on the guts of our software?
Code:
flex reentrant
If reentrant is a file/directory or some similar argument to be acted on
Code:
flex -reentrant
no imo
Code:
flex --reentrant
Yes if reentrant is long form of an argument like -r or something (though -r is frequently a recursive option). Or just an uncommon argument you didn't bother to make a shorthand argument for.
Code:
cl /c (I guess this is the Microsoft style)
no, I don't know any non-MS specific programs that do it this way, even on Windows. Even Wintards are used to command line programs using using the '-'

Actually thinking on the Windows style it may just be I default to - over / and both are supported, not sure.
 
Last edited:
I don't really care what format your thing actually expects, all I ask is that you make any variation of / or - or -- and ? or help print out the lib so I don't have to try various different ways just to find out how it expects me to ask it politely.
 
Back