- return res;
-}
-
-/*
- * Processing write operation to IRAM
- *
- * It starts serial transmition if address is in SFR and it is
- * SBUF. Effect on IE is also checked.
- */
-
-void
-t_uc390::proc_write(uchar *addr)
-{
- if (addr == &((sfr->umem8)[SBUF]))
- {
- s_out= sfr->get(SBUF);
- s_sending= DD_TRUE;
- s_tr_bit = 0;
- s_tr_tick= 0;
- s_tr_t1 = 0;
- }
- else if (addr == &((sfr->umem8)[IE]))
- was_reti= DD_TRUE;
- else if (addr == &((sfr->umem8)[DPS]))
- {
- *addr &= 0xe5;
- *addr |= 0x04;
- }
- else if (addr == &((sfr->umem8)[EXIF]))
- {
- }
- else if (addr == &((sfr->umem8)[P4CNT]))
- {
- ;
- }
- else if (addr == &((sfr->umem8)[ACON]))
- {
- *addr |= 0xf8;
- /* lockout: IDM1:IDM0 and SA can't be set at the same time */
- if (((sfr->umem8)[MCON] & 0xc0) == 0xc0) /* IDM1 and IDM0 set? */
- *addr &= ~0x04; /* lockout SA */
- }
- else if (addr == &((sfr->umem8)[P5CNT]))
- {
- ;
- }
- else if (addr == &((sfr->umem8)[C0C]))
- {
- ;
- }
- else if (addr == &((sfr->umem8)[PMR]))
- {
- *addr |= 0x03;
- // todo: check previous state
- if ((*addr & 0xd0) == 0x90) /* CD1:CD0 set to 10, CTM set */
- {
- ctm_ticks = ticks->ticks;
- (sfr->umem8)[EXIF] &= ~0x08; /* clear CKRDY */
- }
- else
- ctm_ticks = 0;
- }
- else if (addr == &((sfr->umem8)[MCON]))
- {
- *addr |= 0x10;
- /* lockout: IDM1:IDM0 and SA can't be set at the same time */
- if (((sfr->umem8)[ACON] & 0x04) == 0x04) /* SA set? */
- *addr &= ~0xc0; /* lockout IDM1:IDM0 */
- }
- else if (addr == &((sfr->umem8)[TA]))
- {
- if (*addr == 0x55)
- {
- timed_access_ticks = ticks->ticks;
- timed_access_state = 1;
- }
- else if (*addr == 0xaa &&
- timed_access_state == 1 &&
- timed_access_ticks == ticks->ticks + 1)
- {
- timed_access_ticks = ticks->ticks;
- timed_access_state = 2;
- }
- else
- timed_access_state = 0;
- }
- else if (addr == &((sfr->umem8)[T2MOD]))
- *addr |= 0xe0;
- else if (addr == &((sfr->umem8)[COR]))
- {
- ;
- }
- else if (addr == &((sfr->umem8)[WDCON]))
- {
- ;
- }
- else if (addr == &((sfr->umem8)[C1C]))
- {
- ;
- }
- else if (addr == &((sfr->umem8)[MCNT1]))
- *addr |= 0x0f;
-}
-
-
-/*
- * Reading IRAM or SFR, but if address points to a port, it reads
- * port pins instead of port latches
- */
-
-uchar
-t_uc390::read(uchar *addr)
-{
- //if (addr == &(MEM(MEM_SFR)[P1]))
- if (addr == &(sfr->umem8[P1]))
- return get_mem (MEM_SFR, P1) & port_pins[1];
- //if (addr == &(MEM(MEM_SFR)[P2]))
- else if (addr == &(sfr->umem8[P2]))
- return get_mem (MEM_SFR, P2) & port_pins[2];
- //if (addr == &(MEM(MEM_SFR)[P3]))
- else if (addr == &(sfr->umem8[P3]))
- return get_mem (MEM_SFR, P3) & port_pins[3];
- //if (addr == &(MEM(MEM_SFR)[P4]))
- else if (addr == &(sfr->umem8[P4]))
- return get_mem (MEM_SFR, P4) & port_pins[4];
- //if (addr == &(MEM(MEM_SFR)[P5]))
- else if (addr == &(sfr->umem8[P5]))
- return get_mem (MEM_SFR, P5) & port_pins[5];
- else if (addr == &(sfr->umem8[EXIF]))
- if (ctm_ticks &&
- ticks->ticks >= ctm_ticks + 65535)
- {
- *addr |= 0x08; /* set CKRDY */
- ctm_ticks = 0;
- }
- return *addr;