SlideShare a Scribd company logo
1 of 6
Download to read offline
In assembly language for x86 processors write a code that will log work hours and how much to
charge for each task along with calculating the stat avg.
While avoiding real numbers and the 32-bit binary they require store all hours data multiplied by
10, use dwords. Initialize the hours in an array and provide a corresponding array to be used to
hold the resulting amounts due; store the rate, multiplied by 100 (to get to pennies). While
computing the amounts due, adjust the result by dividing it by 10 (times were multiplied by 10
initially, which skews the amounts due), and compute the amounts due and total hours, use a
loop. Use the esi and edi registers to access array elements. Use only the eax, ebx, ecx, and edx
registers for processing, add the eax, ebx, ecx, and edx registers to the Watch, use the esi and edi
registers for the indices for the arrays, place breakpoints after calculating total hours, calculate
total due, calculate average hours, and calculate average due and on the ExitProcess. While
debugging, make sure all watches are viewable and add a memory view.
USE THESE VARIABLES: totTime (whole number * 10), totHours (whole), totMins (whole), totDue
(total in cents), totDueD (whole dollars), totDueC (whole), avgHours (in whole hours), avgMins (in
whole min), avgDueD (avg in dollars), avgDueC (avg in cents), and numCust (num customers set
by array examination).
USE PROCEDURES FOR THE FOLLOWING TASKS: Calculate Amounts Due, Calculate Total
Hours, calculate total minutes, Calculate Total Due (dollars & cents), Calculate Average Hours ,
calculate average minutes, and Calculate Average Due (dollars & cents).
HERE IS THE GIVEN CODE BELOW CORRECT IT SO IT RUNS WITHOUT ERRORS:
.386
.model flat,stdcall
.stack 4096
ExitProcess proto, dwExitCode:dword
.data
log_hours dd 80, 100, 60, 70, 90 ; hours worked on each task, multiplied by 10
log_rate dd 1200, 1500, 900, 1050, 1150 ; rate for each task, multiplied by 100
num_tasks equ 5 ; number of tasks in log_hours and log_rate arrays
.bss
totTime resd 1 ; total time worked, in tenths of an hour
totHours resd 1 ; total whole hours worked
totMins resd 1 ; total whole minutes worked
totDue resd 1 ; total amount due, in cents
totDueD resd 1 ; total amount due, in whole dollars
totDueC resd 1 ; total amount due, in cents
avgHours resd 1 ; avg hours worked
avgMins resd 1 ; avg min worked
avgDueD resd 1 ; avg amt due in whole dollars
avgDueC resd 1 ; avg amt due in cents
numCust resd 1 ; num of customers
.text
global _start
.code
main PROC
; PROCEDURES
; Calculate Amounts Due
; Parameters:
; esi: address of log_hours array
; edi: address of log_rate array
; ecx: number of tasks in log_hours and log_rate arrays
; Returns:
; eax: total amount due, in cents
calc_amounts_due:
xor eax, eax ; initialize total amount due to 0
calc_loop:
; Load hours and rate for current task
mov edx, [esi]
mov ebp, [edi]
; Multiply hours and rate
imul edx, ebp
; Add to total amount due
add eax, edx
; Move to next task
add esi, 4
add edi, 4
loop calc_loop
ret
; Calculate Total Hours
; Parameters:
; esi: address of log_hours array
; ecx: number of tasks in log_hours array
; Returns:
; eax: total time worked, in tenths of an hour
; Clobbers:
; eax, ebx, ecx, edx
calc_total_hours:
xor eax, eax ; initialize total time worked to 0
calc_loop:
; Load hours for current task
mov edx, [esi]
; Add to total time worked
add eax, edx
; Move to next task
add esi, 4
loop calc_loop
ret
; Calculate Total Minutes
; Parameters:
; eax: total time worked, in tenths of an hour
; Returns:
; edx: total time worked, in whole minutes
; Clobbers:
; eax, edx
calc_total_minutes:
xor edx, edx ; initialize total minutes to 0
mov ebx, 6 ; 60 (minutes per hour) / 10 (multiplier for hours)
div ebx ; divide by 6 to get total minutes
ret
; Calculate Total Due
; Parameters:
; eax: total amount due, in cents
; Returns:
; totDueD: total amount due, in whole dollars
; totDueC: total amount due, in cents
; Clobbers:
; eax, ebx, edx
calc_total_due:
; Compute whole dollars and cents separately
xor ebx, ebx ; initialize total dollars to 0
mov ecx, 100 ; 100 cents per dollar
div ecx ; divide by 100 to get total dollars
mov [totDueD], eax
xor eax, eax
mov ecx, 100 ; 100 cents per dollar
div ecx ; remainder is total cents
mov [totDueC], eax
ret
; Calculate Average Hours
; Parameters:
; eax: total time worked, in tenths of an hour
; ecx: number of tasks
; Returns:
; avgHours: average time worked, in whole hours
; Clobbers:
; eax, ebx, ecx, edx
calc_avg_hours:
xor edx, edx ; initialize total whole hours to 0
mov ebx, 10 ; 10 (multiplier for hours)
div ebx ; divide by 10 to get total whole hours
mov [totHours], eax
xor eax, eax
mov eax, [totHours]
div ecx ; divide by number of tasks to get average whole hours
mov [avgHours], eax
ret
; Calculate Average Minutes
; Parameters:
; eax: total time worked, in tenths of an hour
; ecx: number of tasks
; Returns:
; avgMins: average time worked, in whole minutes
; Clobbers:
; eax, edx
calc_avg_minutes:
xor edx, edx ; initialize total whole minutes to 0
mov ebx, 6 ; 60 (minutes per hour) / 10 (multiplier for hours)
div ebx ; divide by 6 to get total whole minutes
mov [totMins], edx
xor eax, eax
mov eax, [totMins]
div ecx ; divide by number of tasks to get average whole minutes
mov [avgMins], eax
ret
; Calculate Average Due
; Parameters:
; eax: total amount due, in cents
; ecx: number of tasks
; Returns:
; avgDueD: average amount due, in whole dollars
; avgDueC: average amount due, in cents
; Clobbers:
; eax, ebx, ecx, edx
calc_avg_due:
; Compute whole dollars and cents separately
xor ebx, ebx ; initialize total dollars to 0
mov ecx, 100 ; 100 cents per dollar
div ecx ; divide by 100 to get total dollars
xor eax, eax ; save total dollars in eax
mov ebx, [totHours] ; use totHours as temporary storage for total whole hours
mov [totHours], edx ; save total cents in totHours
mov eax, ebx ; restore total whole hours
div ecx ; divide by number of tasks to get average whole dollars
mov [avgDueD], eax
xor eax, eax
mov eax, [totHours]
div ecx ; divide total cents by number of tasks to get average cents
mov [avgDueC], eax
ret
; MAIN PROGRAM
_start:
; Calculate total time worked
lea esi, [log_hours]
mov ecx, [num_tasks]
call calc_total_hours
mov [totTime], eax
; Calculate total minutes worked
call calc_total_minutes
; Calculate total amount due
lea esi, [log_hours]
lea edi, [log_rates]
call calc_total_due
; Calculate average time worked
call calc_avg_hours
call calc_avg_minutes
; Calculate average amount due
mov eax, [totDue]
call calc_avg_due
; Exit the program
push 0
call [ExitProcess]
; DATA SECTION
.data
log_hours dd 1, 2, 3, 4, 5 ; Array of hours worked, multiplied by 10
log_rates dd 150, 100, 125, 200, 175 ; Array of rates, multiplied by 100
num_tasks dd 5 ; Number of tasks in the arrays
totTime dd 0 ; Total time worked, in tenths of an hour
totHours dd 0 ; Total time worked, in whole hours
totMins dd 0 ; Total time worked, in whole minutes
totDue dd 0 ; Total amount due, in cents
totDueD dd 0 ; Total amount due, in whole dollars
totDueC dd 0 ; Total amount due, in cents
avgHours dd 0 ; Average time worked, in whole hours
avgMins dd 0 ; Average time worked, in whole minutes
avgDueD dd 0 ; Average amount due, in whole dollars
avgDueC dd 0 ; Average amount due, in cents
; IMPORT SECTION
.idata
invoke ExitProcess, 0
main endp
end main
HERE ARE THE ERRORS THAT APPEAR (CORRECT THEM SO IT WILL DEBUG CLEANLY
WITH NO ISSUES AND WORK AS INTENDED IN VISUAL STUDIOS:

More Related Content

Similar to In assembly language for x86 processors write a code that wi.pdf

Practice Exercise Set 1
Practice Exercise Set 1Practice Exercise Set 1
Practice Exercise Set 1
rampan
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
shreeaadithyaacellso
 
#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx
AASTHA76
 

Similar to In assembly language for x86 processors write a code that wi.pdf (20)

Lesson 24. Phantom errors
Lesson 24. Phantom errorsLesson 24. Phantom errors
Lesson 24. Phantom errors
 
FPBrno 2018-05-22: Benchmarking in elixir
FPBrno 2018-05-22: Benchmarking in elixirFPBrno 2018-05-22: Benchmarking in elixir
FPBrno 2018-05-22: Benchmarking in elixir
 
Progress tracker - A handy progress printout pattern
Progress tracker - A handy progress printout patternProgress tracker - A handy progress printout pattern
Progress tracker - A handy progress printout pattern
 
Elixir and OTP Apps introduction
Elixir and OTP Apps introductionElixir and OTP Apps introduction
Elixir and OTP Apps introduction
 
Write an MPI program that implements a shell-sort like parallel algo.pdf
Write an MPI program that implements a shell-sort like parallel algo.pdfWrite an MPI program that implements a shell-sort like parallel algo.pdf
Write an MPI program that implements a shell-sort like parallel algo.pdf
 
Practice Exercise Set 1
Practice Exercise Set 1Practice Exercise Set 1
Practice Exercise Set 1
 
Writing Faster Python 3
Writing Faster Python 3Writing Faster Python 3
Writing Faster Python 3
 
Celery with python
Celery with pythonCelery with python
Celery with python
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
 
Devansh
DevanshDevansh
Devansh
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
 
How to create a high performance excel engine in java script
How to create a high performance excel engine in java scriptHow to create a high performance excel engine in java script
How to create a high performance excel engine in java script
 
Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)
 
Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)
 
C Language Lecture 16
C Language Lecture 16C Language Lecture 16
C Language Lecture 16
 
C# Loops
C# LoopsC# Loops
C# Loops
 
C Programming Homework Help
C Programming Homework HelpC Programming Homework Help
C Programming Homework Help
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 

More from adithyaups

In Java Please Write a program AirplanSeatingAssignment.pdf
In Java Please   Write a program AirplanSeatingAssignment.pdfIn Java Please   Write a program AirplanSeatingAssignment.pdf
In Java Please Write a program AirplanSeatingAssignment.pdf
adithyaups
 
In each of the following cases report the appropriate diagn.pdf
In each of the following cases report the appropriate diagn.pdfIn each of the following cases report the appropriate diagn.pdf
In each of the following cases report the appropriate diagn.pdf
adithyaups
 

More from adithyaups (20)

In Drosophila white eyes w and yellow body y are both r.pdf
In Drosophila white eyes w and yellow body y are both r.pdfIn Drosophila white eyes w and yellow body y are both r.pdf
In Drosophila white eyes w and yellow body y are both r.pdf
 
In Drosophila vestigial wings is an autosomal recessive tra.pdf
In Drosophila vestigial wings is an autosomal recessive tra.pdfIn Drosophila vestigial wings is an autosomal recessive tra.pdf
In Drosophila vestigial wings is an autosomal recessive tra.pdf
 
In Java Please Write a program AirplanSeatingAssignment.pdf
In Java Please   Write a program AirplanSeatingAssignment.pdfIn Java Please   Write a program AirplanSeatingAssignment.pdf
In Java Please Write a program AirplanSeatingAssignment.pdf
 
In java Develop a menubased shapemaker using randomly gen.pdf
In java Develop a menubased shapemaker using randomly gen.pdfIn java Develop a menubased shapemaker using randomly gen.pdf
In java Develop a menubased shapemaker using randomly gen.pdf
 
IN JAVA Develop a menubased shapemaker using randomly g.pdf
IN JAVA   Develop a menubased shapemaker using randomly g.pdfIN JAVA   Develop a menubased shapemaker using randomly g.pdf
IN JAVA Develop a menubased shapemaker using randomly g.pdf
 
In hindsight Bitcoin experienced a speculative bubble Whic.pdf
In hindsight Bitcoin experienced a speculative bubble Whic.pdfIn hindsight Bitcoin experienced a speculative bubble Whic.pdf
In hindsight Bitcoin experienced a speculative bubble Whic.pdf
 
in Figure 233 shows the different types Filiform papillae .pdf
in Figure 233 shows the different types Filiform papillae .pdfin Figure 233 shows the different types Filiform papillae .pdf
in Figure 233 shows the different types Filiform papillae .pdf
 
In his analysis of the Dell fraud for Forbes Edward Hess co.pdf
In his analysis of the Dell fraud for Forbes Edward Hess co.pdfIn his analysis of the Dell fraud for Forbes Edward Hess co.pdf
In his analysis of the Dell fraud for Forbes Edward Hess co.pdf
 
In his efforts to mobilize action learning and change in th.pdf
In his efforts to mobilize action learning and change in th.pdfIn his efforts to mobilize action learning and change in th.pdf
In his efforts to mobilize action learning and change in th.pdf
 
In humans being a tongue roller R is dominant to being a .pdf
In humans being a tongue roller R is dominant to being a .pdfIn humans being a tongue roller R is dominant to being a .pdf
In humans being a tongue roller R is dominant to being a .pdf
 
In HBS case studies Nextel Peru and Globalization of Cost of.pdf
In HBS case studies Nextel Peru and Globalization of Cost of.pdfIn HBS case studies Nextel Peru and Globalization of Cost of.pdf
In HBS case studies Nextel Peru and Globalization of Cost of.pdf
 
in gibi g mesafesinin yksek olduu lkelerde alanlarn a.pdf
in gibi g mesafesinin yksek olduu lkelerde alanlarn a.pdfin gibi g mesafesinin yksek olduu lkelerde alanlarn a.pdf
in gibi g mesafesinin yksek olduu lkelerde alanlarn a.pdf
 
In Figure 83 there are black squiggles in the RER compar.pdf
In Figure 83 there are black squiggles in the RER compar.pdfIn Figure 83 there are black squiggles in the RER compar.pdf
In Figure 83 there are black squiggles in the RER compar.pdf
 
In early 2015 Ford Motor F had a book value of equity of .pdf
In early 2015 Ford Motor F had a book value of equity of .pdfIn early 2015 Ford Motor F had a book value of equity of .pdf
In early 2015 Ford Motor F had a book value of equity of .pdf
 
In dogs locus B determines pigment color Bblack bbrown p.pdf
In dogs locus B determines pigment color Bblack bbrown p.pdfIn dogs locus B determines pigment color Bblack bbrown p.pdf
In dogs locus B determines pigment color Bblack bbrown p.pdf
 
In Block 1 Week 3 there is a description of various social.pdf
In Block 1 Week 3 there is a description of various social.pdfIn Block 1 Week 3 there is a description of various social.pdf
In Block 1 Week 3 there is a description of various social.pdf
 
In each of the following cases report the appropriate diagn.pdf
In each of the following cases report the appropriate diagn.pdfIn each of the following cases report the appropriate diagn.pdf
In each of the following cases report the appropriate diagn.pdf
 
In Db class we have two attributesinstance variables with t.pdf
In Db class we have two attributesinstance variables with t.pdfIn Db class we have two attributesinstance variables with t.pdf
In Db class we have two attributesinstance variables with t.pdf
 
In descriptive statistics the term standard error refers .pdf
In descriptive statistics the term standard error refers .pdfIn descriptive statistics the term standard error refers .pdf
In descriptive statistics the term standard error refers .pdf
 
In catastropheFamine phase the action required is Action r.pdf
In catastropheFamine phase the action required is Action r.pdfIn catastropheFamine phase the action required is Action r.pdf
In catastropheFamine phase the action required is Action r.pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 

Recently uploaded (20)

FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 

In assembly language for x86 processors write a code that wi.pdf

  • 1. In assembly language for x86 processors write a code that will log work hours and how much to charge for each task along with calculating the stat avg. While avoiding real numbers and the 32-bit binary they require store all hours data multiplied by 10, use dwords. Initialize the hours in an array and provide a corresponding array to be used to hold the resulting amounts due; store the rate, multiplied by 100 (to get to pennies). While computing the amounts due, adjust the result by dividing it by 10 (times were multiplied by 10 initially, which skews the amounts due), and compute the amounts due and total hours, use a loop. Use the esi and edi registers to access array elements. Use only the eax, ebx, ecx, and edx registers for processing, add the eax, ebx, ecx, and edx registers to the Watch, use the esi and edi registers for the indices for the arrays, place breakpoints after calculating total hours, calculate total due, calculate average hours, and calculate average due and on the ExitProcess. While debugging, make sure all watches are viewable and add a memory view. USE THESE VARIABLES: totTime (whole number * 10), totHours (whole), totMins (whole), totDue (total in cents), totDueD (whole dollars), totDueC (whole), avgHours (in whole hours), avgMins (in whole min), avgDueD (avg in dollars), avgDueC (avg in cents), and numCust (num customers set by array examination). USE PROCEDURES FOR THE FOLLOWING TASKS: Calculate Amounts Due, Calculate Total Hours, calculate total minutes, Calculate Total Due (dollars & cents), Calculate Average Hours , calculate average minutes, and Calculate Average Due (dollars & cents). HERE IS THE GIVEN CODE BELOW CORRECT IT SO IT RUNS WITHOUT ERRORS: .386 .model flat,stdcall .stack 4096 ExitProcess proto, dwExitCode:dword .data log_hours dd 80, 100, 60, 70, 90 ; hours worked on each task, multiplied by 10 log_rate dd 1200, 1500, 900, 1050, 1150 ; rate for each task, multiplied by 100 num_tasks equ 5 ; number of tasks in log_hours and log_rate arrays .bss totTime resd 1 ; total time worked, in tenths of an hour totHours resd 1 ; total whole hours worked totMins resd 1 ; total whole minutes worked totDue resd 1 ; total amount due, in cents totDueD resd 1 ; total amount due, in whole dollars totDueC resd 1 ; total amount due, in cents avgHours resd 1 ; avg hours worked avgMins resd 1 ; avg min worked avgDueD resd 1 ; avg amt due in whole dollars avgDueC resd 1 ; avg amt due in cents numCust resd 1 ; num of customers .text global _start
  • 2. .code main PROC ; PROCEDURES ; Calculate Amounts Due ; Parameters: ; esi: address of log_hours array ; edi: address of log_rate array ; ecx: number of tasks in log_hours and log_rate arrays ; Returns: ; eax: total amount due, in cents calc_amounts_due: xor eax, eax ; initialize total amount due to 0 calc_loop: ; Load hours and rate for current task mov edx, [esi] mov ebp, [edi] ; Multiply hours and rate imul edx, ebp ; Add to total amount due add eax, edx ; Move to next task add esi, 4 add edi, 4 loop calc_loop ret ; Calculate Total Hours ; Parameters: ; esi: address of log_hours array ; ecx: number of tasks in log_hours array ; Returns: ; eax: total time worked, in tenths of an hour ; Clobbers: ; eax, ebx, ecx, edx calc_total_hours: xor eax, eax ; initialize total time worked to 0 calc_loop: ; Load hours for current task mov edx, [esi] ; Add to total time worked add eax, edx ; Move to next task add esi, 4
  • 3. loop calc_loop ret ; Calculate Total Minutes ; Parameters: ; eax: total time worked, in tenths of an hour ; Returns: ; edx: total time worked, in whole minutes ; Clobbers: ; eax, edx calc_total_minutes: xor edx, edx ; initialize total minutes to 0 mov ebx, 6 ; 60 (minutes per hour) / 10 (multiplier for hours) div ebx ; divide by 6 to get total minutes ret ; Calculate Total Due ; Parameters: ; eax: total amount due, in cents ; Returns: ; totDueD: total amount due, in whole dollars ; totDueC: total amount due, in cents ; Clobbers: ; eax, ebx, edx calc_total_due: ; Compute whole dollars and cents separately xor ebx, ebx ; initialize total dollars to 0 mov ecx, 100 ; 100 cents per dollar div ecx ; divide by 100 to get total dollars mov [totDueD], eax xor eax, eax mov ecx, 100 ; 100 cents per dollar div ecx ; remainder is total cents mov [totDueC], eax ret ; Calculate Average Hours ; Parameters: ; eax: total time worked, in tenths of an hour ; ecx: number of tasks ; Returns: ; avgHours: average time worked, in whole hours ; Clobbers: ; eax, ebx, ecx, edx calc_avg_hours:
  • 4. xor edx, edx ; initialize total whole hours to 0 mov ebx, 10 ; 10 (multiplier for hours) div ebx ; divide by 10 to get total whole hours mov [totHours], eax xor eax, eax mov eax, [totHours] div ecx ; divide by number of tasks to get average whole hours mov [avgHours], eax ret ; Calculate Average Minutes ; Parameters: ; eax: total time worked, in tenths of an hour ; ecx: number of tasks ; Returns: ; avgMins: average time worked, in whole minutes ; Clobbers: ; eax, edx calc_avg_minutes: xor edx, edx ; initialize total whole minutes to 0 mov ebx, 6 ; 60 (minutes per hour) / 10 (multiplier for hours) div ebx ; divide by 6 to get total whole minutes mov [totMins], edx xor eax, eax mov eax, [totMins] div ecx ; divide by number of tasks to get average whole minutes mov [avgMins], eax ret ; Calculate Average Due ; Parameters: ; eax: total amount due, in cents ; ecx: number of tasks ; Returns: ; avgDueD: average amount due, in whole dollars ; avgDueC: average amount due, in cents ; Clobbers: ; eax, ebx, ecx, edx calc_avg_due: ; Compute whole dollars and cents separately xor ebx, ebx ; initialize total dollars to 0 mov ecx, 100 ; 100 cents per dollar div ecx ; divide by 100 to get total dollars xor eax, eax ; save total dollars in eax
  • 5. mov ebx, [totHours] ; use totHours as temporary storage for total whole hours mov [totHours], edx ; save total cents in totHours mov eax, ebx ; restore total whole hours div ecx ; divide by number of tasks to get average whole dollars mov [avgDueD], eax xor eax, eax mov eax, [totHours] div ecx ; divide total cents by number of tasks to get average cents mov [avgDueC], eax ret ; MAIN PROGRAM _start: ; Calculate total time worked lea esi, [log_hours] mov ecx, [num_tasks] call calc_total_hours mov [totTime], eax ; Calculate total minutes worked call calc_total_minutes ; Calculate total amount due lea esi, [log_hours] lea edi, [log_rates] call calc_total_due ; Calculate average time worked call calc_avg_hours call calc_avg_minutes ; Calculate average amount due mov eax, [totDue] call calc_avg_due ; Exit the program push 0 call [ExitProcess] ; DATA SECTION .data log_hours dd 1, 2, 3, 4, 5 ; Array of hours worked, multiplied by 10 log_rates dd 150, 100, 125, 200, 175 ; Array of rates, multiplied by 100 num_tasks dd 5 ; Number of tasks in the arrays totTime dd 0 ; Total time worked, in tenths of an hour totHours dd 0 ; Total time worked, in whole hours totMins dd 0 ; Total time worked, in whole minutes totDue dd 0 ; Total amount due, in cents totDueD dd 0 ; Total amount due, in whole dollars
  • 6. totDueC dd 0 ; Total amount due, in cents avgHours dd 0 ; Average time worked, in whole hours avgMins dd 0 ; Average time worked, in whole minutes avgDueD dd 0 ; Average amount due, in whole dollars avgDueC dd 0 ; Average amount due, in cents ; IMPORT SECTION .idata invoke ExitProcess, 0 main endp end main HERE ARE THE ERRORS THAT APPEAR (CORRECT THEM SO IT WILL DEBUG CLEANLY WITH NO ISSUES AND WORK AS INTENDED IN VISUAL STUDIOS: