Question
This homework tests your ability to evaluate potential pipeline hazards. The following program is used as a model. It computes vehicle sales by large (>50000)
This homework tests your ability to evaluate potential pipeline hazards. The following program is used as a model. It computes vehicle sales by large (>50000) and small makes.
// WarRawWawRarSample.cpp : Sample program for Homework 5
#include
#include
#define makes 29
int main(int argc, char* argv[])
{
// Vehicle sales from
// http://online.wsj.com/mdc/public/page/2_3022-autosales.html#autosalesD
char makers[makes][12] = {
"GM", "Ford", "Chrysler", "Toyota",
"Honda", "Nissan", "Hyundai", "Mazda",
"Mitsubishi", "Kia", "Subaru", "Mercedes",
"Volvo", "Volkswagen", "Audi", "BMW",
"Porsche", "Fiat", "Tesla", "Jaguar",
"Land Rover", "Alfa Romeo", "Mini", "Smart",
"Ferrari", "Maserati", "Bentley", "Lamborghini",
"Rolls Royce"};
int sales[makes] = {
259557, 229739, 196526, 211125,
148829, 123861, 62213, 26195,
9674, 56508, 50380, 31825,
6168, 27112, 17801, 24951,
5410, 3045, 2900, 1087,
5188, 60, 4796, 466,
217, 1066, 110, 89,
79};
int i, j, large = 0, small = 0, largetot = 0, smalltot = 0;
const int lim = 50000;
for (i = 0; i < makes; i++) {
if (sales[i] > lim) {
large++;
largetot += sales[i];
}
else {
small++;
smalltot += sales[i];
}
}
std::cout << "Large:" << large << " vehicles:" << largetot << " Small:" << small << " vehicles:" << smalltot << ' ';
return 0;
}
On the following page, you will find the assembly code generated by the for loop above. List the type of hazard (WAR, WAW, RAW, RAR, Control, or none) and the data item causing the hazard in the spaces provided. These lines will be identified by an arrow ( ). Ignore lines marked N/A. The associated C++ code is interspersed. Note that the dword ptr [i] syntax refers to i as a variable, not as a subscript.
Address | Opcode | Operands | Hazard Type | Caused By |
for (i = 0; i < makes; i++) { |
| |||
010369EF | mov | dword ptr [i],0 | N/A |
|
010369F9 | jmp | main+5EAh (01036A0Ah) | N/A |
|
010369FB | mov | eax,dword ptr [i] |
| |
01036A01 | add | eax,1 |
| |
01036A04 | mov | dword ptr [i],eax |
| |
01036A0A | cmp | dword ptr [i],1Dh | N/A |
|
01036A11 | jge | main+65Ah (01036A7Ah) | N/A |
|
if (sales[i] > lim) { |
| |||
01036A13 | mov | eax,dword ptr [i] |
| |
01036A19 | cmp | dword ptr sales[eax*4],0C350h | N/A |
|
01036A24 | jle | main+630h (01036A50h) | N/A |
|
large++; |
| |||
01036A26 | mov | eax,dword ptr [large] | N/A |
|
01036A2C | add | eax,1 | N/A |
|
01036A2F | mov | dword ptr [large],eax | N/A |
|
largetot += sales[i]; |
| |||
01036A35 | mov | eax,dword ptr [i] |
| |
01036A3B | mov | ecx,dword ptr [largetot] |
| |
01036A41 | add | ecx,dword ptr sales[eax*4] |
| |
01036A48 | mov | dword ptr [largetot],ecx |
| |
} |
| |||
else { |
| |||
01036A4E | jmp | main+658h (01036A78h) | N/A |
|
small++; |
| |||
01036A50 | mov | eax,dword ptr [small] |
| |
01036A56 | add | eax,1 | N/A |
|
01036A59 | mov | dword ptr [small],eax | N/A |
|
smalltot += sales[i]; |
| |||
01036A5F | mov | eax,dword ptr [i] | N/A |
|
01036A65 | mov | ecx,dword ptr [smalltot] | N/A |
|
01036A6B | add | ecx,dword ptr sales[eax*4] | N/A |
|
01036A72 | mov | dword ptr [smalltot],ecx |
| |
} |
| |||
} |
| |||
01036A78 | jmp | main+5DBh (010369FBh) | N/A |
|
Which hazard type listed on the previous page (not none) is not really a hazard? ___________________
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started