home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / books / 68k_book / arp_src / prg_6gp.s < prev    next >
Text File  |  1985-11-20  |  3KB  |  77 lines

  1.  ; Program Name: PRG_6GP.S
  2.  ;      Version: 1.001
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;     Assemble in PC-relative mode and save with a TOS extension.
  7.  
  8.  ; Execution Instructions:
  9.  
  10.  ;     Execute from the desktop.
  11.  
  12.  ; Program Function:
  13.  
  14.  ; Within a subroutine addressed by XBIOS function $26, does the following:
  15.  
  16.  ;   1. Turns off keyclick sound.
  17.  ;   2. Prints a string with GEMDOS function $9.
  18.  ;   3. Prints a string with BIOS function $3.
  19.  
  20.  ; See programs PRG_6DP and PRG_6EP for further documentation.
  21.  
  22.  ; Program Purpose:
  23.  
  24.  ;   Illustrate the use of XBIOS function $26 to execute a subroutine in
  25.  ;   the supervisor mode, even though the subroutine contains GEMDOS and
  26.  ;   BIOS function calls.  This example shows that these function calls
  27.  ;   can be executed within the subroutine, a contradiction to information
  28.  ;   contained in some of the references (See page 3-13 of the Peel book,
  29.  ;   for example.).
  30.  
  31. mainline:
  32.  lea        stack, a7           ; Point A7 to this program's stack.
  33.  
  34. execute_subroutine_in_supervisor_mode:
  35.  pea        subroutine          ; Push address of subroutine onto stack.
  36.  move.w     #$26, -(sp)         ; Function = superexec = XBIOS $26 (dec 38).
  37.  trap       #14                 ; XBIOS call.
  38.  addq.l     #6, sp
  39.  
  40. terminate:
  41.  move.w     #0, -(sp)           ; Function = p_term_old = GEMDOS $0.
  42.  trap       #1                  ; GEMDOS call.
  43.  
  44. subroutine:         
  45.  move.b     #6, $484
  46.  pea        message             ; Push address of first string.
  47.  move.w     #$9, -(sp)          ; GEMDOS function $9 = c_conws.
  48.  trap       #1                  ; Print first string.
  49.  addq.l     #6, sp
  50.  lea        message_2, a3       ; Load address of second string.
  51. print_string:
  52.  move.b     (a3)+, d3
  53.  beq.s      wait_for_keypress
  54.  move.w     d3, -(sp)
  55.  move.w     #2, -(sp)
  56.  move.w     #3, -(sp)           ; BIOS function $3 = bconout.
  57.  trap       #13
  58.  addq.l     #6, sp
  59.  bra.s      print_string        ; Branch until NULL detected.
  60. wait_for_keypress: 
  61.  move.w     #8, -(sp)           ; Function = c_necin = GEMDOS $8.
  62.  trap       #1                  ; GEMDOS call.
  63.  addq.l     #2, sp              ; Reposition stack pointer at top of stack.
  64.  rts
  65.  
  66.  data
  67. message:     dc.b 'This string printed with GEMDOS function $9.',$D,$A,0
  68. message_2:   dc.b 'This string printed with BIOS function $3.',$D,$A,0
  69.  align
  70.  bss
  71.              ds.l    48         ; Stack.  Must be large enough for system
  72.                                 ; use when the switch to supervisor mode
  73.                                 ; is accomplished by GEMDOS $26.
  74. stack:       ds.l     0         
  75. program_end: ds.l     0
  76.  end
  77.