Sergei
Sergei

Reputation: 47

HLA Assembly Error: Unexpected ')' at Line 18, Expecting '(' in my HLA Program

Im trying to run this program : Number Looping! Im expecting: Gimme a decimal value to use for n: 5 Here's your answer: 111112222333445

program NumberLooping;

#include("stdlib.hhf")  // Standard library for I/O operations.

static
  n: int8;      // Store the user input.
  i: int8;      // Counter for the outer loop (digit to print).
  j: int8;      // Counter for the inner loop (number of repetitions).

begin NumberLooping;

  stdout.put("Gimme a decimal value to use for n: ");
  stdin.get(n);            // Read user input and store it in 'n'.

  mov(1, i);               // Start with digit '1'.

OuterLoop:
  cmp(i, n);               // Compare current digit with the input number 'n'.
  jg(Done);                // If i > n, we are done.

  mov(n, j);               // Set the inner loop counter 'j' to 'n'.
  sub(i, j);               // Calculate the number of repetitions for the current digit.

InnerLoop:
  cmp(j, 0);               // Check if we have printed all repetitions.
  jle(NextDigit);          // If j <= 0, move to the next digit.

  stdout.put(i);           // Print the current digit.
  dec(j);                  // Decrease the repetition counter.
  jmp InnerLoop;           // Repeat inner loop.

NextDigit:
  inc(i);                  // Move to the next digit.
  jmp OuterLoop;           // Repeat outer loop.

Done:
  stdout.newln();          // Print a newline at the end.

end NumberLooping;

I keep getting compile errors like:

C:\Users\KOSAREV_SERGEI\Downloads>hla newhomework.hla
Error in file "newhomework.hla" at line 18 [errid:129712/hlaparse.c]:
syntax error, unexpected ')', expecting '('.
Near: << ) >>

HLAPARSE assembly failed with 1 errors

What's the issue here?

Upvotes: 0

Views: 15

Answers (0)

Related Questions