Re:Forth: The Hacker’s Language
by kayamon on Saturday January 28, 2017 @12:02PM
(#13507378)
Borland C used to, and I believe OpenWatcom still does. Haven't seen any other one that did for a long time.
[ Parent
| on HN ]
Most C compilers do, but those are language extensions, not defined on the language's standard thus not portable across compilers.
Re:Forth: The Hacker’s Language
by Turing_Machine on Saturday January 28, 2017 @10:09PM
(#13511691)
Yep. If nothing else, just about all of them have the asm keyword. That's non-standard (but almost always present) in C compilers, and "conditional" in C++ (i.e. the keyword is in the standard, but the semantics are implementation-defined).
And yeah, it's a given that it's going to be non-portable.
Given asm, implementing a Turbo C-style int86() function seems pretty trivial. It might even be doable as a macro.
I loved the asm way in PC compilers used to support inline asm.
asm {
mov ax, 0x0013
int 0x10
}
Can't really like the way clang and gcc asm work, even it it means giving more info to the optimizer.
Re:Forth: The Hacker’s Language
by groovy2shoes on Saturday February 04, 2017 @08:35PM
(#13570251)
Not to mention that you could just use C identifiers in the asm block willy-nilly:
int foo(int c)
{
int r;
asm {
mov ax, 0x0b00
int 0x21 /* poll stdin for input */
mov ax, offset c /* get address of `c` */
call bar /* call other C function */
mov r, dx /* save the result in `r` */
}
return r;
}
Or something like that — it's been a while. Those were the days! GCC's (and I'm assuming clang's is much the same) inline assembly is a joke in comparison. I remember, when I first encountered it, flipping back-and-forth through the GCC docs looking for how people actually do inline asm with GCC...