Another kind of pointer arithmetic

Igor Shirkalin isemsoft at gmail.com
Fri Jun 26 18:56:24 UTC 2020


On Friday, 26 June 2020 at 18:18:34 UTC, welkam wrote:
> On Friday, 26 June 2020 at 14:00:27 UTC, Ianis Vasilev wrote:
>> Somebody joked yesterday on Twitter about how pointer levels 
>> of indirection can be used to represent natural numbers and 
>> how we can do arithmetic with them (I can't find the post 
>> right now).
>>
>> I decided to try and implement adding and multiplying levels 
>> of indirection:
>> https://gist.github.com/v--/5cbd0046be6fc5dbff9a9ad2f1717cde
>>
>> I think it turned out fairly trivial.
>
> This reminded me when one person heard that mov instruction is 
> turing complete so he implemented c compiler that emitted only 
> mov instructions

The task from the school:

Say, we have six intel 8086 cpu registers: ax, bx, cx, dx, si, 
di. Our task is to make the rotation: 
ah->al->bh->bl->ch->cl->dh->dl->ah. We can only use "move reg, 
reg" command. The si and di registers are undefined.



More information about the Digitalmars-d mailing list