English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do I write a procedure to sort an array in Assembly language that will find the largest value and another procedure to find the smallest value in the array?
Do I need to use some kind of sort? For example: bubble sort.
In C and C++, it is so much easier.

Only serious responses, please.

2007-03-26 15:56:01 · 2 answers · asked by Rosy 3 in Computers & Internet Programming & Design

2 answers

I have read your prior questions and assume IA-32 (Intel Architecture) - basically an x86 instruction set.

Your problem description is confusing so I'm going to help you with the following problem - find the largest value in an array. I am going to do it in a pseudocode that is close to assembly

load address register with address of the array
load index register with the size of the array
load register with maximum negative number // holds the current largest value
load register 2 with -1 // the offset of the largest number
loop label:
compare value pointed to by address plus index to register
jump if register is larger to loop label 2
load register with value pointed to by address plus index
load register 2 with current value of the index register
loop label 2:
increment index register
jump if index > 0 to loop label

// done

2007-03-29 12:19:01 · answer #1 · answered by Mn 6 · 1 0

assembly isn't device language, for the reason that device language is one million's and nil's. assembly language is in basic terms a human readable form of device language. each coaching in assembly immediately correlates with a device language op-code. With that stated, there are a number of different device languages, each designed to run on one form of CPU. So there are different assembly languages that are linked with different device languages. there is not any different language that has training that immediately correlate with an op-code. additionally you may no longer use an identical assembly training for an 8051, and collect on an 8085 or the different CPU. in case you like a application to run on the two, you will possibly desire to completely rewrite it. There are compilers which you would be able to write code in C, and collect for a particular CPU, yet that's no longer a sort of assembly, in basic terms a a techniques better point language.

2016-10-20 12:44:10 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers