'===========================================================================
' Subject: ASSEMBLY IN QBASIC                 Date: 12-15-95 (21:45)       
'  Author: Stephan Van Loendersloot           Code: QB, QBasic, PDS        
'  Origin: FidoNet QUIK_BAS Echo            Packet: ASMCODE.ABC
'===========================================================================
'> While I got through your twit filter somehow ;) To those who are
'> trying to use my GUI Interface in QBasic (instead of QuickBasic 4.5),
'> it won't work - you'll need to use DOS Calls CALL INTERRUPT command in
'> QuickBasic.  QBasic won't support those.  BUT, I will try to get at it
'> and make a QBasic version sometime soon.

'> Anyone know how to convert CALL INTERRUPT stuff into PEEK & POKE?...

'Here I am...again ;-)

'It's pretty easy to use assembly stuff in QBasic. It's not possible to write
'variables in registers via Basic. The following is an example of how to
'incorporate some assembly in Qbasic. It does not attempt to do anything very
'ambitious. It only beeps the speaker, but that's not the point. Point is how to
'use assembly in QBasic (GWBasic also accepts it, but line number have to be
'added).

'Now here's what you need to do.
'First write the program / routine that you wish to use in Basic, in assembly.
'My program doesn't do much, as I already stated:

mov ah, 2       ; Write a character to screen
mov dl, 7       ; Ascii character 7 (= bell)
int 21h         ; Call to DOS
retf            ; Far return to transfer control back to BASIC

(BTW. I skipped the 'push bp' etc. since I don't use any variables passed to
the function).
Once assembled, this translates to the following bytes:

&HB4, &H02, &HB2, &H07, &HCD, &H21, &HCB

This has to be written to memory and executed.

DIM Beeper%(1)
MemoryLoc% = VARPTR(Beeper%(1))
'mov ah, 2
POKE MemoryLoc%, &HB4
POKE MemoryLoc% + 1, &H2
'mov dl, 7
POKE MemoryLoc% + 2, &HB2
POKE MemoryLoc% + 3, &H7
'int 21h
POKE MemoryLoc% + 4, &HCD
POKE MemoryLoc% + 5, &H21
'retf
POKE MemoryLoc% + 6, &HCB
CALL ABSOLUTE(Returnvalue%, VARPTR(Beeper%(1))

ReturnValue% isn't used.

'I know it could be much more optimized, but I wanted to give an oversimplified
'example, so everyone can understand it.
