Built-in assembly in BCC (Bruce C compiler) - How to use C variables?

I am writing a C program in real time. The program will be downloaded to the address 0x2000:0x0000and run. The register DSis equal CS, which is equal 0x2000. I am also debugging with bochs.

My goal is to print text on the screen. So I need a built-in assembly (for BIOS INT 10h).

Here is my test file:

asm("jmp _main");

void putchar(c) char c;
{
    asm("mov ah, 0x0e");
    asm("mov al, c");
    asm("xor bx, bx");
    asm("int 0x10");
}

void main ()
{
    asm("push cs");
    asm("pop ds");
    putchar('A');
    for(;;);
}

When I compiled it with this command ...

bcc -W -0 -c test.c -o test.obj

... it works. But when I try to associate it with ...

ld86 -d isimsiz.obj -o kernel.bin

... he gave me this error:

undefined symbol: c

Why is this happening? How can I use C variables under BCC In-Line Assembly?

If you know a good tutorial about BCC, leave a link. I could not find it on the Internet :(

Thanks in advance.

PS: BCC linker LD86.

+4
1

bcc C. :

void putchar(c)
{
#asm
     mov ah, 0x0e
     mov bx, sp
     mov al, [bx+2]
     xor bx, bx
     int 0x10
#endasm
}

, __FIRST_ARG_IN_AX__:

void putchar(c)
{
#asm
     mov ah, 0x0e
#if !__FIST_ARG_IN_AX__
     mov bx, sp
     mov al, [bx+2]
#endif
     xor bx, bx
     int 0x10
#endasm
}

, K & R- , int, , void putchar(c) char c; , . , libc putchar int.

, :

unsigned equipment;
int has_floppy() {
#asm
    int 0x11 ! get BIOS equipment list
    mov _equipment,ax
#endasm

    return (_equipment & 1);
}
}

dev86 libc .

+6

Source: https://habr.com/ru/post/1654899/


All Articles