A good way to feel that for yourself is by programming a little program in Assembly and C.
Make sure the program needs to loop a bit and perhaps also require some if/ else logic.
A simple one would be to read a 1000 integers and return the sum.
In C, you would do something like:
int MAX = 1000;
int accumulator = 0;
int counter = 0;
while (counter < MAX)
{
accumulator = accumulator + value_at_next_memory_location_by_counter;
counter = counter + 1;
}
In assembly, you would go (writing pseudo, because I have forgotten most assembly stuff):
set reg1 = 1000// For max valueset accumulator = 0// just choose a register and consider it an accumulator. older CPUs have a fixed accumulator and you can only operate on that. I am not considering that hereset reg2 = 0// For counter
tag LOOP:
set flag iftrue reg2 < reg1
jump iffalse -> END
move from memory location @counter(reg2) to reg3
add accumulator reg3
add reg2 1goto -> LOOP
tag END:
I also realised that you could just try using C with goto instead of any loops and would realise similar things, but I’m not in the mood to rewrite my comment.
In conclusion, it is easier to understand something like BASIC, if you haven’t been introduced to other languages, but these {} structures end up making it easier to catch control flows at a glance.
That’s also the argument I use when telling people to have opening and closing brackets of the same level at the same indent, while people prefer stuff like:
A good way to feel that for yourself is by programming a little program in Assembly and C.
Make sure the program needs to loop a bit and perhaps also require some
if/elselogic.A simple one would be to read a 1000 integers and return the sum.
In C, you would do something like:
int MAX = 1000; int accumulator = 0; int counter = 0; while (counter < MAX) { accumulator = accumulator + value_at_next_memory_location_by_counter; counter = counter + 1; }In assembly, you would go (writing pseudo, because I have forgotten most assembly stuff):
set reg1 = 1000 // For max value set accumulator = 0 // just choose a register and consider it an accumulator. older CPUs have a fixed accumulator and you can only operate on that. I am not considering that here set reg2 = 0 // For counter tag LOOP: set flag if true reg2 < reg1 jump if false -> END move from memory location @counter(reg2) to reg3 add accumulator reg3 add reg2 1 goto -> LOOP tag END:I also realised that you could just try using C with
gotoinstead of any loops and would realise similar things, but I’m not in the mood to rewrite my comment.In conclusion, it is easier to understand something like BASIC, if you haven’t been introduced to other languages, but these
{}structures end up making it easier to catch control flows at a glance.That’s also the argument I use when telling people to have opening and closing brackets of the same level at the same indent, while people prefer stuff like:
if { ... } else { ... }