📜 ⬆️ ⬇️

Which modern programmer is able to solve low-level tasks or problems for programmers?

Inspired by the story about one byte ...

Are modern programmers capable of creating code as art? Try to solve these puzzles :)

Well, for example, try to solve such problems, as it was written - about single crystals
So, let there be 2 single-byte registers A and B, which form a double-byte AB, stack, conditional transition to longer + - 127 commands from the current point, unconditional - 255. 128 commands in RAM, 8K memory bank.
Register commands - bit shifts, addition
A conditional transition can be if the flag is set to exit the border of the register?
What is going abroad? That is, if you add 100 to 200. There will be a byte overshoot. This is the one that is 8 bits

Suppose the first task. Implement subtraction. We have only addition.
Make AB, place the result in A.
We solve the problem for values ​​up to 127. We have a high byte.
Accordingly, setting the high bit for A, we get -A
(-A) + B = AB
Problem solved
')
Can you make a solution for 255? And for 0xFFFFh?

Suppose you coped with the first task.

How to change the values ​​of A and B between them?

Can you make multiplication? And the division? To facilitate the work - unsigned + added another pair of registers - DE

Do you know how to do the branching process with return to one point using the stack?

And how to implement cos () and sin ()? :)

Source: https://habr.com/ru/post/27060/


All Articles