I really don't know exactly what you're doing, at this point. What I experimented with was some earlier code you posted. It has some "problems", but I imagine you've fixed them. I haven't actually tried any of this, just looked at the disassembly. It "looks like" it would work, as 16-bit code (although rather strange code). What I would do to actually "try" it would be to write up a bootsector which loads the code - somewhere - and jumps to it. I'm guessing you're trying this in an emulator, rather than actually booting to it from a floppy(?). "Should" work the same.
I can show you what I've got, I suppose...
start.asm
bits 16
global start
start:
extern main
call main
main.c
extern int paramter(int i);
extern void read();
extern void stop();
asm(".code16\n");
int main() {
if (paramter(9) == 9) {
read();
}
read();
stop();
return 0;
}
read.asm
bits 16
global read
read:
mov ah, 0x0
int 0x16
ret
paramter.asm
bits 16
global paramter
paramter:
push bp
mov bp, sp
mov al, [bp+8]
add al, 48
mov ah, 0x0E
int 0x10
mov ah, 0
pop bp
ret
stop.asm
bits 16
global stop
stop:
mov ah, 0x4C
int 0x21
ret
link.ld
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
00000000 E80D00 call word 0x10
00000003 0000 add [bx+si],al
00000005 0000 add [bx+si],al
00000007 0000 add [bx+si],al
00000009 0000 add [bx+si],al
0000000B 0000 add [bx+si],al
0000000D 0000 add [bx+si],al
0000000F 00 db 0x00
00000010 67668D4C2404 lea ecx,[dword esp+0x4]
00000016 6683E4F0 and esp,byte -0x10
0000001A 6766FF71FC push dword [ecx-0x4]
0000001F 6651 push ecx
00000021 6683EC08 sub esp,byte +0x8
00000025 6766C70424090000 mov dword [dword esp],0x9
-00
0000002E E83F00 call word 0x70
00000031 6683F809 cmp eax,byte +0x9
00000035 7503 jnz 0x3a
00000037 E82600 call word 0x60
0000003A 89F6 mov si,si
0000003C 8DBD0000 lea di,[di+0x0]
00000040 E81D00 call word 0x60
00000043 E83A00 call word 0x80
00000046 66B800000000 mov eax,0x0
0000004C 6683C408 add esp,byte +0x8
00000050 6659 pop ecx
00000052 67668D61FC lea esp,[ecx-0x4]
00000057 C3 ret
00000058 0000 add [bx+si],al
0000005A 0000 add [bx+si],al
0000005C 0000 add [bx+si],al
0000005E 0000 add [bx+si],al
00000060 B400 mov ah,0x0
00000062 CD16 int 0x16
00000064 C3 ret
00000065 0000 add [bx+si],al
00000067 0000 add [bx+si],al
00000069 0000 add [bx+si],al
0000006B 0000 add [bx+si],al
0000006D 0000 add [bx+si],al
0000006F 00 db 0x00
00000070 55 push bp
00000071 89E5 mov bp,sp
00000073 8A4608 mov al,[bp+0x8]
00000076 0430 add al,0x30
00000078 B40E mov ah,0xe
0000007A CD10 int 0x10
0000007C B400 mov ah,0x0
0000007E 5D pop bp
0000007F C3 ret
00000080 B44C mov ah,0x4c
00000082 CD21 int 0x21
00000084 C3 ret
...padded to 4096
Your "paramter:" converts the number 9 to the character '9'. When this returns to the C code, this checks for 9, the number, not the character. This isn't going to work.
Your "stop:" uses int 21h. This isn't going to work.
The "phys" in your "link.ld" looks a little high to me. I doubt if this is going to work (although I doubt if it makes any difference at this point). I think you'd need to enable a20, and alter the "limit" to make this actually work at "some_segment:0x100000". But I don't know how/where you're actually loading this code, and what you've done first, so I could be wrong about that. You keep saying that you're going to use Protected Mode, but you haven't actually switched to pmode yet, right?
I don't know if this is any help or not.
Best,
Frank