Question

I need the following done in MASM (Assmebly or ASM)

Write an assembly language(x86) program to sort in ascending order 10 integers numbers read from the keyboard and display in order.


.model small

.stack 100h 

.data



.code

start:

Mov ax ,@data

Mov ds.ax







mov ax ,4c00h

Int 21h 

End start

0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1


Write an assembly language(x86) program to sort in ascending order 10 integers numbers read from the keyboard and display in order.


Algorithm 
1. Load data from offset 500 to register CL
2. Travel from starting memory location to last and compare two numbers if the first number is greater than the second number then swap them.
3. First-pass fix the position for the last number
4. Decrease the count by 1.
5. Again travel from starting memory location to (last-1, by using of count)and compare two numbers if the first number is greater than the second number then swap them.

6. the Second pass fix the position for the last two numbers
7. repeated


CODE 

.model small
.stack 100h
.data
strg1 DB 'Insert numbers: $'
strg2 DB 'Sorted numbers: $'
Arr Db 10 dup(?)
v dw ?
.code
main proc
mov ax,@data
mov ds,ax

mov ah,9
lea dx,strg1
int 21h

mov dl,0ah
mov ah,2
int 21h

;inputs
mov di,0
mov cx,10
Input_loop:

mov ah,1
int 21h
mov arr[di],al

mov dl,0ah
mov ah,2
int 21h
inc di
loop Input_loop

mov v,0
sort:

mov di,0
mov cx,10
sub cx,v

B:
mov al,Arr[di]
cmp al,Arr[di+1]
jng C

mov al,Arr[di]
xchg al,Arr[di+1]
mov Arr[di],al
c:
inc di
loop B
inc v
cmp v,10
jne sort

;Output
mov ah,9
lea dx,strg2
int 21h

mov dl,0ah
mov ah,2
int 21h

mov di,0
mov cx,10
Output_loop:

mov dl,Arr[di]
mov ah,2
int 21h
inc di

mov dl,0ah
mov ah,2
int 21h
loop output_loop

mov ah,4ch
int 21h

main endp
end main


answered by: gavin
Add a comment
Answer #2
Algoritm
source: Curse,
answered by: Miki mouse
Add a comment
Answer #3
Vggggg
source: Gggvvv
answered by: Miki mouse
Add a comment
Know the answer?
Add Answer to:
I need the following done in MASM (Assmebly or ASM)
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with a code in assembly language MASM (x86)

    write an assembly language (x86) program to input in a string 10 multi-digit integers and displays them in ascending order. Modify the code below to comply with the requirement..model small.stack 100h.datastrg1 DB 'Insert numbers: $'strg2 DB 'Sorted numbers: $'Arr Db 10 dup(?)v dw ?.codemain procmov ax,@datamov ds,axmov ah,9lea dx,strg1int 21hmov dl,0ahmov ah,2int 21h;inputsmov di,0mov cx,10Input_loop:mov ah,1int 21hmov arr[di],almov dl,0ahmov ah,2int 21hinc diloop Input_loopmov v,0sort:mov di,0mov cx,10sub cx,vB:mov al,Arr[di]cmp al,Arr[di+1]jng Cmov al,Arr[di]xchg al,Arr[di+1]mov Arr[di],alc:inc diloop Binc vcmp v,10jne sort;Outputmov ah,9lea dx,strg2int...

  • Analyze this assembly program (emu 8086) line by line! and explain the purpose of the program!...

    Analyze this assembly program (emu 8086) line by line! and explain the purpose of the program! PROGRAM: .model small .stack 100h .data    num1 db ?    num2 db ?    num3 db ?    MSG1 DB 10,13,"ENTER FIRST NUMBER : $"    MSG2 DB 10,13,"ENTER SECOND NUMBER: $"      MSG3 DB 10,13,"ENTER SECOND NUMBER: $"      MSG4 DB 10,13,"SMALLER NUMBER IS : $"    avg db ? ends .code .start    main proc        mov ax,data       ...

  • Explain each line of code. What does the routine do. model small .stack 100h .code main...

    Explain each line of code. What does the routine do. model small .stack 100h .code main proc mov BL, 36 yor BL, 40h mov CL, 16h m: mov ah,6 mov dl, bl. add DL, CL int 21h dec CL jnz m mov ax,4C00h int 21h main endp end main Good luck!

  • I need the following done in MASM (Assmebly or ASM) This program must use Irvine Library and the outline for the code is...

    I need the following done in MASM (Assmebly or ASM) This program must use Irvine Library and the outline for the code is below (Kip irvine) Write an assembly language program to input a string from the user. Your program should do these two things: 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   ...

  • This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the...

    This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the solution is not there. Programming exercise 12.7 #2. The code must be in assembly language for Intel using Kip Irvine library. An example of the source code would be: INCLUDE Irvine32.inc .code main PROC mov ax,4000h mov bx,1000h mov cx,1500h sub ax,bx sub ax,cx call DumpRegs exit main ENDP END main Question: Write a procedure that receives a single-precision floating-point binary value and displays...

  • MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the...

    MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...

  • MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest...

    MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...

  • Convert the following assembly language program into a C program: *Update: The variables are initialized, in...

    Convert the following assembly language program into a C program: *Update: The variables are initialized, in lines 4 & 6 of the red assembly language code. Convert the following assembly language program into a C program: *Update: The variables are initialized, in lines 4 & 6 of the red assembly language code. include "p24Hxxxx.inc" global__reset bss: Uninitialized data section: Variables start at location 0x0800 x: .space 2: Allocating space (two bytes) to variable. y: .space 2;Allocating space (two bytes) to...

  • You have to put the input to the line(Linea), rectangle(rectangulo), triangle(triangulo) and circle(circulo) in assembly 8086...

    You have to put the input to the line(Linea), rectangle(rectangulo), triangle(triangulo) and circle(circulo) in assembly 8086 please, Same as this code, add that input that I'm asking. Which user of the size and the area where the figure will be located on the screen. .MODEL SMALL   .STACK 100h .DATA    mensaje db 'Seleccione una opcion del siguiente Menu',13, 10        db '1. Dibujar un Circulo', 13, 10        db '2. Dibujar una Linea', 13, 10        db '3. Dibujar un...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT