I am trying to compile an Assembly file to object file. This assembly file calls a c function. But i encounter this error: binary output format does not support external references
I call the c function in line 17 of the assembly file
I try to compile it with this command:
cpu/interrupt.o: cpu/interrupt.asm
nasm $< -f bin -o $@
how can i fix this problem
[extern isr_handler]
; Common ISR code
isr_common_stub:
; 1. Save CPU state
pusha ; Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax
mov ax, ds ; Lower 16-bits of eax = ds.
push eax ; save the data segment descriptor
mov ax, 0x10 ; kernel data segment descriptor
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
; 2. Call C handler
call isr_handler
; 3. Restore state
pop eax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
popa
add esp, 8 ; Cleans up the pushed error code and pushed ISR number
sti
iret ; pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP
; We don't get information about which interrupt was caller
; when the handler is run, so we will need to have a different handler
; for every interrupt.
; Furthermore, some interrupts push an error code onto the stack but others
; don't, so we will push a dummy error code for those which don't, so that
; we have a consistent stack for all of them.
; First make the ISRs global
global isr0
global isr1
global isr2
global isr3
global isr4
global isr5
global isr6
global isr7
global isr8
global isr9
global isr10
global isr11
global isr12
global isr13
global isr14
global isr15
global isr16
global isr17
global isr18
global isr19
global isr20
global isr21
global isr22
global isr23
global isr24
global isr25
global isr26
global isr27
global isr28
global isr29
global isr30
global isr31
.oobject file, why do you use-f bin? Use-f elfor whatever is appropriate for your format. - Jesterprint('X', 1);was the wrong offset. It should have been 2 instead of 1. for the second character on the display since each cell on the text mode screen is 2 bytes. A fix would have been to usevolatile unsigned short *vga = (unsigned short *) 0xb8000;vga[offset] = (0x0f<<8) | c;in your print function. This would treat each cell on the screen as a 2 byte entity (unsigned short is 16-bits on your compiler). That wayprint('X', 1);prints to the second cell on the screen. - Michael Petch