Calculate W =Y+ (X-Z) using base plus direct address, repeat using scaled index
ID: 3668828 • Letter: C
Question
Calculate W =Y+ (X-Z) using base plus direct address, repeat using scaled index
Use loop to implement the code.
Using x86 Assembly language MASM
Need a starting point to implement this code. Given the following data definitions: X BYTE 4, 16, 28, 88, 100, 216, 168, 204, 192, 40, 52, 128, 180, 208, 64, 76, 156, 144, 132, 220 Y SWORD 32765, -16373, -19651, -22927, 29491, 7,-3271, 26215, 6559, 16387, 13111, 9835, 3283, -6545, -9823, -13099, 22937, 19663, -26201, 29479 Z DWORD 32765h, 116373h, 08A19651h, OFF22927H, 29491H, 7H, OABCD3271H, 26215H, 6559H, 16387H, ODEF13111,9835H, 3283H, 80006545H, 90129823H, 87613099H, 22937H, 19663H, OBA926201H, OCDE29479H
Explanation / Answer
#include <stdio.h>
// prototype for the function
void sum(int, int);
// we simply had given a forewarning to the compiler that
// somewhere down the track, please expect a function with
// couple of integer parameters
void main() {
sum(5,6); // see the wonder – we are allowed to call a function that is not defined yet !!
// appreciate the power of C and Assembly!!
} // end main
// now to the actual definition:
void sum(int i, int j) {
printf(“ %d “, i+j);
} // end function sum
version 2: will give an error because the prototype is missing
#include <stdio.h>
// prototype for the function
// void sum(int, int); // prototype is commented out – hence will error
// we simply had given a forewarning to the compiler that
// somewhere down the track, please expect a function with
// couple of integer parameters
void main() {
sum(5,6); // due to lack of prototype, compiler will complain here
} // end main
// now to the actual definition:
void sum(int i, int j) {
printf(“ %d “, i+j);
} // end function sum
version 3: Will work as Prototype is not required as the function is defined ahead of the calling point
#include <stdio.h>
void sum(int i, int j) {
printf(“ %d “, i+j);
} // end function sum
void main() {
sum(5,6);
} // end main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.