On 05/01/2021 13:06, Thomas Koenig wrote:
> The Natural Philosopher schrieb:
>> The C. Some things that are
>> neat in assembler are ugly as sin in C.
>
> One thing that is hard to do with C is to have different entries
> to the same function, something like:
>
> bar:
> .cfi_startproc
> ... do something
> foo:
> ... do something else
>
> ret
>
> and then either call foo or bar.
>
Blimey, that takes me back over 40 years to a neat trick of mine to
save a couple of bytes (but something today that might get
you the sack in these times of the high cost of software maintenance!).
It's a way of passing on the stack a zero / non zero value.
In PDP11 (Octal!!!!!!!) opcodes ..
012746
5046
the first word says Push the value 5046 onto the stack, but
the second word, 5046 means clear the next stack entry.
So, by jumping to the second word of the instruction, you
push a zero value!
That it warrants such an involved explanation is very good
reason why such techniques should be avoided today! :-)
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|