Direct Memory Access

Download MEMORY2.zip and and extract MEMORY.DLL, you can make a direct access to memory.
This can be used for invoking a Win32API or DLL function which has variable arguments.

Example. Put MEMORY.DLL at the same folder that contains BASIC.EXE or save the program at the folder where MEMORY.DLL is put.

DECLARE EXTERNAL FUNCTION GetMem, peek, peek2, peek4, PeekDouble
LET p=GetMem(28)
if p<>0 then
   FOR i=0 TO 4 
      CALL poke4(p+4*i,i)
   NEXT i
   LET a=PI
   CALL PokeDouble(p+4*i,a)
   FOR i=0 TO 4
      PRINT peek4(p+4*i)
   NEXT i
   PRINT PeekDouble(p+4*i)
   CALL FreeMem(p)
END IF
END

EXTERNAL FUNCTION GetMem(n)
assign "memory.dll","GetMem"
END FUNCTION
EXTERNAL  SUB FreeMem(p)
assign "memory.dll","FreeMem"
END SUB
EXTERNAL FUNCTION peek(p)
assign "memory.dll","Peek"
END FUNCTION
EXTERNAL SUB poke(p,i)
assign "memory.dll","Poke"
END SUB
EXTERNAL FUNCTION peek2(p)
assign "memory.dll","Peek2"
END FUNCTION
EXTERNAL  SUB poke2(p,i)
assign "memory.dll","Poke2"
END SUB
EXTERNAL FUNCTION peek4(p)
assign "memory.dll","Peek4"
END FUNCTION
EXTERNAL SUB poke4(p,i)
assign "memory.dll","Poke4"
END SUB
EXTERNAL FUNCTION PeekDouble(p)
SUB MoveM(p,s$,n)
   ASSIGN "Memory.dll","MoveM"
END SUB
LET s$=REPEAT$(CHR$(0),8)
CALL MoveM(p,s$,8)
LET PeekDouble=UnPackDBL(s$)
END FUNCTION
EXTERNAL SUB PokeDouble(p,a)
SUB MoveM(s$,p,n)
   ASSIGN "Memory.dll","MoveM"
END SUB
CALL MoveM(PackDBL$(a),p,8)
END SUB


GetMem(n) occupies n byte of memory and returns the address of the head. If this is zero, occupation has failed.
FreeMem(p) frees the occupied memory, where p must be set the value the GetMem function has returned.
peek(p) reads unsigned 8 bits at the address p.
peek2(p)reads unsigned 16 bits at the address p.
peek4(p)reads unsigned 32 bits at the address p.
Poke(p,i) writes the least significant 8 bits of an integer i.
Poke2(p,i) writes the least significant 16 bits of an integer i.
Poke4(p,i) writes the least significant 32 bits of an integer i.
PeekDouble(p) reads the double precision floatint point number from the address p.
PokeDouble(p,a) write the value a as a 8-byte double precision floating point number at p.