Create an HLA Assembly language program that calculates the cost of an order at a local fast food restaurant from its dollar value menu of items.. The cost will be based on a single 16-bit value entered by the value. The value will be used to specify a number of $5 items, $4 items, $3 items, $2 items and $1 items.
Three bits are being used to specify the number of order items. Total the cost of the order and print this amount.
Since 16 bits are being entered here, your program should expect to read 4 hexadecimal digits.
Below is a sample program dialogues that demonstrate these ideas.
Feed me your order as 4 hex digits: 1000
1 $1 item
0 $2 item
0 $3 item
0 $4 item
0 $5 item
Total Order Costs: $1
Here is my code:
program calculate_order;
#include("stdlib.hhf");
static
item_cost: int16;
begin calculate_order;
stdout.put("Feed me your oredr as 4 hex digits: ");
stdin.get(item_cost);
MOV(item_cost, ax);
stdout.put(" ", bh,"$5item", nl);
mov(bl, bh);
shr(5, bh);
and(7, bh);
mul(bh);
add(ax, bx);
stdout.put(" ", bl,"$4item", nl);
mov(bl, bl);
shr(4, bl);
and(7, bl);
mul(bl);
add(ax, bx);
stdout.put(" ", ch,"$3item", nl);
mov(bl, ch);
shr(7, ch);
and(7, ch);
mul(ch);
add(ax,bx);
stdout.put(" ", cl,"$2item", nl);
mov(bl, cl);
shr(4, cl);
and(7,cl);
mul(cl);
add(ax, bx);
stdout.put(" ", dl,"$1item", nl);
mov(bl, dl);
shr(3, dl);
and(15, dl);
add(ax,bx);
stdout.put("Total Order Cost:$", ax);
stdout.put(item_cost);
end calculate_order;
I tried to create the above code. But I am having some issues it is compiling but as a result for hex digits, whatever I put for hex is giving me same for its total cost order with zeros . I am having difficulty to understand where to make a change. It would be great if someone walk me through and help me find the issue in it. I am expecting to get same result as the sample above. This is the output it is giving me.
Feed me your oredr as 4 hex digits: 4567
20$5item
00$4item
10$3item
B2$2item
B2$1item
Total Order Cost:$00004567