Lab 1

Lab Description:
In this lab we created a program using HLA that asks the user for a decimal number and then converts it into Roman numerals and displays the result. The program continues to ask the user for more numbers until they enter zero then it exits.

program dectorom;

#include("stdlib.hhf")

static

n:int32;


begin dectorom;
 

repeat

stdout.put("enter a number: ");

  stdin.get(n);

  mov(n,eax);

  while(eax > 0) do

  if(eax >= 1000 ) then

      stdout.put("M");

      sub(1000,eax);


      elseif(eax >= 900 ) then

      stdout.put("CM");

      sub(900,eax);


      elseif(eax >= 500 ) then

      stdout.put("D");

      sub(500,eax);


      elseif(eax >= 400 ) then

      stdout.put("CD");

      sub(400,eax);


      elseif(eax >= 100 ) then

      stdout.put("C");

      sub(100,eax);


      elseif(eax >= 90 ) then

      stdout.put("XC");

      sub(90,eax);


      elseif(eax >= 50 ) then

      stdout.put("L");

      sub(50,eax);


      elseif(eax >= 40 ) then

      stdout.put("XL");

      sub(40,eax);


      elseif(eax >= 10 ) then

      stdout.put("X");

      sub(10,eax);


      elseif(eax >= 9 ) then

      stdout.put("IX");

      sub(9,eax);


      elseif(eax >= 5 ) then

      stdout.put("V");

      sub(5,eax);


      elseif(eax >= 4 ) then

      stdout.put("IV");

      sub(4,eax);


      elseif(eax >= 1 ) then

      stdout.put("I");

      sub(1,eax);

      
      endif;

      
  endwhile;


  stdout.put(nl);
until(n = 0);

stdout.put();
stdin.get(n);
end dectorom;

Untitled

Leave a Reply

Your email address will not be published. Required fields are marked *