first of i just wanna say im very new to coding and trying to learn. I have to write a HLA code for a program that lets u enter numbers. after each number is entered it gives u a new line to enter another number, until "0" is entered. then the program should stop and show u in all the numbers u entered in the correct order. I need to use the HEAP memory to store the numbers in. so when they come out they are in the wrong order. this is where i am right now
program Project3;
#include("stdlib.hhf")
static
count: int32 := 0;
mempointer: int32;
begin Project3;
mem.alloc(1000);
mov(eax, mempointer);
loopStart:
stdout.put("Enter a number, 0 to stop: ");
stdin.flushInput();
stdin.geti32();
mov(eax, ebx);
cmp(ebx, 0);
je exitLoop;
add(1, count);
mov(count, ecx);
shl(2, ecx);
mov(mempointer, eax); add(ecx, eax);
mov([eax], ebx);
jmp loopStart;
exitLoop:
stdout.put(nl, "Entered numbers: ");
while (count <> 0) do
sub(1, count);
mov(count, ecx);
shl(2, ecx);
mov(mempointer, eax); add(ecx, eax);
mov(ebx, [eax]);
stdout.puti32(ebx);
stdout.put(" ");
endwhile;
mem.free(mempointer);
end Project3;
As it is it compiles and run but it only displays a 0 for each number I've entered. does anyone know how to fix that?
ive tried using manny diffrent ways of storing the numbers so they come out in the order ive entered them. but cant find what im doing wrong.