misc: Consistent include guards in headers
[simavr] / simavr / sim / sim_core.h
index 22f781f..6466b80 100644 (file)
@@ -19,8 +19,8 @@
        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" {
@@ -29,7 +29,7 @@ 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)
@@ -47,7 +47,7 @@ const char * avr_regname(uint8_t reg);
 
 /* 
  * DEBUG bits follow 
- * These will diseapear when gdb arrives
+ * These will disappear when gdb arrives
  */
 void avr_dump_state(avr_t * avr);
 
@@ -95,8 +95,28 @@ 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__*/