Question

rte an assembl langage 시lows a use to enter and S nemle(s in an Order then J splay the largest and smallest entere num ber and the or der frem Smal to large ans large to smallt so Ive this Pro blem whoct as your APproach? Pl te Jeta, led,ゴnc lode utpet screenshots as Proof arles e ase
0 0
Add a comment Improve this question Transcribed image text
Answer #1

// here is the full code

// output is attached

// Approach : Read the numbers in to an array(In the program Label L3) and then take two variables (In the program Label L2), and assign them,
? variable representing smallest number = 999999

   variable representing largest number = -999999

now, iterate through each number , (Lable L7), If largest number is less than the current number in the array then replace largest number with current number(Label L5). If smallest number is greater than the current number in the array then replace the smallest number with the current number(Label L7).

?Now prin the largest and smallest numbers.

// CODE

.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "Please Enter 5 elements : \0"
LC1:
.ascii "%d\0"
LC2:
.ascii "Small : %d\12Large : %d\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $64, %esp
call ___main
movl $LC0, (%esp)
call _printf
movl $0, 60(%esp)
jmp L2
L3:
leal 28(%esp), %eax
movl 60(%esp), %edx
sall $2, %edx
addl %edx, %eax
movl %eax, 4(%esp)
movl $LC1, (%esp)
call _scanf
addl $1, 60(%esp)
L2:
cmpl $4, 60(%esp)
jle L3
movl $-999999, 56(%esp)
movl $999999, 52(%esp)
movl $0, 48(%esp)
jmp L4
L7:
movl 48(%esp), %eax
movl 28(%esp,%eax,4), %eax
cmpl 52(%esp), %eax
jge L5
movl 48(%esp), %eax
movl 28(%esp,%eax,4), %eax
movl %eax, 52(%esp)
L5:
movl 48(%esp), %eax
movl 28(%esp,%eax,4), %eax
cmpl 56(%esp), %eax
jle L6
movl 48(%esp), %eax
movl 28(%esp,%eax,4), %eax
movl %eax, 56(%esp)
L6:
addl $1, 48(%esp)
L4:
cmpl $4, 48(%esp)
jle L7
movl 56(%esp), %eax
movl %eax, 8(%esp)
movl 52(%esp), %eax
movl %eax, 4(%esp)
movl $LC2, (%esp)
call _printf
movl $0, %eax
leave
ret
.ident "GCC: (tdm-1) 5.1.0"
.def _printf; .scl 2; .type 32; .endef
.def _scanf; .scl 2; .type 32; .endef

// OUTPUT

Add a comment
Know the answer?
Add Answer to:
rte an assembl langage 시lows a use to enter and S nemle(s in an Order then...
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
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