home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / TEXT / UTILITY / COOKIE.ZIP / COOKIE.MSG < prev   
Encoding:
Text File  |  1991-12-11  |  2.6 KB  |  77 lines

  1.   From: Mike Marotta
  2.     To: All                Date: 07 Dec 91  04:27:30
  3.   Subj: Fortune Cookie
  4.   Conf: `PC Assembly Language'
  5.  
  6. Michael E. Marotta                          
  7. 5751 Richwood  #34
  8. Lansing, MI  48911
  9.  
  10.                An Efficient "Fortune Cookie" Program
  11.  
  12.         Using DEBUG you can write a program that can be called 
  13. from your AUTOEXEC.BAT file to display a clever saying each time 
  14. the computer boots.  The working code in COOKIE.COM consumes a 
  15. mere 22 bytes.  The entire file fits in just over 4 Kbytes.
  16.         COOKIE.COM selects one of sixty fortunes based on the 
  17. value of the seconds counter of the system clock.  When Function 
  18. 2C of Interrupt 21H calls the system clock, the seconds are 
  19. stored in the DH register.  Multiplying the seconds by 46 and 
  20. adding 120 gives the address of the fortune.  This value is moved 
  21. from the AX to the DX register because Function 09H of INT 21 
  22. displays a string whose offset is held in DX.  This interrupt is 
  23. called twice.  To save space, the carriage return (0D), line feed  
  24. (0A) and the $ are stored in locations 118, 119 and 11A so that 
  25. the CR LF pair is executed after the fortune is displayed.  INT 
  26. 20 halts the program with a return to DOS.
  27.         I allowed only 70 (46H) characters per saying because the 
  28. amount text you can enter is limited by the prompt, the E 
  29. command, and the requisite quotation marks and dollar sign $ for 
  30. each string.
  31.         Before keying in the clever remarks, I zeroed out the 
  32. working space (F for Fill) to ensure that I could easily edit the 
  33. sayings later. 
  34.         The entire program (code and data) is saved to disk by 
  35. setting the CX register to the size of the program, Naming it 
  36. COOKIE.COM and Writing it.
  37.  
  38. figure 1. Entering COOKIE.COM in the DEBUG environment.
  39.                                                                        
  40.  
  41. C:> debug 
  42. -a 100                
  43. 1607:0100 mov ah,2c  
  44. 1607:0102 int 21
  45. 1607:0104 mov al,46   
  46. 1607:0106 imul dh  
  47. 1607:0108 add ax,120
  48. 1607:010B mov dx,ax
  49. 1607:010D mov ah,09 
  50. 1607:011F int 21  
  51. 1607:0111 mov dx,0118
  52. 1607:0114 int 21 
  53. 1607:0116 int 20
  54.  
  55. e 118
  56. 1607:0118 00.0d 00.0a 00.24
  57.  
  58. -f 114 1500 00 
  59. -e 120 "Beam me up Scottie, there's no intelligent life down here. $"
  60. -e 166 "8 + 8 = 10 $"
  61. -e 1ac "Hello, Dave, it's good to be working with you again. $"
  62.  
  63. (and so on, in increments of 46H bytes)
  64.  
  65. -e 1142 "Welcome, my son: Welcome to the machine !$"
  66. -r cx
  67. CX 0000
  68. :1088
  69. -n cookie.com
  70. -w
  71. Writing 1088 bytes
  72. -q 
  73. C:>  
  74.  
  75. --- Maximus 2.00
  76.  * Origin: LCC CAI BBS, Lansing MI -- (517) 483-9609 (1:159/575)
  77.