![]() |
smallest number....
Hi I need to perform this:
Double the 2 smallest numbers and add that sum to the largest, but I need to know the smallest number from an input divice. |
DaWei can you help me?
|
have you come up with an algorithm or some pseudo code yet?
Oh, and we don't always reply within 20 minutes of your post. Some of us do have other things going on than sitting here, refreshing every couple minutes, and hoping for a new thread. |
[HTML]
.code getnum proc @@Height: mov dx,offset msg1 ;get Height call pstring call getdec ;make shure height are between 1 and 100 cmp ax,0 jz @@ok cmp ax,1 jb @@bad cmp ax,100 ja @@bad jmp @@ok @@bad: mov dx,offset complain call pstring jmp @@Height @@ok: cmp ax,0 mov val1,ax ret getnum ENDP next proc @@Length: mov dx,offset msg2 ;ger Length call pstring call getdec cmp ax,0 ;make shure length is between 1 and 100 jz @@ok cmp ax,1 jb @@bad cmp ax,100 ja @@bad jmp @@ok @@bad: mov dx,offset complain call pstring jmp @@Length @@ok: cmp ax,0 mov val2,ax next ENDP ;if is right how can I know the smallest number? [/HTML] |
The smallest number depends entirely upon your implementation (if you subscribe to the notion that negative numbers are smaller than zero, as I do). Each implementation usually has a header file defining the limits of such things. "Smallest" is a superlative. There cannot be two (different) 'smallest' numbers.
|
I dont know ASM but cant you make a list of the numbers then sort that list so the first or last numbers are the smallest and then grab those numbers? maybe try doing the ordering function in high level then porting it to ASM.
|
You should take a look at this Instruction table. I have one printed and accesible at all times :)
|
Quote:
|
yeah that right, i was just thinking more about order or numbers.
|
| All times are GMT -5. The time now is 11:22 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC