BBC BASIC for Windows
« [BB4WFORTH] Memory Allocation and thoughts... »
Welcome Guest. Please Login or Register. Apr 5th, 2018, 10:02pm
ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018. Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.
If you require a dump of the post on your message board, please come to the support board and request it.
[BB4WFORTH] Memory Allocation and thoughts...
« Thread started on: Sep 25th, 2009, 12:05am »
At the end of this message is some sample code for doing memory allocations in BB4W.
It would be appreciated if someone was able to provide a hint as to how COMPILE, and POSTPONE could be added as there's some interesting code here http://www.jwdt.com/~paysan/mini-oof.html
The code for Mini OOF could with translation might also be of interest to anyone wanting to attempt OO in BBCBASIC using structures and indirect PROC/FN calls
Alex Farlie
\ Memory Allocation words for BB4WFORTH
\ Allocation words... \ These are wrappers around the equivlant Win32 API Functions \ FIXME: ior is the Win32 error code at present - Somone might want to convert these to BB4W type error codes.
HEX : _CHECK_HANDLE (handle -- handle ior) DUP \Duplicate return value =0 \ IS Null? IF 'GetLastError' \ Get the last error value from Windows SYSCALL ELSE 0 \ Otherwise the IOR code is 0= Success! THEN ; : ALLOCATE (u -- handle ior) \ Allocate fixed memory 40 LITERAL \ GPTR Constant SWAP \ Reorder for API call 'GlobalAlloc' SYSCALL \Global alloc call _CHECK_HANDLE
; : FREE (a-addr -- ior) 'GlobalFree' SYSCALL _CHECK_HANDLE SWAP DROP \ Don't want handle only want I/O code. ;