Asm errors with latest version.

DOS specific questions.
Dinosaur
Posts: 1186
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Asm errors with latest version.

Postby Dinosaur » Jul 05, 2013 5:42

Hi All

Recompiling an older Dos project with the latest version and have struck
some errors. Compiling for Windows works perfectly, but the identical routines
creates errors in some haphazard places.

I know the routines can be significantly improved, or one used for all 4, but I dont Fix what Aint broken.

Code: Select all

Function AD7701C2 (ByVal Addr As Integer) As Integer
#ifdef __FB_DOS__
    Dim BitCount2 As Integer
    Dim DDS As Ushort = _dos_ds
Asm
    mov     eax,[DDS]           ' Directly using "_dos_ds" won't work here !!!
    push    eax
    pop     gs                  ' Just to get sure, it is usually set anyway
    mov     cl,[gs:0x046C]      ' Get current Tick count
    add     cl,2                ' add 2 x 1/18 sec
    MOV     DX,[Addr]           ' set input address
B1:
    CMP     cl,[gs:0x046C]
    JE      B4                  ' chip stuffed, so quit.
    IN      AL,DX            'Wait here for DREADY to go on.
    TEST   AL,2            'as this syncronises for the next
    JZ      B1               'loop which is
B2:
    IN      AL,DX            'wait for next time
    TEST   AL,2            'DREADY bit is off.
    JNZ      B2               'loop if not off.

    MOV      BITCOUNT2,0         '2 otherwise ,zero the bitcount.
    MOV      AL,0            '2 set Chip Select bit to ACTIVE LOW.
    OUT      DX,AL            '11 and send it to port.
    XOR      BX,BX            '2
    NOP                     '3
    NOP                     '3
    NOP                     '3
    NOP                     '3
    JMP      READBIT2          '7
    '*******************************;
BIT_LOOP2:            
    SHL      BX,1            '*3
    MOV      AL,16            '*2
    OUT      DX,AL            '*11 Set clk hi
    NOP                     '*3
    NOP                     '*3
    NOP                     '*3
    NOP                     '*3
                                'spec says 50nsec min.
    MOV      AL,0            '*2  = *2 x 30ns = 60nsec
    OUT      DX,AL            '*16 = *17 X 30ns = 510 nsec
    NOP                     'spec says 180nsec min.
    NOP                     '
    NOP                     '*6  = *6 x 3 = 18 clks
    NOP                  
    NOP                  
    NOP                  
READBIT2:               
    IN      AL,DX            '*13
    TEST   AL,4            '*2 otherwise test databit
    JZ      B3               '*7
    OR      BX,1            '*2 set bit in word.
B3:               
    INC      BITCOUNT2         '*6
    CMP      BITCOUNT2,16         '*5 Is it bit 16 ?
    JB      BIT_LOOP2         '*7 if not keep reading bits.
    Jmp      B5
B4:
    Mov      BX,65534
B5:   '-------------------------------
    MOV      AL,32            '*2 Last bit recvd so
    OUT      DX,AL            '*11 set CS hi again
    MOV      [Function],BX      
End Asm
#Endif
End Function


I have 4 Identical Asm routines that are just named different and have different
label names.
The first of these 3 compiles with AS.EXE without errors, but on the next three
I get errors in places that dont make sense.
assembling: C:\fbdos\bin\dos\as.exe --32 --strip-local-absolute "RunMod02.asm" -o "RunMod02.o"

RunMod02.asm: Assembler messages:
In Function AD7701C2
RunMod02.asm:149: Error: invalid use of register
OUT DX,AL

RunMod02.asm:179: Error: invalid use of register
B3:

RunMod02.asm:180: Error: invalid use of register
INC BITCOUNT2

In Function AD7701C3
RunMod02.asm:228: Error: invalid use of register
OUT DX,AL

RunMod02.asm:259: Error: invalid use of register
End Asm

RunMod02.asm:260: Error: invalid use of register
#EndIf

In Function AD7701C4
RunMod02.asm:308: Error: invalid use of register
NOP

Last Line Nbr in This module Is 330, but the following errors ?????

RunMod02.asm:339: Error: invalid use of register
RunMod02.asm:340: Error: invalid use of register
RunMod02.asm:388: Error: invalid use of register
RunMod02.asm:419: Error: invalid use of register
RunMod02.asm:420: Error: invalid use of register

assembling failed: 'C:\fbdos\bin\dos\as.exe' terminated with exit code 1

Is there some numbering problem with AS.EXE ?
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Asm errors with latest version.

Postby MichaelW » Jul 05, 2013 6:37

Using 0.24.0, for function AD7701C2 I get Error: invalid use of register for the three lines that reference BITCOUNT2. Wrapping the references in [] I then get Error: ambiguous operand size… for the same lines, so after modifying the operands to:

DWORD PTR [BITCOUNT2]

The compile completes with no errors or warnings.

[OFFTOPIC] Are you back in business?
Dinosaur
Posts: 1186
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Re: Asm errors with latest version.

Postby Dinosaur » Jul 05, 2013 7:08

Hi All

Michael, nice to hear from you again.
No, I am not back in business, but some customers keep throwing projects at me.
If they only involve software, or on-site consultancy, then I supplement my pension.
Last one was Ice cream factory in SLC Utah.
This one is Chineese Noodles in Sydney.

[Back on Topic]
In earlier versions I didnt have any errors, as this is working on site.
Dont know which version that was though.

It doesn't seem to matter which way I declare the variable, the same errors, with the same line numbers.

EDIT: Apologies Michael, the mod you suggested did work.
Still leaves the question as to what changed, and I originally compiled this in 2010.
Many thanks for your unending help.
dkl
Site Admin
Posts: 3206
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Asm errors with latest version.

Postby dkl » Jul 07, 2013 6:41

The GNU assembler (GAS from GNU binutils) apparently has become more strict about the Intel syntax it accepts over the years, and more recent versions of FB will naturally come with more recent binutils version. Of course you could replace the *.exe files in bin\dos\ with old ones, as long as it works for you.

From my experience with GAS, it's wise to always specify DWORD PTR and such, instead of just using DWORD or omitting it completely, as I think is possible with other assemblers.
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

Re: Asm errors with latest version.

Postby DOS386 » Aug 07, 2013 5:18

Dinosaur wrote:RunMod02.asm:339: Error: invalid use of register
RunMod02.asm:340: Error: invalid use of register
RunMod02.asm:388: Error: invalid use of register
RunMod02.asm:419: Error: invalid use of register
RunMod02.asm:420: Error: invalid use of register
assembling failed: 'C:\fbdos\bin\dos\as.exe' terminated with exit code 1


Rediscovered this BUG ?

> Is there some numbering problem with AS.EXE ?

BIG problem: it refers to the .ASM file, not to the .BAS file ?
dkl
Site Admin
Posts: 3206
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Asm errors with latest version.

Postby dkl » Aug 07, 2013 10:13

Yea, it's the assembler which doesn't get to know about the .bas file. And fbc (which handles the .bas file) doesn't check the inline ASM syntax.

You can preserve the .asm file by compiling with the -R option, and even add -g to get fbc to emit the original lines of code into the .asm file that may allow finding the corresponding inline asm blocks in the input .bas. I'm afraid there's no better solution at the moment. It'd be great if the assembler could interprete debugging information if present, but it doesn't seem like that works. It could be an interesting project though to try and get fbc to parse the assembler's error messages and map them back to the input .bas.

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 2 guests