Qbasicnews.com

Full Version: FB inline asm compiler bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I think I've found a bug in the FB compiler's treatment of inline assembly.
The .bas:
Code:
ASM
mov ax,[Regs.AX]
mov bx,[Regs.BX]
mov cx,[Regs.CX]
mov dx,[Regs.DX]
mov bp,[Regs.BP]
mov si,[Regs.SI]
mov di,[Regs.DI]
mov ds,[Regs.DS]
mov es,[Regs.ES]
int 10h
mov [Regs.ES],es
mov [Regs.DS],ds
mov [Regs.DI],di
mov [Regs.SI],si
mov [Regs.BP],bp
mov [Regs.DX],dx
mov [Regs.CX],cx
mov [Regs.BX],bx
mov [Regs.AX],ax
END ASM
Compiles into this .asm:
Code:
    mov ax,[Regs.AX]
    mov bx,[Regs.BX]
    mov cx,[Regs.CX]
    mov dx,[Regs.DX]
    mov bp,[Regs.BP]
    mov si,[Regs.SI]
    mov di,[Regs.DI]
    mov ds,[Regs.DS]
    mov es,[Regs.ES]
        _floor 10h
    mov [Regs.ES],es
    mov [Regs.DS],ds
    mov [Regs.DI],di
    mov [Regs.SI],si
    mov [Regs.BP],bp
    mov [Regs.DX],dx
    mov [Regs.CX],cx
    mov [Regs.BX],bx
    mov [Regs.AX],ax
Which generates (of course) the following error upon assembly:
Code:
test.asm:line: Error: invalid character '_' in mnemonic
because _floor isn't a valid mnemonic. FB has obviously translated int (as in int(4.3)=4) into floor, which makes no sense within an ASM block.
Is this real, am I crazy, or shouldn't I be using int anyway? (If the latter is the case, that's no good reason alone that FB shouldn't treat int right in ASM) In any case, I can correct the bad ASM file FBC generates, but what do I need to do to get it to finish the process and make me an EXE?
Use "int &H10".

EDIT: If you're using the DOS port, you should use __dpmi_int() instead of using inline assembly. If you're using any of the other ports of FB, you shouldn't use an INT because it's a priveleged instruction.
Quote:If you're using the DOS port, you should use __dpmi_int() instead of using inline assembly.

Sorry if this is a stupid question, but how? What's the syntax, or where can I find it, and how do I pass register (or other) values to it?
Code:
#include "dos/go32.bi"
#include "dos/dpmi.bi"
#include "dos/sys/farptr.bi"

Dim regs As __dpmi_regs

regs.x.ax = &H13
__dpmi_int &H10, @regs

Do While Len(InKey) = 0
    _farpokeb _dos_ds, &HA0000 + Int(Rnd * 64000), Int(Rnd * 256)
Loop

regs.x.ax = &H03
__dpmi_int &H10, @regs