Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is a big difference between modifying the stack control registers directly and modifying general purpose registers directly.


Not really.

What do you think you do when you write in assembly and want to enter or exit a function? You push and pop on the stack control registers.... gasp?

It’s not common but I’ve had to manually adjust PC register before. The author and most software devs are so far removed from metal, the downvotes on my comments are hilarious to me.


>What do you think you do when you write in assembly

You said you were an "Embedded C programmer". Why are you now switching the topic and talking about assembly? First of all there is no such objective definition of assembly. It is inherently specific to the architecture and therefore someone knowing x86 assembly doesn't mean that person also knows how to use RISC-V assembly. Since you have moved the goalpost out of the playing field by switching languages one could now conceive of an architecture that simply has no registers at all because everything is stored in RAM. Such an architecture would allow a C compiler to still produce valid code but assembly code would not be able to access any registers whatsoever. Therefore it makes equally little sense for the C programming language to have the ability to access registers.

> The author and most software devs are so far removed from metal, the downvotes on my comments are hilarious to me.

The reason why you receive downvotess is that even people who are not "far removed from metal" disagree with your comments because you are making fun of them.


> The author and most software devs are so far removed from metal

The author writes emulators of multiple game systems in C++. They probably wake up screaming at night thinking about the metal.


Ha, good point. Doesn't stop them from using the term I've noticed.


> as modifying the CPU context registers and stack frame directly is not permitted by most sane programming languages

My point was, if C++ had a global variable named "stack_pointer" you could assign to, that would indeed be rather insane.


I said directly. You seem to be implying that it is common for important embedded work to involve manually messing with stack registers directly by the programmer with assembly.


Um... I don't know what to tell you - but I do that every day. Guess what - people who make libraries for other embedded devices, sometimes still write in assembly. Insane, I know.


You seem to be purposely ignoring what I am saying so that you contradict something I didn't say. I doubt people are writing the software for medical devices by directly writing to stack registers (which wouldn't mean the typical automatic instructions that push and pop the stack while automatically incrementing or decrementing the instruction pointer at the same time)


Your first comment didn't mention assembly. You only talked about C. It's insane that you switch the topic of the conversation and then pretend to be the only smart one.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: