Interesting, I can't imagine how that's happening because IX is pushed to my save stack at the beginning of the function and restored at the end.
The calling origin from the code below is...
7920 2887 cd0000 call ____sdcc_store_dehl_bcix
Which calls (this is the portion of code that you traced to)
____sdcc_store_dehl_bcix = $FEBA ; addr, public, , ____sdcc_store_dehl_bcix, code_l_sdcc, l/sdcc/____sdcc_store_dehl_bcix.asm:7
But at the time of sdcc_store_dehl_bcix mangling IX, it's already been saved and will be restored at the end of the function. Something with my observation and tracing are wrong if you think that's where the IX mangle occurs.
These memory addresses need to have 0xC500 added to them
Code: Select all
7876 ; ---------------------------------
7877 ; Function doRead
7878 ; ---------------------------------
7879 _doRead:
7880 283b f3 di
7881 283c e5 push hl
7882 283d 21000039 ld hl, sp
7883 2841 31ffff ld sp, 0xffff
7884 2844 e5 push hl
7885 2845 c5 push bc
7886 2846 d5 push de
7887 2847 f5 push af
7888 2848 fde5 push iy
7889 284a dde5 push ix <--------------------------- IX SAVED
7890 284c 3e26 ld a,0x26
7891 284e d3a1 out (_IO_VDPLATCH), a
7892 2850 3e48 ld a,0x48
7893 2852 d3a1 out (_IO_VDPLATCH), a
7894 2854 3eb3 ld a,0xb3
7895 2856 d3a0 out (_IO_VDPDATA), a
7896 2858 3a0400 ld a,(_CPM_USER_DRIVE)
7897 285b e60f and a,0x0f
7898 285d c6a2 add a,0xa2
7899 285f d3a0 out (_IO_VDPDATA), a
7900 2861 3e0f ld a,0x0f
7901 2863 d300 out (_IO_CONTROL), a
7902 2865 2114ff ld hl,__TEMP
7903 2868 3600 ld (hl),0x00
7904 286a 218e07 ld hl,__FILEID
7905 286d 7e ld a, (hl)
7906 286e 3c inc a
7907 286f 23 inc hl
7908 2870 b6 or a, (hl)
7909 2871 2864 jr Z,l_doRead_00104
7910 2873 2a1bff ld hl, (__TRACK)
7911 2876 110000 ld de,0x0000
7912 2879 53 ld d, e
7913 287a 5c ld e, h
7914 287b 65 ld h, l
7915 287c 2e00 ld l,0x00
7916 287e cb24 sla h
7917 2880 cb13 rl e
7918 2882 cb12 rl d
7919 2884 01ffff ld bc,-1
7920 2887 cd0000 call ____sdcc_store_dehl_bcix <---------- CALLING ORIGIN
7921 288a 2a1dff ld hl, (__SECTOR)
7922 288d 110000 ld de,0x0000
7923 2890 0607 ld b,0x07
7924 l_doRead_00123:
7925 2892 29 add hl, hl
7926 2893 cb13 rl e
7927 2895 cb12 rl d
7928 2897 10f9 djnz l_doRead_00123
7929 2899 dd7efc ld a,(ix-4)
7930 289c 85 add a, l
7931 289d 4f ld c, a
7932 289e dd7efd ld a,(ix-3)
7933 28a1 8c adc a, h
7934 28a2 47 ld b, a
7935 28a3 dd7efe ld a,(ix-2)
7936 28a6 8b adc a, e
7937 28a7 5f ld e, a
7938 28a8 dd7eff ld a,(ix-1)
7939 28ab 8a adc a, d
7940 28ac 57 ld d, a
7941 28ad 2a19ff ld hl, (__DMA)
7942 28b0 e5 push hl
7943 28b1 3a8e07 ld a,(__FILEID)
7944 28b4 218000 ld hl,0x0080
7945 28b7 e3 ex (sp), hl
7946 28b8 d5 push de
7947 28b9 c5 push bc
7948 28ba 110000 ld de,0x0000
7949 28bd d5 push de
7950 28be e5 push hl
7951 28bf f5 push af
7952 28c0 33 inc sp
7953 28c1 cdc320 call _rn_fileHandleRead
7954 28c4 f1 pop af
7955 28c5 f1 pop af
7956 28c6 f1 pop af
7957 28c7 f1 pop af
7958 28c8 f1 pop af
7959 28c9 33 inc sp
7960 28ca 7d ld a, l
7961 28cb d680 sub a,0x80
7962 28cd b4 or a, h
7963 28ce 280c jr Z,l_doRead_00105
7964 28d0 2114ff ld hl,__TEMP
7965 28d3 3601 ld (hl),0x01
7966 28d5 1805 jr l_doRead_00105
7967 l_doRead_00104:
7968 28d7 2114ff ld hl,__TEMP
7969 28da 36ff ld (hl),0xff
7970 l_doRead_00105:
7971 28dc 3e26 ld a,0x26
7972 28de d3a1 out (_IO_VDPLATCH), a
7973 28e0 3e48 ld a,0x48
7974 28e2 d3a1 out (_IO_VDPLATCH), a
7975 28e4 010000 ld bc,__vdp_textBuffer+0
7976 28e7 218007 ld hl,__vdp_viewPortStart
7977 28ea 5e ld e, (hl)
7978 28eb 1600 ld d,0x00
7979 28ed 212600 ld hl,0x0026
7980 28f0 19 add hl, de
7981 28f1 09 add hl, bc
7982 28f2 7e ld a, (hl)
7983 28f3 d3a0 out (_IO_VDPDATA), a
7984 28f5 010000 ld bc,__vdp_textBuffer+0
7985 28f8 218007 ld hl,__vdp_viewPortStart
7986 28fb 5e ld e, (hl)
7987 28fc 1600 ld d,0x00
7988 28fe 212700 ld hl,0x0027
7989 2901 19 add hl, de
7990 2902 09 add hl, bc
7991 2903 7e ld a, (hl)
7992 2904 d3a0 out (_IO_VDPDATA), a
7993 2906 3e07 ld a,0x07
7994 2908 d300 out (_IO_CONTROL), a
7995 290a 3e0e ld a, 0x0e
7996 290c d341 out (_IO_AYLATCH), a
7997 290e 3e20 ld a, 0x20
7998 2910 d340 out (_IO_AYDATA), a
7999 2912 dde1 pop ix <----------------- IX RESTORED
8000 2914 fde1 pop iy
8001 2916 f1 pop af
8002 2917 d1 pop de
8003 2918 c1 pop bc
8004 2919 e1 pop hl
8005 291a f9 ld sp, hl
8006 291b e1 pop hl
8007 291c 3a14ff ld a, (__TEMP)
8008 291f fb ei
8009 2920 c9 ret