home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / msdos / programm / 8094 < prev    next >
Encoding:
Text File  |  1992-07-26  |  1.2 KB  |  30 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!news.cs.indiana.edu!noose.ecn.purdue.edu!ec.ecn.purdue.edu!shankar
  3. From: shankar@ec.ecn.purdue.edu (Shankar Ramakrishnan)
  4. Subject: Poser on abs() function in asm. lang.
  5. Message-ID: <1992Jul26.215541.4461@noose.ecn.purdue.edu>
  6. Sender: news@noose.ecn.purdue.edu (USENET news)
  7. Organization: Purdue University Engineering Computer Network
  8. Date: Sun, 26 Jul 1992 21:55:41 GMT
  9. Lines: 19
  10.  
  11.  
  12. While I went through the object code generated by Turbo C for the 
  13. integer abs() function, I saw something like this:
  14.   or ax,ax
  15.   js done
  16.   neg ax
  17. done:
  18. This has 6 bytes of code. I wondered whether there could be a shorter
  19. code, and yes, I came up with one that takes only 5 bytes. But instead
  20. of posting it on the net, I am leaving it as a puzzle to be solved by
  21. readers of this net.
  22. The problem is as follows: given an integer in AX, find a routine that
  23. has 5 bytes or less that returns the absolute value in AX. Assume 
  24. nothing about the contents of other registers or flags.
  25. Please DO NOT post your answers on the net. Instead, send your solution
  26. by email to me(shankar@ecn.purdue.edu). The names of the first 10
  27. people who give the correct solution will be posted by me on this net.
  28. Good luck.
  29. -Shankar
  30.