LAB1

Lab description:

In this lab, we are supposed to write a HLA program that convert decimal to roman numeral. First of all, we need to figureout the algorithm of converting decimal to roman numeral. After we find out all the symbols of Roman numeral, we are ale to write the program by using while loop and “if”  statement. This is our first lab, and it is a little difficult for people who haven’t learn any program. Anyway, after learning our first program, we have gained some experience for programming.


Program Romanconvert1;
#include( "stdlib.hhf" ); 
static 
x:int32;
begin Romanconvert1;
stdout.put("Enter A Decimal Number:")
stdin.get(x);
mov(x,eax);

       while(eax>0)  do
	   if(eax>=0) then
	         stdout.put("C");
	         sub(100,eax);
		endif;
	    if(eax>=0) then
	         stdout.put("XC");
	         sub(90,eax);
		endif;
	    if(eax>=0) then
	         stdout.put("L");
	         sub(50,eax);
		endif;
	    if(eax>=0) then
	         stdout.put("X");
	         sub(10,eax);
		endif;
	    if(eax>=0) then
	         stdout.put("V");
	         sub(5,eax);
		endif;
	    if(eax>=0) then
	         stdout.put("IV");
	         sub(4,eax);
		endif;
	    if(eax>=0) then
	         stdout.put("I");
	         sub(1,eax);
	endif;


endwhile;

stdout.put("nl");
end Romanconvert1;

lab1

Leave a Reply

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