logoalt Hacker News

JamesTRexxyesterday at 8:44 PM3 repliesview on HN

Would and how much would it shrink when if, while, and for were replaced by the simple goto routine? (after all, in assembly there is only jmp and no other fancy jump instruction (I assume) ).

And PS, it's "chose your own adventure". :-) I love minimalism.


Replies

dzaimatoday at 1:03 AM

It only does if & while, not for. A goto in a single-pass thing would need separate handling for forwards vs backwards jumps, which involves keeping track of data per name (in a form where you can tell when it's not yet set; whereas if/while data is freely held in recursion stack). And you'd still need to handle at least `if ( expr ) goto foo;` to do any conditionals at all.

direwolf20today at 1:01 AM

It's "choose your own adventure"

show 1 reply
SAI_Peregrinusyesterday at 9:29 PM

What fancy jumps are present in assembly depends on the CPU architecture. But there are always conditional jumps, like JNZ that jumps if the Zero flag isn't set.