TCC can't understand

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
St8ic

TCC can't understand

Post by St8ic »

I hacked together a little bit of assembly code that SHOULD show the model and serial number of the primary master hard drive. compiled well with gcc (with some work), but TCC is too stupid to understand. On the first line it gives a "byte value exceeds bounds" AND a "'obj' output driver does not support one-byte relocations".

Code: Select all

        mov dx, 1f6h
        mov al,10100000b
        out dx,al
        inc dx
        mov al,11101100b
        out dx,al           
 still: in al,dx
        test al,8 
        jz still               
        mov cx,256 
        mov bx,0 
        lea si,[Buffer] 
   upp: mov dx,1f0h
        in ax,dx 
        cmp al,0 
        jne nxxt 
        mov al,20
  nxxt: cmp ah,0           
        jne  nxxt1          
        mov ah,20          
 nxxt1: mov [si+bx],al 
        mov [si+bx+1],ah
        add bx,2
        loop upp
       mov ax,2020
       cmp word [si+36h],ax
       je err0r
       xor bx,bx
       mov bl,Count
cont:  mov ax,word [si+bx]
       xchg ah,al   
       mov word [si+bx],ax
       cmp bx,46h
       je dis
       inc bx
       inc bx
       jmp cont
dis:   xor bx,bx
       mov bl,14h
cot:   mov ax,word [si+bx]
       xchg ah,al
       mov word [si+bx],ax
       cmp bx,24h
       je here
       inc bx
       inc bx
       jmp cot
here:  mov ah,09h
       mov dx,[@Model]         
       int 21h 
       mov byte [si+46h],"$"
       mov dx,[Buffer+36h]
       int 21h
       mov dx,[Serial]
       int 21h
       mov byte [si+24h],"$"
       mov dx,[Buffer+14h]
       int 21h
       jmp exit
err0r: mov ah,09h
       mov dx,[on_error]
       int 21h
exit:  ret

Buffer   DB 512, (0)
Count    db 36h
on_error db "No HDD0, or read error",13,10,"$"
@Model   db "Detecting HDD0...",13,10
         db "HDD0 model: ","$"
Serial   db 13,10
         db "HDD0 serial number: ","$"
Schol-R-LEA

Re:TCC can't understand

Post by Schol-R-LEA »

Shouldn't this have a [BITS 16] directive at the begining of the code? Even if the default is 16-bit code, it's better to be explicit.

I tried this under NASM, and it assembled fine when set to generate a DOS .COM file, but even after adding an [org 100h] directive, it would not run; however, this may be because it was running in the Windows XP console, which does not work well with 16-bit code (peculiarly, it returned an error 'Cannot load VDM IPX/SPX support', which makes no sense as it does not do anything regarding networking; however, I get the same message from another old 16-bit program I sometimes run, so it may just have something to do with the Windows console).

When I tried to generate an OMF object file (the same sort which TCC would create by default, IIRC) it returned the same "'obj' output driver does not support one-byte relocations" that TCC did, but not the other error message. This seems to be related to a limitation of the OMF (that is, DOS .EXE) format.

Could you post the GCC code? Even with Intel syntax and 16-bit code set, there are enough differences that the two that it would be easy to miss an actual difference in the effective code. Also, what platform and build of gcc and gas did you use (e.g., DOS/Windows DJGPP gcc2.98, Linux gcc3.2, etc.), what file format did you assemble it for, and did the program actually run as planned?
St8ic

Re:TCC can't understand

Post by St8ic »

The code didn't need to be altered for gcc 3.2 on a Linux rig to copile. However, it wouldn't run in Linux or Windows, like you said. I want to comple it into my own kernel using TCC or nasm. How did you get it to work with nasm? DId you have to alter the code or use any specific parameters? Thanks.
Post Reply