along with simavr. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SIM_CORE_H_
-#define SIM_CORE_H_
+#ifndef __SIM_CORE_H__
+#define __SIM_CORE_H__
#ifdef __cplusplus
extern "C" {
/*
* Instruction decoder, run ONE instruction
*/
-uint16_t avr_run_one(avr_t * avr);
+avr_flashaddr_t avr_run_one(avr_t * avr);
/*
* These are for internal access to the stack (for interrupts)
/*
* DEBUG bits follow
- * These will diseapear when gdb arrives
+ * These will disappear when gdb arrives
*/
void avr_dump_state(avr_t * avr);
#endif
+/**
+ * Reconstructs the SREG value from avr->sreg into dst.
+ */
+#define READ_SREG_INTO(avr, dst) { \
+ dst = 0; \
+ for (int i = 0; i < 8; i++) \
+ if (avr->sreg[i] > 1) { \
+ printf("** Invalid SREG!!\n"); \
+ } else if (avr->sreg[i]) \
+ dst |= (1 << i); \
+ }
+
+/**
+ * Splits the SREG value from src into the avr->sreg array.
+ */
+#define SET_SREG_FROM(avr, src) { \
+ for (int i = 0; i < 8; i++) \
+ avr->sreg[i] = (src & (1 << i)) != 0; \
+ }
+
#ifdef __cplusplus
};
#endif
-#endif /* SIM_CORE_H_ */
+#endif /*__SIM_CORE_H__*/