Lab 1

Lab Description:

The purpose of this lab was to familiarize us with basic HLA syntax by creating a simple program that converts decimal numbers to roman numerals.

Code:

program ConvDecRom;
#include("stdlib.hhf")
static
n:int32;
begin ConvDecRom;
stdout.put("Enter a decimal number or enter 0 to exit." nl);
  stdin.get(n);
  mov(n,eax);

  while(eax!=0)do

	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 "Enter a decimal number: ");
mov(0,n);
	stdin.get(n);
	mov(n,eax);

endwhile;

stdout.put(nl, "Program End", nl);
end ConvDecRom;

 

Screenshots:

Lab1ScreenShot

Leave a Reply

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