•  Back 
  •  Assembler 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : Pure Assembler Documentation
Author      : John Kormylo
Version     : PASM.HYP 1.0
Subject     : Documentation/Pure Assembler
Nodes       : 740
Index Size  : 20262
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : en
@default    : 
@help       : Help
@options    : +g -i -s +x +z -t4
@width      : 75
View Ref-File[ call_TOS ]

/* ******************************************************************
MACRO call_TOS ntrap,cmd,arg1,size1,arg2,size2,arg3,size3,arg4,size4

All GEMDOS, BIOS, XBIOS, VDI & AES functions are implemented by
TRAP instructions.  This macro will perform any such function call
involving up to four arguments.  Uses label 'npop'.

ntrap = trap number (1=GEMDOS, 2=AES & VDI, 13=BIOS, 14=XBIOS)
cmd   = command number
arg1 - arg4   = optional function arguments
size1 - size4 = size of arguments in bytes (1, 2, or 4)

For example, 'Pterm0()' could be implemented by 'call_TOS 1,0'
****************************************************************** */

MACRO call_TOS ntrap,cmd,arg1,size1,arg2,size2,arg3,size3,arg4,size4

npop = 2     ;number bytes to pop off stack.  cmd takes 2 bytes
             ;push arguments onto stack
IFNB arg4
  IF size4 == 1
    move.b  arg4,-(A7)
  ENDIF
  IF size4 == 2
    move.w  arg4,-(A7)
  ENDIF
  IF size4 == 4
    move.l  arg4,-(A7)
  ENDIF
  npop = npop + size4
ENDIF

IFNB arg3
  IF size3 == 1
    move.b  arg3,-(A7)
  ENDIF
  IF size3 == 2
    move.w  arg3,-(A7)
  ENDIF
  IF size3 == 4
    move.l  arg3,-(A7)
  ENDIF
  npop = npop + size3
ENDIF

IFNB arg2
  IF size2 == 1
    move.b  arg2,-(A7)
  ENDIF
  IF size2 == 2
    move.w  arg2,-(A7)
  ENDIF
  IF size2 == 4
    move.l  arg2,-(A7)
  ENDIF
  npop = npop + size2
ENDIF

IFNB arg1
  IF size1 == 1
    move.b  arg1,-(A7)
  ENDIF
  IF size1 == 2
    move.w  arg1,-(A7)
  ENDIF
  IF size1 == 4
    move.l  arg1,-(A7)
  ENDIF
  npop = npop + size1
ENDIF

  move.w  cmd,-(A7)  ;push command onto stack
  trap #ntrap        ;perform trap
  add.l #npop,A7     ;restore stack pointer
ENDM