It suggests two critical steps:
(1) Having CRT_ORG_VECTOR_TABLE = -0x100 ( a special flag to put the interrupt vector table at 0x100 in the CRT Page 0)
(2) Including in the compile a section for the interrupt vectors. I did an interrupt.asm file as suggested.
For a sample simple c program, I am using this for test.c:
Code: Select all
#include <stdio.h>
int main()
{
int q=0;
for (int i=0; i<100; i++)
{
q = q +i;
}
return 0;
}
Code: Select all
section interrupt_vectors
EXTERN l_ret
;defs 0x100 - ASMPC
;defc z180_int_int1 = __crt_org_vector_table + 0x00
defw l_ret
;defc z180_int_int2 = __crt_org_vector_table + 0x02
defw l_ret
;defc z180_int_prt0 = __crt_org_vector_table + 0x04
defw l_ret
;defc z180_int_prt1 = __crt_org_vector_table + 0x06
defw l_ret
;defc z180_int_dma0 = __crt_org_vector_table + 0x08
defw l_ret
;defc z180_int_dma1 = __crt_org_vector_table + 0x0A
defw l_ret
;defc z180_int_csio = __crt_org_vector_table + 0x0C
defw l_ret
;defc z180_int_asci0 = __crt_org_vector_table + 0x0E
defw l_ret
;defc z180_int_asci1 = __crt_org_vector_table + 0x10
defw l_ret
defb $AA,$BB,$CC,$DD
defb $AA,$BB,$CC,$DD
defb $AA,$BB,$CC,$DD
defb $AA,$BB,$CC,$DD
I compiled these two files with:
Code: Select all
zcc +z180 -clib=new -startup=1 test.c interrupt.asm -create-app -v -pragma-define:CRT_ORG_VECTOR_TABLE=-0x100 -o testrom -pragma-define:CRT_INTERRUPT_MODE=2 -pragma-define:CRT_IO_VECTOR_BASE=0 --list -v
If I look in the crt_memory_model_z180.inc file:
Code: Select all
SECTION CODE
org __crt_org_code
IF (__crt_org_vector_table = -0x80) || (__crt_org_vector_table = -0x100)
section interrupt_vectors
ENDIF
section code_crt_start
.......
I looked in the page zero ctr itself (crt_page_zero_z180.inc) , and it has
Code: Select all
IF (__crt_org_vector_table = -0x0100)
; place vector table at address 0x0100
; current address = 0x0069 or 0x0068
; that is 151 bytes to pad, make it count!
Code: Select all
; address = 0x100
defs 0x100 - ASMPC
section code_crt_start
I did quickly try using the +embedded target (using the old c library and targeting the Z80), and it seemed to do the right thing. (the vector table was at 0x100).
I am sure I am missing something here! Anyone have any ideas what I'm missing?
Cheers!
Jeff Sponaugle