X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fmemory.c;h=c5b2acf51c7384776af89fe6b60ad346e27bebcd;hb=8d9b71ab3848729da1cf90a38a599be0b08cbb5c;hp=44a2118f596d48d52e09b65f0ef3f986dfb09a7c;hpb=47f57bc5800c41963db47b2f2dddf8f612ddc295;p=emu8051.git diff --git a/src/memory.c b/src/memory.c index 44a2118..c5b2acf 100644 --- a/src/memory.c +++ b/src/memory.c @@ -70,6 +70,8 @@ memory_init(void) log_err("%s", strerror(errno)); exit(1); } + + memset(m->buf, 0x00, m->size); } } @@ -183,44 +185,16 @@ stack_pop16(void) return value; } -void -psw_write_cy(int cy) -{ - u_int8_t psw = memory_read8(INT_MEM_ID, _PSW_); - - if (cy) - psw |= 0x80; /* Set */ - else - psw &= ~0x80; /* Clear */ - - memory_write8(INT_MEM_ID, _PSW_, psw); /* Save updated value */ -} - -void -psw_set_cy(void) -{ - u_int8_t psw = memory_read8(INT_MEM_ID, _PSW_); - - psw |= 0x80; - - memory_write8(INT_MEM_ID, _PSW_, psw); /* Save updated value */ -} - -void -psw_clr_cy(void) +/* Read a 16-bit address from PGM memory, starting at offset */ +uint16_t +pgm_read_addr16(uint16_t base) { - u_int8_t psw = memory_read8(INT_MEM_ID, _PSW_); - - psw &= ~0x80; + uint16_t addr; - memory_write8(INT_MEM_ID, _PSW_, psw); /* Save updated value */ -} + addr = memory_read8(PGM_MEM_ID, base) << 8; /* MSB */ + addr |= memory_read8(PGM_MEM_ID, base + 1); /* LSB */ -/* Returns 0 or 1 */ -int -psw_read_cy(void) -{ - return memory_read8(INT_MEM_ID, _PSW_) >> 7; + return addr; } /* Dump memory */