News for hackers. Stuff that matters.
Re:ngn/k, an AGPL K interpreter by ngnk on Friday January 10, 2020 @04:39AM (#22009715)
any ideas for a more compact and efficient way to get argc and argv on both linux and freebsd without bringing in libc?
Re:ngn/k, an AGPL K interpreter by kick on Friday January 10, 2020 @05:02AM (#22009843)
Thanks for writing/freeing this! I've had a lot of fun with it since a friend first pointed out that it had been released under a libre license.
Re:ngn/k, an AGPL K interpreter by pja on Friday January 10, 2020 @06:11AM (#22010162)
Nope :)

But http://dbp-consulting.com/tutorials/debugging/linuxProgramSt...

does suggest zeroing the top-most frame (%ebp) and making sure the stack is 16-byte aligned might also be worth doing. (Possibly it’s already 16-byte aligned already because you jmp to main instead of calling it though?)

Re:ngn/k, an AGPL K interpreter by ngnk on Friday January 10, 2020 @07:02AM (#22010376)
that's a good read, thanks. afaik zeroing %rbp here plays no role other than to assist debuggers. i'm not sure if alignment makes any measurable difference. if it does, it'll be worth doing. i jmp to main() because i wrote it and i know it never returns. it exit()-s.
Re:ngn/k, an AGPL K interpreter by saagarjha on Friday January 10, 2020 @07:06AM (#22010394)
> afaik zeroing %rbp here plays no role other than to assist debuggers.

Yep, it marks function frame boundaries. If you don't particularly care, you may want to consider compiling with -fomit-frame-pointer and the compiler will return this register back to the set of general purpose ones for it to use.

> i'm not sure if alignment makes any measurable difference. if it does, it'll be worth doing.

It will if you end up emitting any SSE instructions, because they will cause loads and stores that need to be aligned.

Re:ngn/k, an AGPL K interpreter by 3xblah on Friday January 10, 2020 @06:19AM (#22010202)
I use _getenv in k3

   a=arg1 b=arg2 k c.k
Re:ngn/k, an AGPL K interpreter by saagarjha on Friday January 10, 2020 @04:51AM (#22009772)
Portably? No.
Re:ngn/k, an AGPL K interpreter by duskwuff on Friday January 10, 2020 @05:02AM (#22009845)
Given that the interpreter makes system calls directly using inline assembly [1], I suspect that any hope of portability went out the window long ago.

[1]: https://bitbucket.org/ngn/k/src/b54eb5cfea5eb821fe1de68d2a8a...

Re:ngn/k, an AGPL K interpreter by ngnk on Friday January 10, 2020 @05:48AM (#22010059)
across architectures: you're right, as of now it's x86_64 only

across operating systems: it works on linux and freebsd as-is (thanks bakul), and with a few changes on windows+libc (thanks ktye) - https://github.com/ktye/i/tree/master/_/ngn though i personally never use windows