'=========================================================================== ' Subject: ASSEMBLY LANGUAGE INTO BASIC Date: 04-17-96 (08:18) ' Author: Ian Musgrave Code: Text ' Origin: comp.lang.basic.misc Packet: FAQS.ABC '=========================================================================== > Hi all, > I am looking for a QBasic routine (not QuickBasic, please) that will > let you use Assembly language code in QBasic programs. > I have seen these all over the place. I even had a few, but I either > misplaced or deleted them. Well, there is no routine as such to convert ASM code to the assembly language hex code QBASIC and QB4.x requires for CALL ABSOLUTE. Mark K Kim's assembly language in BASIC tutorial at the following FTP site, ftp://users.aol.com/markkkim/asm_tutorial/ gives good step by step instructions for using DEBUG to convert ASM code to hex code. This won't work on MASM or TASM code though (but you should be able to convert this to DEBUG acceptable code with only minor difficulties if you know what you are doing). You can semi automate the system Mark mentions though. Here's a modification of one of his examples, the code to turn the mouse on. Create a file called mouseon.dbg (or cut and paste the example below) with the following DEBUG code (best read Marks examples first so this makes sense ;==========Mouseon.dbg, cut here a mov ax,0000 ;Copy 0000h to AX int 33h ;Interrupt 33h cmp ax,0000 ;Compare, is AX=0000h jz 010f ;If equal, Jump to last statement mov ax,0001 ;Else move 0001h to AX int 33 ;Interrupt 33h retf ;Return u 100 10f q ;=============cut here. now type DEBUG < mouseon.dbg > mouseon.asm This will send the contents of the debug session to a file called mouseon.asm which looks like this. ;========mouseon.asm -a 1289:0100 mov ax,0000 ;Copy 0000h to AX 1289:0103 int 33h ;Interrupt 33h 1289:0105 cmp ax,0000 ;Compare, is AX=0000h 1289:0108 jz 010f ;If equal, Jump to last statement 1289:010A mov ax,0002 ;Else move 0001h to AX 1289:010D int 33 ;Interrupt 33h 1289:010F retf ;Return 1289:0110 -u 100 10f 1289:0100 B80000 MOV AX,0000 1289:0103 CD33 INT 33 1289:0105 3D0000 CMP AX,0000 1289:0108 7405 JZ 010F 1289:010A B80100 MOV AX,0001 1289:010D CD33 INT 33 1289:010F CB RETF -q ;===========end you want the lines between -u and -q, now you have to select the hex codes and split them up (eg, ignore the 1289:0103, you just want CD33, which has to be split up into CD and 33 and then converted into a string format CALL ABSOULTE can use. So CD33 becomes CHR$(&HCD)+CHR$(&H33) (&H means hex) Thus you get '========================================================================== asm$ = "" asm$ = asm$ + CHR$(&HB8) + CHR$(&H0) + CHR$(&H0) 'MOV AX,0000 asm$ = asm$ + CHR$(&HCD) + CHR$(&H33) 'INT 33 Call the interupt asm$ = asm$ + CHR$(&H3D) + CHR$(&H0) + CHR$(&H0) 'CMP AX,0000 If AX is 0 then no mouse asm$ = asm$ + CHR$(&H74) + CHR$(&H5) 'JZ 010F so jump to the end asm$ = asm$ + CHR$(&HB8) + CHR$(&H1) + CHR$(&H0) 'MOV AX,0001 otherwise load AX with 1 asm$ = asm$ + CHR$(&HCD) + CHR$(&H33) 'INT 33 and do the interrupt asm$ = asm$ + CHR$(&HCB) 'RETF Return to the system DEF SEG = VARSEG(asm$) 'calculate segment offset% = SADD(asm$) 'calculate offset CALL ABSOLUTE(offset%) 'execute '============================================================================= It should be easy to write a parser that will take the mouseon.asm file and convert it to BASIC code, I might even do it when I get some time.