Question

In: Computer Science

using Windows 32 bit framework , Write an assembly language program to find the second minimum...

using Windows 32 bit framework , Write an assembly language program to find the second minimum
element (formally, second minimum is larger than the minimum but smaller than all
the other elements in the array) of an array of size 100.
Note: You can define the array as nbrArray DWORD 23 45 21 67 78 95 dup(?) and
show that your program works for the first five elements. Display the second minimum in a message box using Input output macro

Solutions

Expert Solution

;given doubleword array and find first small number array and after second Small.


.MODEL FLAT
.STACK 256

.DATA
nbrArray DWORD 23,45,21,67,78,95 DUP ?
SMALLEST DWORD ?
SECOND_SMALLEST DWORD ?

.CODE
MAIN PROC

MOV EAX,0
LEA EBX nbrArray ;get address of nbrArray
MOV SMALLEST,EBX ; mov data in ebx to smallest

COMPARE_1:
INC EAX ;increment next value in array that stored eax
CMP EAX,10 ;compare value in eax with 10
JE UPDATED_SMALLEST ;if equal then jump Updated_smallest
LEA EBX,nbrArray ;get address of nbrArray
CMP EBX,SMALLEST ;compare value in Smllest with ebx value
JL UPDATE_SMALLEST ;if lessthan then jump update_smallest
JMP COMPARE_1 ; jump to compare_1

UPDATE_SMALLEST:  
MOV SMALLEST, EBX ; load ebx to smallest
JMP COMPARE_1 ; jump compare_1


UPDATED_SMALLEST:   
MOV EAX,0 ;return 0

FIND_SECOND_SMALLEST:

LEA EBX, nbrArray ;get address of nbrArray
CMP EBX, SMALLEST ;compare ebx with smallest
JE SPECIAL_CASE ;if equal jump to special case
MOV SECOND_SMALLEST,EBX ;load ebx to Second_smallest
JMP COMPARE_2 ;jump

SPECIAL_CASE:
INC EAX ;increment
JMP FIND_SECOND_SMALLEST ; jump to find_second_smallest


COMPARE_2:
INC EAX
CMP EAX, 10
JE EXIT
LEA EBX, nbrArray ;get address of nbrArray
CMP EBX, SECOND_SMALLEST ;compare
JL UPDATE_SECOND_SMALLEST ;if less then jump to update_second_smallest
JMP COMPARE_2 ; jump to

UPDATE_SECOND_SMALLEST:
CMP EBX,SMALLEST ; compare ebx that with 1st smallest
JE COMPARE_2 ; if equal then go to compare_2
MOV SECOND_SMALLEST,EBX ;load ebx that stored second smallest to Second_smallest
JMP COMPARE_2 ; jump to


MAIN ENDP
END MAIN


Related Solutions

Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
Write an assembly language program code to clear and set bit 7th and 19th in a...
Write an assembly language program code to clear and set bit 7th and 19th in a 32-bit variable called N.
Need to code this is assembly language. Using the windows32 framework, write a procedure to read...
Need to code this is assembly language. Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output...
Write an assembly language program for 8051 microcontroller to find the sum of the following series,...
Write an assembly language program for 8051 microcontroller to find the sum of the following series, 1, -2, +3, -4, +5, -6,..., up to 100 terms. Store lower byte in R0 and higher byte in R1.
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality:...
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality: Configures pin RA2 of the PIC24to be an output to control an attached LED. Configures pin RB13 of the PIC24 to be an input to read the value on an attached switch (this switch will connect to ground when pressed). Configures pin RB13 to use the internal pull-up resistor. After configuration, the LED will be "off" when the push-button is pressed, and "on" when...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
Using the MARIE computer assembly language, write a program that computes the following expression: z =...
Using the MARIE computer assembly language, write a program that computes the following expression: z = a * b * c. The computer will read in the input values a, b, and c from the keyboard and the final result (z) have to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Remember that the instruction set does not have an instruction to execute multiplication. Note: If any of the...
Write a program named subtract.asm that does the following using LC3 assembly language: Print a prompt...
Write a program named subtract.asm that does the following using LC3 assembly language: Print a prompt "PRESS TWO KEYS: " Note that the prompt MUST LOOK EXACTLY like the above, with a colon and a space after the word KEYS with no newline. Get a two key press from the user. Subtract the second characters ASCII code from the first characters ASCII code. If the result is positive, print the word POSITIVE. Turn in subtract.asm to the appropriate submission point...
Assembly Language Coding Using MARS (MIPS) 1)Write a program that prints your name in a Triangle....
Assembly Language Coding Using MARS (MIPS) 1)Write a program that prints your name in a Triangle. (NAME = John Doe) 2)Write a Program that intializes X to 10, Y to 20 and Z to -50, adds X and Y and Z and prints the following the value of each variable, for example value of x is 10 as well as the result of the addition.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT