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.
>
Indeed.
I had to write an extended but of assemble once to fit in 2K eprom - a
bios for larger disks using larger sectors than standard msdos.
I was frustratingly about 80 bytes short.
I looked at the code for a long time trying to think what I could use in
various places - and found something.
The original cider was always in the habit of using the same two
register - AX and BX, as scratch, (Sometimes he used DX as well)
so every subroutine started with push AX, PUSH BX, and ended with POP
BX, POP AX, RET. Sometimes he used DX as well
that was three words or four . But JMP MY_EXIT (or DX_EXIT)was only two...
DX_EXIT: POP DX
MY_EXIT: POP BX
POP AX
RET
But that is exactly the sort of things a compiler optimised for code
size rather than speed, would be expected to do. Find common bits of
code and jump to them
--
Climate Change: Socialism wearing a lab coat.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|