home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / PT.ZIP / PT.ASM < prev    next >
Assembly Source File  |  1992-12-17  |  3KB  |  72 lines

  1. ;       Author:
  2. ;               Josiah Standing
  3. ;
  4. ;       Purpose:
  5. ;       Illustrates how some of the Return and Call functions
  6. ;       work.
  7. ;
  8.         .MODEL  small           ;For MASM Compatibility
  9.                                 ;(I prefer TASM's TINY Model)
  10.         .CODE
  11.         org     100h            ;Starting point for .COM files
  12.  
  13. start:                          ;Program entry point
  14.  
  15.                                 ;Simulate calls by pushing the values
  16.                                 ;ourself.
  17.         push    offset finish   ;Push our last address to process
  18.                                 ;on the Stack. (Function 4)
  19.         pushf
  20.         push    cs              ;Save 3-words for the IRET function
  21.         push    offset get_key  ;(Function 3)
  22.                                 ;Equiv: Int ?
  23.  
  24.         push    offset print_msg2 ;Save offset address
  25.                                   ;(Function 2)
  26.                                 ;Equiv: Call print_msg2
  27.  
  28.         push    cs
  29.         push    offset print_msg1 ;Save 2-words for the RETF function
  30.                                   ;(Function 1)
  31.         retf                    ;Pop two addresses off the Stack (CS:IP)
  32.                                 ;Equiv: Call far print_msg1
  33.  
  34. get_key:                        ;(Function 3)
  35.         lea     dx,msg3         ;Load DX with memory offset for msg3
  36.         call    print_string    ;Display msg3
  37.  
  38.         xor     ah,ah
  39.         int     16h             ;ROM BIOS Get Keypress function
  40.         ret
  41.  
  42. print_msg1:                     ;(Function 1)
  43.         lea     dx,msg1         ;Load DX with memory offset for msg1
  44.         call    print_string    ;Display msg1
  45.         ret                     ;Pop next address off the Stack
  46.                                 ;(IP)
  47.  
  48. print_msg2:                     ;(Function 2)
  49.         lea     dx,msg2         ;Load DX with memory offset for msg2
  50.         call    print_string    ;Display msg2
  51.         iret                    ;Pop next addresses off the stack
  52.                                 ;(CS:IP,FLAGS)
  53.  
  54. finish:                         ;(Function 4)
  55.         int     20h             ;Old DOS Terminate Program function
  56.  
  57. print_string:
  58.         mov     ah,9            ;DOS Print string function (DX=offset of
  59.                                 ;string terminated by a dollar sign)
  60.         int     21h
  61.         ret                     ;Pop next address off the Stack
  62.  
  63. msg1    db      'This is a test.'
  64.         db      0ah, 0dh, 0ah, '$'
  65.  
  66. msg2    db      'This is only a test.'
  67.         db      0ah, 0dh, 0ah, '$'
  68.  
  69. msg3    db      'Press any key to exit:'
  70.         db      0ah, 0dh, '$'
  71.         end     start
  72.