Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an HLA Assembly language program that calculates the cost of an airline ticket. The ticket will be based on different choices made by the

Write an HLA Assembly language program that calculates the cost of an airline ticket. The ticket will be based on different choices made by the traveler as represented by a bit field as shown below:
Flight Packed Bit Field
Since just 8 bits are being entered, your program should expect to read 2 hexidecimal digits.
The two low-order bits (shown in white) represent the number of checked bags. Each checked bag add $25 to the cost of the airline ticket.
The next four bits (shown in blue) represents the flight length, in 100 mile increments. A flight of 100 miles or less would be represented by 0001. A flight of up to 200 miles in length would be represented by 0010. A flight up to 300 miles in length would be represented by 0011, and so on. Each 100 miles flown adds $50 to the cost of the airline ticket. For the fare to be valid, the smallest allowed value for this field is 0001. The biggest allowed value for this field would be 1111, meaning 1500 miles in length.
The next bit (shown in yellow) represents whether a meal is purchased on board. A meal adds $10 to the cost of the airline ticket.
The high-order bit (shown in orange) represents whether a first-class fare is being purchased. First-class tickets cost twice as much an economy ticket.
Below are some sample program dialogues that demonstrate these ideas.
(Hint: Do this in small steps, bit-by-bit. There's alot to it...)
(Further Hint: The most important part of this assignment is to worked with the packed data field entered by the user to extract the sub-parts out of it. The overlapping design of the Intel registers helps you parse this kind of data field and you can shift the bits around to get the right part into BH or BL, for example... )
(Further Hint: You can read hex numbers by reading directly into a register. Just don't use EAX since stdin.get uses that one when it executes.)
(Final Hint: Since we haven't learned how to do multiplication yet, although it's kinda painful, I was expecting that you would perform the multiplication by a looping set of addition instructions)
Feed me(2 hex digits): 00
Miles flown cannot be zero!
Feed me(2 hex digits): 01
Miles flown cannot be zero!
Feed me(2 hex digits): 04
Economy ticket
No meal
No bags
100 miles flown
Total Fees = $ 50
Feed me(2 hex digits): 84
First class ticket
No meal
No bags
100 miles flown
Total Fees = $ 100
Feed me(2 hex digits): 7F
Economy ticket
Meal purchased
3 bags
1500 miles flown
Total Fees = $ 835
Feed me(2 hex digits): FF
First class ticket
Meal purchased
3 bags
1500 miles flown
Total Fees = $ 1670

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions