chris.vargas.773 0 Newbie Poster

so im tasked to write a program that converts decimals to binary numbers; the only problem is that im having trouble writeing this program.

Write an HLA Assembly program that prompts for an int8 value to inspect and then prints it in binary format. For example, here would be the program output for various entered values

Gimme a decimal value to print: 15
15 is 0000_1111
Gimme a decimal value to print: 7
7 is 0000_0111

(Hint: There is no standard output that prints in binary output, so you need to do this yourself. In order to accomplish this, you need to move a bit at time into the carry flag and print 0 or 1, depending on what you find in the Carry bit. Shift and repeat this procedure 8 times and you are done! Eventually, we will learn how to loop, making this task much less terrible.)

(Second Hint:LAHF pushes the Carry Bit and all the other flags out of the EFLAGS register and into AH. As an Assembly programmer, you have the power to mask out all the bits but the one you are interested in by using either AND or OR.)

so far this is what ive wrote so far

//    File:   binaryConvert.hla
program binaryConvert;
#include( "stdlib.hhf" );
static
   iNumberData : int8;   
   begin binaryConvert;
   //start with title of the table
   stdout.put( "Decimal Number Conversion" , nl );  
   // statement to enter a 8bit decimal to be converted  
   stdout.put( " Enter a starting decimal number you want converted : "  , nl);
   stdin.get(iNumberData);   
   //move the iNumberData value into a 8bit register   
   mov(iNumberData , AH );



   stdout.put("The number :, iNumberData , "the binary is %", AH, nl);
   end binaryConvert;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.