home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / programmation / scm4e2.arc / !NewFuncs < prev    next >
Text File  |  1995-08-03  |  3KB  |  101 lines

  1. New Routines
  2. ------------
  3.  
  4. After some thought, a couple of new routines for further experimentation
  5. and interference with:
  6.  
  7. ----------
  8. Name: swi
  9.  
  10. Function: Enables users to call any SWI via providing a list of register 
  11.           values to use and a SWI number.
  12.        
  13. Example:
  14.           (swi 4       ; OS_ReadC
  15.             '(0))      ; Must provide a list with at least one element, 
  16.                        ; the rest are assumed to be zero if not provided.
  17.  
  18. Will result in the character pressed being returned in register zero, i.e.
  19. if the user pressed 'A' then you would get
  20.  
  21.     '(65 0 0 0 0 0 0 0 0 0)
  22.  
  23. as a result.
  24.  
  25. Notes: It does not seem a good idea to try making Scheme multitask via
  26.        providing calls that perform Wimp_Initialise and Wimp_Poll---this
  27.        seems to result in a Mess (i.e. DONT do that then ;-)
  28.  
  29.        Registers are zeroed if not provided with values, i.e. if you call
  30.        (swi n '(1 2 3))
  31.        then the registers used for the swi call will be as follows:
  32.        r0 r1 r2 r3 r4 r5 r6 r7 r8 r9
  33.        1  2  3  0  0  0  0  0  0  0
  34.  
  35.        Registers after the call are returned.    
  36.        
  37.        Strings may be passed as register values as a pointer to the string
  38.        as an integer is put into the register for the SWI call.
  39. ----------
  40. Name: _dehex
  41.  
  42. Function: Enables users to convert from a string hexadecimal representation
  43.           to the integer value.
  44.           
  45. Example:
  46.           (_dehex "f")
  47.  
  48. returns the result 15.
  49.  
  50. Notes: Typically of use in creating SWI calls where you have the hex value
  51.        but are too lazy to get out your calculator to work out the decimal
  52.        value. Hence you can create the second argument to swi via backquote
  53.        and judicious use of ','.           
  54. ----------
  55. Name: _makebuf
  56.  
  57. Function: Makes a blank buffer that is n bytes big, and returns the pointer
  58.           to the space allocated as an integer.
  59.           (Actually, you get n+1 bytes, but the last one is a null for
  60.           obvious reasons...)
  61.  
  62. Example: 
  63.           (_makebuf 20) 
  64.  
  65. returns a pointer to a null terminated buffer capable of holding 20 bytes 
  66. worth of information.
  67.  
  68. Notes: Uses of this are creation of a buffer and then passing the value
  69.        returned as value of a SWI register for a SWI call if space is needed.
  70.          
  71. ----------
  72. Name: _dsptr
  73.  
  74. Function: Dereferences a string pointer at a given address and returns the
  75.           string found there.
  76. Example: 
  77.           (define a (_makebuf 5))
  78.           (_dsptr a)
  79.  
  80. will return "     " or whatever happens to be in that buffer area pointed to
  81. by `a' at that time.
  82. ----------
  83. Name: _free
  84.  
  85. Function: Frees memory associated with a given address passed as an integer.
  86.  
  87. Example:
  88.           (define a (_makebuf 5))
  89.           ; do something with buffer pointed to by a--e.g. used for swi call
  90.           (_free a)
  91.           
  92. Notes: You should NOT rely on the contents of buffers that were allocated
  93.        and subsequently freed via this means---it is more than likely the
  94.        contents will be overwritten after the _free call and anything that
  95.        then allocates memory thereafter.
  96. ----------       
  97.  
  98.  
  99.  
  100. ams
  101. 3/8/95