I have also been researching Div use with HLA (High Level Assembly). I wanted to share what I found also to help others. This program was not a class assignment, for that we had to do everything by hand and show our work. I just wrote this short program for some extra practice, so I thought why not share it, it worked great for checking my work, plus it has division use in it. This program will take a char convert it to Hex to Decimal and after convert it to binary, to do the binary conversions is uses idiv inside of a while loop and goes from 64 to 32 to 16 to 8 to 4 to 2 to 1 each while loop iteration divides the cl in half.
//Jonathan Lee Sacramento State University
//CSC35
//Professor Devin Cook
//Feb 11 2023
//Non-Credit Practice program with Asci/hex/decimal
//Program: This is a HLA program that converts ASCII/HEX/DECIMAL/BINARY
based off one letter input
program binarydiv;
#include( "C:\hla\include\stdlib.hhf");
static
UserChar: char;
i8: int8 :=0; //value
begin binarydiv;
stdout.put("---> Please enter one character: ");
stdin.get(UserChar); //store as char
stdout.put("You Entered: ",UserChar);
mov(UserChar,al); // store hex value of char into al reg
stdout.put(nl,"(",UserChar,") In Hex is: ", al); //show hex value
mov(al,i8); //move hex into int8
stdout.put(nl,"(",UserChar,") In Decimal is: ",i8); //show decimal value
stdout.put(nl,"(",UserChar,") In Binary is: 0"); //start of binary not using 128
mov(64,cl); //use cl with operators 2nd binary
while(cl>0) do
if(i8>=cl) then
stdout.put("1");
sub(cl,i8);
elseif(i8<cl) then
stdout.put("0");
endif;
//div block
mov(cl,al);
cbw();
mov(2,bl);
idiv(bl);
mov(al,cl);
//end div block
endwhile;
stdout.put(nl);
end binarydiv;
