CET 3510 Lab 1

Lab 1

Objective: The objective of this experiment was to analyze and observe the characteristics of HLA syntax and semantics through developing an Arabic to Roman numeral conversion program. By doing so, it was possible to be come familiarized with registers and creating loops in programming.

Code: The source code used to conduct the experiment is below. The program can calculate values up to 3999.

//CET 3510 Shinquella Glasgow Lab# 1
//This is a arabic to roman numeral converter

program roman_numerals;

#include ("stdlib.hhf");   

//assign varibles
static
//variable to produce output
	z: int32;

//begin program

begin roman_numerals;
repeat

  stdout.put ("Enter a number from 1 to.", nl);

  //get user input from keyboard
  stdin.get(z);

  //Move z user input to register
  mov(z,eax); 
  mov(z,ebx);

  //Roman numeral Conversion Loop

 while(eax>0) do
   	  if(eax>=100) then
             stdout.put("C");
             sub(100,eax);

 elseif (eax>=99)then
        stdout.put("IC");
	        sub(99,eax);
elseif (eax>=90)then
	       stdout.put("XC");
	       sub(90,eax);

elseif(eax>=50)then
	      stdout.put("L");
	      sub(50,eax);

elseif(eax>=49)then
	       stdout.put("IL");
	       sub(49,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(ebx==0);

end roman_numerals;

 

Screen Shot: The image below is the output of the program once it is executed.

shot-2013-10-04_19-57-50

 

Leave a Reply

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