Some fun with CALL ABSOLUTE
code not tested. Maybe someone might try to get it to work?
DIM apple AS LONG ' 4bytes
DIM string AS STRING * 20 'reserve space for ASM code
DEF SEG = VARSEG(apple)
FOR x% = 0 to 11
READ d%
DATA &h66,&hb8,&ha0,&h86,&h01,&h00,&h66,&ha3,&h00,&h00,&hcb"
POKE (VARPTR(apple) + 4 + x%),d%)
next x%
CALL ABSOLUTE(VARPTR(apple) + 4)
DEF SEG 'put DS where it was
PRINT apple ' should = 100000
****
here is the assembler code encoded in the DATA
'mov eax,100000
'mov [[0]],eax 'the single brackets would not show on the site so had to use 2 brackets.
'RETF
****
In mov [[0]],eax the offset might not be zero. In Quick Basic the offset is 6 If DS was pointing to start of BC_DATA segment.
got the idea from
https://scruss.com/qbasic_hlp/T008A.htmlhere is a site where you can disassemble code
http://shell-storm.org/online/Online-Assembler-and-Disassembler/?inst=mov+ax%2C0%0D%0Aretf&arch=x86-16&as_format=inline#assemblyQuite a few of the online assemblers put a 66h in front of an opcode when it shouldn't - be careful!
**** So QB knows where the variable "apple" is in memory but the ASM code does not really know unless the offsets are predictable.