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 the windows 32 framework , write an assembly language program ; write a procedure to...
Using the windows 32 framework , write an assembly language program ; 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...
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 a MIPS assembly language program that inputs a floating-point number and shows its internal 32-bit...
Write a MIPS assembly language program that inputs a floating-point number and shows its internal 32-bit representation as a 8-digit hexadecimal representation. For example: 2.5 decimal is 10.1 binary, which normalized is 1.01x21 and would be stored in the IEEE format as 0100 0000 0010 0000 0000 0000 0000 0000 which is 0x40200000
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.
- sparc assembly - *Write a program that takes four 32-bit integers (A,B,C,D) in hexadecimal form...
- sparc assembly - *Write a program that takes four 32-bit integers (A,B,C,D) in hexadecimal form and calculates A*B + C*D. (Assumption: User input is 32-bit 0 or positive. The result is expressed in 64 bits.) [result example] bash $ assm Hex value? ffffffff Hex value? 8 Hex value? ffffffff Hex value? 8 Result is 0000000f fffffff0
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT