Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Assembly (http://www.programmingforums.org/forum20.html)
-   -   smallest number.... (http://www.programmingforums.org/showthread.php?t=10561)

Edgar. Jun 28th, 2006 5:11 PM

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.

Edgar. Jun 28th, 2006 5:29 PM

DaWei can you help me?

Jimbo Jun 28th, 2006 5:33 PM

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.

Edgar. Jun 28th, 2006 5:39 PM

[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]

DaWei Jun 28th, 2006 6:07 PM

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.

mrynit Jun 28th, 2006 8:25 PM

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.

Wizard1988 Jun 28th, 2006 11:13 PM

You should take a look at this Instruction table. I have one printed and accesible at all times :)

tempest Jun 29th, 2006 12:11 AM

Quote:

Originally Posted by mrynit
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.

When you know what you're looking for, a list is pointless. Keep only enough variables for what you want to end up with, and compare each new value to see if it should take the place of what's in the variables. At the end, you should end up with what you want.

mrynit Jun 29th, 2006 12:26 AM

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