Question: how can i fix my code to output ( I cant use the multiplication function ) Feed me 4 hex digits: 1 2 4 0
how can i fix my code to output I cant use the multiplication function
Feed me hex digits:
$ item
$ item
$ item
$ item
$ item
Total Order Costs: $
and
Feed me hex digits: C
$ item
$ item
$ item
$ item
$ item
Total Order Costs: $
when i input i get
Feed me hex digits:
$ item
C $ item
$ item
$ item
$ item
Total Order Costs: $
and when i input C i get a conversion error
program DollarValueMenu;
#include "stdlib.hhf;
static
inputValue: int;
totalCost: int;
begin DollarValueMenu;
Function to prompt for and read the input value
stdout.put "Feed me hex digits: ;
stdin.get inputValue ;
Extract number of items for each dollar value
mov inputValue, ebx ; Use ebx to hold the input value
Extract $ items first hex digit
mov ebx, eax ; Move input value to eax for easier manipulation
and eax ; Mask the first hex digit
stdout.put eax, $ item" ;
stdout.newln;
Extract $ items second hex digit
shr ebx ; Shift to next hex digit
mov ebx, eax ; Move input value to eax for easier manipulation
and eax ; Mask the second hex digit
stdout.put eax, $ item" ;
stdout.newln;
Extract $ items third hex digit
shr ebx ; Shift to next hex digit
mov ebx, eax ; Move input value to eax for easier manipulation
and eax ; Mask the third hex digit
stdout.put eax, $ item" ;
stdout.newln;
Extract $ items fourth hex digit
shr ebx ; Shift to next hex digit
mov ebx, eax ; Move input value to eax for easier manipulation
and eax ; Mask the fourth hex digit
stdout.put eax, $ item" ;
stdout.newln;
Remaining bits in ebx are for $ items
and ebx ; Mask the remaining hex digit
stdout.put ebx, $ item" ;
stdout.newln;
Calculate total cost
mov totalCost ; Initialize total cost to
mov inputValue, ebx ; Reload ebx with input value
Calculate total cost for $ items
and ebx ; Mask the first hex digit count for $ items
add ebx, totalCost ; Add to total cost
Calculate total cost for $ items
shr ebx ; Shift to next hex digit
and ebx ; Mask the second hex digit count for $ items
shl ebx ; Multiply by cost per item
add ebx, totalCost ; Add to total cost
Calculate total cost for $ items
shr ebx ; Shift to next hex digit
and ebx ; Mask the third hex digit count for $ items
shl ebx ; Multiply by cost per item
add ebx, totalCost ; Add to total cost
Calculate total cost for $ items
shr ebx ; Shift to next hex digit
and ebx ; Mask the fourth hex digit count for $ items
shl ebx ; Multiply by cost per item
add ebx, totalCost ; Add to total cost
Calculate total cost for $ items
and ebx ; Remaining bits are count for $ items
shl ebx ; Multiply by cost per item
add ebx, totalCost ; Add to total cost
Output the total order cost
stdout.put "Total Order Costs: $;
stdout.put totalCost ;
stdout.newln;
end DollarValueMenu;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
