flat assembler
Message board for the users of flat assembler.

Index > DOS > Is FASM able to communicate with QBasic Quickly and easily?

Author
Thread Post new topic Reply to topic
Oz



Joined: 01 Mar 2004
Posts: 3
Location: Canda
Oz 01 Mar 2004, 15:19
Is FASM able to communicate with QBasic Quickly and easily?
I have MASM32, but i don't like it, and it really isn't dos based
If FASM isn't QB compatible, any suggestions one which ASM interpreter to use?

Oz~

_________________
Oz-"Call Me A Bible Thumper, And I'll give you"
Guy-"Give Me What?"
Oz-"The Meanest Look"
Post 01 Mar 2004, 15:19
View user's profile Send private message Reply with quote
Cas



Joined: 26 Feb 2004
Posts: 82
Location: Argentina
Cas 02 Mar 2004, 05:02
I have to tell you that QuickBasic 4.5 is my native programming language Razz and even when I am every day doing more and more low level, I always get back to QB when I need to do something simple or when it doesn't need much speed and I want to see everything in a clear way instead of fighting against the computer.
I even programmed a couple of games in QuickBASIC and lastly I've used routines in assembly in them. Before I met Flat Assembler, I had to do everything with the MSDOS Debug, you know it? And it was a pain... besides, it does not support more than the 8086's instructions. But believe me FASM is HEAVEN for this.
The way I do it now is this:

FIRST - I create an ASM file which begins like this

db "Texto" ; This can be any five-char string, say a header
dw total_length ; This will be a word that QB will need
org 000h ; This makes the start of the code at offset zero


SECOND - I write the routine and end it with total_length label

xor ax,ax ; For example, this routine shows the mouse cursor
inc ax
int 33h
iret ; IRET is needed, for this is an interrupt routine

total_length: ; This label is for FASM to calculate the length and put it in
; the header

THIRD - I save the file and compile it with FASM

cwsdpmi.com
fasm routine.asm routine.bin

FOURTH - I go to QuickBasic and use BLOAD to load the file

This can be done in many ways. What I recommend is this: get the length of the file with LOF and store it in a variable, say filelength&, then release some memory (QB takes up all memory when it runs) like this:

filelength& = filelength& + 4096 'Exagerate, just in case
a% = SETMEM(-filelength&) 'Release the memory

Now use the DOS interrupt to allocate memory. (You will have to run QB with the /L parameter in order to be able to use the CALL INTERRUPT statement)

DIM reg as RegTypeX

reg.ax = &H4900
reg.bx = filelength&/16
call interruptx(&H21, reg, reg)

segment% = reg.ax

a% = SETMEM(655360) 'Recover as much memory as possible for QB

Now you have a memory block for your own, no longer QuickBasic's. You can use BLOAD to load the routine there.

DEF SEG = segment%
BLOAD "routine.BIN", 0
DEF SEG

If you don't like using the interrupts, you can load this into a text variable or an array, but you must check that it starts at offset zero.

FIFTH - Enable an interrupt for your routine

This is done by choosing a free interrupt (80h, for example) and calling interrupt 21h (DOS) to point it to your routine. Check first that the interrupt is free!!!! I won't do that here.

reg.ax = &H2580 'Set Interrupt Vector 80h
reg.ds = segment%
reg.dx = 0
call interruptx(&H21, reg, reg)

SIXTH - Ready! You can call your routine like this

call interruptx(&h80, reg, reg)

-- --------------------------------------------------------

Note that if you make your program EXE, it will deallocate the memory automatically, but if you're running it inside QuickBasic, you will also need to deallocate the memory block with function 49h. I recommend you to do it always, just in case.

If you don't have QB, but only QBASIC, you won't be able to use CALL INTERRUPT, so you will have to do this with CALL ABSOLUTE. I recommend you to get QuickBasic 4.5, if that is the case, but if you can't, contact me and I will explain you how to do this with CALL ABSOLUTE. If this sounds too complex for you, it's just me... I'm complex, but believe me this is simple.

My e-mail is: pedrosa_lucas@yahoo.com.ar

Cas

_________________
«Earth is my country; science is my religion» - Christian Huygens
Post 02 Mar 2004, 05:02
View user's profile Send private message Yahoo Messenger MSN Messenger Reply with quote
Oz



Joined: 01 Mar 2004
Posts: 3
Location: Canda
Oz 02 Mar 2004, 14:45
I already have a quicker mouse routien than that:

Code:
DEFINT A-Z

Declare sub MouseDriver(ax,bx,cx,dx)

DO
MouseDriver 3, MouseButton, MouseX, MouseY

MouseDriver 2,0,0,0
'..Drawing
MouseDriver 1,0,0,0
loop until len(Inkey$)

end

SUB MOUSEDRIVER (ax,bx,cx,dx)
dim RegData(1 to 2) as RegTypeX
RegData(1).AX=ax
RegData(1).BX=bx
RegData(1).CX=cx
RegData(1).DX=dx

Call InterruptX (51, RegData(1), RegData(2))     '51 = &HC i belive...

ax = RegDat(2).AX
bx = RegDat(2).BX
cx = RegDat(2).CX
dx = RegDat(2).DX

END SUB
    


Ta-Da.....Mouse Support

That is all

Oz~

_________________
Oz-"Call Me A Bible Thumper, And I'll give you"
Guy-"Give Me What?"
Oz-"The Meanest Look"
Post 02 Mar 2004, 14:45
View user's profile Send private message Reply with quote
Cas



Joined: 26 Feb 2004
Posts: 82
Location: Argentina
Cas 06 Mar 2004, 05:47
Very Happy I know that it's simpler to make a mouse routine the way you say. In fact, THAT is the way I use the mouse, but the interrupt handler I am telling you about here does not only work for mouse routines, but it can also be used for anything, like a bit blitter, for example, which is the main use I give to it.


Cas Smile

_________________
«Earth is my country; science is my religion» - Christian Huygens
Post 06 Mar 2004, 05:47
View user's profile Send private message Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.