home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / ASM / ASMS4QB.ZIP / SAVESPC.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-07-15  |  1.5 KB  |  40 lines

  1. ;Save memory: put your print messages into code space for easy access by
  2. ;Quick BASIC programs without using precious data space.
  3. ;Written by Bruce W. Tonkin on 12/30/85.  Copyright 1985, Bruce W. Tonkin.
  4. ;This routine may be used with or without attribution.
  5. ;Simple modifications to this routine can save any data into any part of code
  6. ;space.  Doing this is left as an exercise for the student.
  7. ;
  8. data     segment   word public 'data'
  9.  
  10. storage  dw   0
  11. data     ends
  12. dgroup   group     data
  13. code     segment   byte public 'code'
  14.          assume cs:code, ds:data
  15.  
  16.          public    generr
  17. generr   proc      far       ;routine is a far procedure
  18.          push      bp        ;save base pointer
  19.          mov       bp,sp     ;index off stack
  20.          push      ds        ;save data segment
  21.          call      messg     ;print whatever
  22.          pop       ds        ;restore data segment
  23.          pop       bp        ;and base pointer
  24.          ret
  25. generr   endp
  26. messg    proc near
  27.          mov       ax,cs     ;manipulate code segment
  28.          mov       ds,ax     ;into the data segment
  29.          mov       dx,offset show      ;so we can print some fake code
  30.          mov       ah,9      ;set up for print
  31.          int       21h       ;call DOS service routine for print.
  32.          ret
  33. show     db        'This is a message.',0dh,0ah
  34.          db        'The message can take as much room as you need.',0dh,0ah
  35.          db        '$'
  36.          ret
  37. messg    endp
  38. code     ends
  39.          end
  40.