#ifndef ARMY_H #define ARMY_H /* * constants * (copied from 'breakcode.h') */ /* program termination */ #define BREAK_PROGRAM_EXIT 0x1 /* read data */ #define BREAK_READ_INT 0x11 #define BREAK_READ_CHAR 0x12 #define BREAK_READ_STRING 0x13 /* print data */ #define BREAK_PRINT_INT 0x21 #define BREAK_PRINT_CHAR 0x22 #define BREAK_PRINT_STRING 0x23 /* * macros */ /* program termination */ #define EXIT(v) \ asm volatile ("swi %0" : : "i" (BREAK_PROGRAM_EXIT)) /* read data */ #define READ_INT(v) \ asm volatile ("swi %1; mov %1,r0" : "=r" (v) : "i" (BREAK_READ_INT) : "0") #define READ_CHAR(v) \ asm volatile ("swi %1; mov %1,r0" : "=r" (v) : "i" (BREAK_READ_CHAR) : "0") #define READ_STRING(v) \ asm volatile ("mov r0,%1; swi %0" : : "i" (BREAK_READ_STRING), "r" (v) : "0") /* print data */ #define PRINT_INT(v) \ asm volatile ("mov r0,%1; swi %0" : : "i" (BREAK_PRINT_INT), "r" (v) : "0") #define PRINT_CHAR(v) \ asm volatile ("mov r0,%1; swi %0" : : "i" (BREAK_PRINT_CHAR), "r" (v) : "0") #define PRINT_STRING(v) \ asm volatile ("mov r0,%1; swi %0" : : "i" (BREAK_PRINT_STRING), "r" (v) : "0") #endif /* ARMY_H */