Guest_imported
New member
- Jan 1, 1970
- 0
hey guys
how do you find the average between three numbers in assembly language. here is what i have done so far: if you can help, i would be appreciate it very much. thanks
void Find( int *Address, int Number, int *Maximum, int * Minimum, double *Average) {
int Min, Max;
asm{
mov Min, 0x7FFF // Assign largest possible value
mov Max, 0x8000 // Assign smallest possible value
mov bx, word ptr Address // Offset address of array to search Number of
mov cx, word ptr Number // elements in array.
} // end asm
Loop:
asm{ // Loop around the array looking for Min and Max
mov ax, [bx] // Get next array element
add bx, 2 // Point to next element, ready for next time around loop
// Replace Min, if element smaller than current Min
cmp ax, Min
jge MaxTest
mov Min, ax
// Replace Max if element greater than current Max
MaxTest:
cmp ax, Max
jle Finish
mov Max, ax
Finish: // Loop back if more elements left
dec cx
jnz Loop
// Put Min answer into contents pointed to by Minimum
mov bx, word ptr Minimum
mov ax, Min
mov [bx], ax
// Put Max answer into contents pointed to by Maximum
mov bx, word ptr Maximum
mov ax, Max
mov [bx], ax
// put average answer into contents pointed to by average
mov bx, word ptr Average
mov ax, average
mov [bx], ax
} // end asm statement
} /*end of function Find*/
how do you find the average between three numbers in assembly language. here is what i have done so far: if you can help, i would be appreciate it very much. thanks
void Find( int *Address, int Number, int *Maximum, int * Minimum, double *Average) {
int Min, Max;
asm{
mov Min, 0x7FFF // Assign largest possible value
mov Max, 0x8000 // Assign smallest possible value
mov bx, word ptr Address // Offset address of array to search Number of
mov cx, word ptr Number // elements in array.
} // end asm
Loop:
asm{ // Loop around the array looking for Min and Max
mov ax, [bx] // Get next array element
add bx, 2 // Point to next element, ready for next time around loop
// Replace Min, if element smaller than current Min
cmp ax, Min
jge MaxTest
mov Min, ax
// Replace Max if element greater than current Max
MaxTest:
cmp ax, Max
jle Finish
mov Max, ax
Finish: // Loop back if more elements left
dec cx
jnz Loop
// Put Min answer into contents pointed to by Minimum
mov bx, word ptr Minimum
mov ax, Min
mov [bx], ax
// Put Max answer into contents pointed to by Maximum
mov bx, word ptr Maximum
mov ax, Max
mov [bx], ax
// put average answer into contents pointed to by average
mov bx, word ptr Average
mov ax, average
mov [bx], ax
} // end asm statement
} /*end of function Find*/