This the output I want:
Quote
3
3 4
3 4 5
3 4 5 6
3 4 5 6 7
My code:
program triangle;
#include("stdlib.hhf")
begin triangle;
mov(7, edx);
for (mov (3, ecx); ecx <= edx; inc(ecx)) do
for (mov (ecx, eax); eax <= ecx; inc(eax)) do
stdout.put((type uns32 eax)," ");
endfor;
stdout.put(nl);
endfor;
end triangle;
The output is:
Quote
3
4
5
6
7
Hmm what is wrong here?
Quote
note well , the second for-endfor loop will always execute only one time.
here is the correct code
program triangle;
#include("stdlib.hhf")
begin triangle;
mov(7, edx);
for (mov (3, ecx); ecx <= edx; inc(ecx)) do
for (mov (3, eax); eax <= ecx; inc(eax)) do
stdout.put((type uns32 eax)," ");
endfor;
stdout.put(nl);
endfor;
end triangle;
Ah, I didn't notice that. :red
Thanks!