
Which modern programmers are able to solve low-level problems or tasks for programmers
Inspired by the story of one byte ...
Are modern programmers capable of creating code as art? Try to solve these problems :)
Well, for example, try to solve such problems as it was written - about single crystals
So, let there are 2 single-byte registers A and B, which form a double-byte AB, a stack, a conditional jump in length + - 127 commands from the current point, unconditional - 255. 128 instructions in RAM, 8K memory bank.
Commands for working with registers - bit shifts, addition.
Conditional transition can be if the flag goes over the border of the register?
What is going abroad? This is if you add 100 to 200. There will be an exit beyond the limit of the byte capacity. This is one that is 8 bit
Assume the first task. Implement subtraction. We only have addition.
Make AB, place the result in A.
Let us solve the problem for values up to 127. The high byte will be familiar with us
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 we coped with the first task.
And how to change the values of A and B among themselves?
Can you do the multiplication? And the division? To facilitate the work - unsigned + a couple more registers have been added - DE
Do you know how to do the branching process with returning to one point using the stack?
But how to implement cos () and sin ()? :)
Are modern programmers capable of creating code as art? Try to solve these problems :)
Well, for example, try to solve such problems as it was written - about single crystals
So, let there are 2 single-byte registers A and B, which form a double-byte AB, a stack, a conditional jump in length + - 127 commands from the current point, unconditional - 255. 128 instructions in RAM, 8K memory bank.
Commands for working with registers - bit shifts, addition.
Conditional transition can be if the flag goes over the border of the register?
What is going abroad? This is if you add 100 to 200. There will be an exit beyond the limit of the byte capacity. This is one that is 8 bit
Assume the first task. Implement subtraction. We only have addition.
Make AB, place the result in A.
Let us solve the problem for values up to 127. The high byte will be familiar with us
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 we coped with the first task.
And how to change the values of A and B among themselves?
Can you do the multiplication? And the division? To facilitate the work - unsigned + a couple more registers have been added - DE
Do you know how to do the branching process with returning to one point using the stack?
But how to implement cos () and sin ()? :)