Search code examples
assemblynasmhla

How to properly divide numbers in HLA assembly


I got Integer overflow in HLA nasm. I would like to write simple program that divide provided Distance variable by 15000 and display evaluation of it, but I faced that problem. I simply don't understand an idea of division in HLA. Thank you in advance for your help.

program zad2;
#include( "stdlib.hhf");

static
    f    :  int32   := 15000;
    s    :  int32   := 300000;
    Distance: int32;

begin zad2;

        stdout.put("Give car distance", nl);
        stdin.get(Distance);
        if (Distance<150000) then
            MOV(15000, eax);
            div(Distance, EDX:EAX );
                stdout.put("div evaluation:",eax ,nl);
                    jmp menu0;
            endif
end zad2;

Solution

  • I found my resolution of it. Please have a look on it. All stuff with hla div are not working correctly on Windows version of hla compiler. It should look like this. I hope it might by somehow helpful for sb ;)

    mov(Distance, eax);
    mov(15000, ebx);
    div(ebx);
    mov(eax, age);