本文整理汇总了C++中SFR_W函数的典型用法代码示例。如果您正苦于以下问题:C++ SFR_W函数的具体用法?C++ SFR_W怎么用?C++ SFR_W使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SFR_W函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_a_r
/*ADD A, R0 to R7 1: 0010 1rrr */
INLINE void add_a_r(int r)
{
UINT8 data = R_R(r); /*Grab data from R0 - R7 */
UINT8 result = R_ACC + data; /*Add data to accumulator */
DO_ADD_FLAGS(R_ACC,data,0); /*Set Flags */
SFR_W(ACC,result); /*Store 8 bit result of addtion in ACC */
}
示例2: add_a_ir
/*ADD A, @R0/@R1 1: 0010 011i */
INLINE void add_a_ir(int r)
{
UINT8 data = IRAM_IR(R_R(r)); /*Grab data from memory pointed to by R0 or R1 */
UINT8 result = R_ACC + data; /*Add data to accumulator */
DO_ADD_FLAGS(R_ACC,data,0); /*Set Flags */
SFR_W(ACC,result); /*Store 8 bit result of addtion in ACC */
}
示例3: xch_a_ir
/*XCH A, @RO/@R1 1: 1100 011i */
INLINE void xch_a_ir(int r)
{
UINT8 data = IRAM_IR(R_R(r)); /*Grab data pointed to by R0 or R1 */
UINT8 oldACC = R_ACC; /*Hold value of ACC */
SFR_W(ACC,data); /*Sets ACC to data */
IRAM_W(R_R(r),oldACC); /*Sets data address to old value of ACC */
}
示例4: SFR_R
/*******************************************************************************************
NOTE: All registers are accessed directly, instead of using the SFR_R() function for speed
Direct register access is availabe from the R_(register name) macros.. ex: R_ACC for the ACC
with the exception of the PC
********************************************************************************************/
//ACALL code addr /* 1: aaa1 0001 */
INLINE void acall(void)
{
UINT8 op = ROP(PC-1); //Grab the opcode for ACALL
UINT8 addr = ROP_ARG(PC++); //Grab code address byte
PUSH_PC //Save PC to the stack
//Thanks Gerrit for help with this! :)
PC = (PC & 0xf800) | ((op & 0xe0) << 3) | addr;
}
//ADD A, #data /* 1: 0010 0100 */
INLINE void add_a_byte(void)
{
UINT8 data = ROP_ARG(PC++); //Grab data
UINT8 result = R_ACC + data; //Add data to accumulator
DO_ADD_FLAGS(R_ACC,data,0) //Set Flags
SFR_W(ACC,result); //Store 8 bit result of addtion in ACC
}
//ADD A, data addr /* 1: 0010 0101 */
INLINE void add_a_mem(void)
{
UINT8 addr = ROP_ARG(PC++); //Grab data address
UINT8 data = IRAM_R(addr); //Grab data from data address
UINT8 result = R_ACC + data; //Add data to accumulator
DO_ADD_FLAGS(R_ACC,data,0); //Set Flags
SFR_W(ACC,result); //Store 8 bit result of addtion in ACC
}
//ADD A, @R0/@R1 /* 1: 0010 011i */
INLINE void add_a_ir(int r)
{
UINT8 data = IRAM_IR(R_R(r)); //Grab data from memory pointed to by R0 or R1
UINT8 result = R_ACC + data; //Add data to accumulator
DO_ADD_FLAGS(R_ACC,data,0); //Set Flags
SFR_W(ACC,result); //Store 8 bit result of addtion in ACC
}
//ADD A, R0 to R7 /* 1: 0010 1rrr */
INLINE void add_a_r(int r)
{
UINT8 data = R_R(r); //Grab data from R0 - R7
UINT8 result = R_ACC + data; //Add data to accumulator
DO_ADD_FLAGS(R_ACC,data,0); //Set Flags
SFR_W(ACC,result); //Store 8 bit result of addtion in ACC
}
//ADDC A, #data /* 1: 0011 0100 */
INLINE void addc_a_byte(void)
{
UINT8 data = ROP_ARG(PC++); //Grab data
UINT8 result = R_ACC + data + GET_CY; //Add data + carry flag to accumulator
DO_ADD_FLAGS(R_ACC,data,GET_CY); //Set Flags
SFR_W(ACC,result); //Store 8 bit result of addtion in ACC
}
//ADDC A, data addr /* 1: 0011 0101 */
INLINE void addc_a_mem(void)
{
UINT8 addr = ROP_ARG(PC++); //Grab data address
UINT8 data = IRAM_R(addr); //Grab data from data address
UINT8 result = R_ACC + data + GET_CY; //Add data + carry flag to accumulator
DO_ADD_FLAGS(R_ACC,data,GET_CY); //Set Flags
SFR_W(ACC,result); //Store 8 bit result of addtion in ACC
}
//ADDC A, @R0/@R1 /* 1: 0011 011i */
INLINE void addc_a_ir(int r)
{
UINT8 data = IRAM_IR(R_R(r)); //Grab data from memory pointed to by R0 or R1
UINT8 result = R_ACC + data + GET_CY; //Add data + carry flag to accumulator
DO_ADD_FLAGS(R_ACC,data,GET_CY); //Set Flags
SFR_W(ACC,result); //Store 8 bit result of addtion in ACC
}
示例5: add_a_byte
/*ADD A, #data 1: 0010 0100 */
INLINE void add_a_byte(void)
{
UINT8 data = ROP_ARG(PC++); /*Grab data */
UINT8 result = R_ACC + data; /*Add data to accumulator */
DO_ADD_FLAGS(R_ACC,data,0) /*Set Flags */
SFR_W(ACC,result); /*Store 8 bit result of addtion in ACC */
}
示例6: SFR_W
/*From several sources, since none said the same thing:
The decimal adjust instruction is associated with the use of the ADD and ADDC instructions.
The eight-bit value in the accumulator is adjusted to form two BCD digits of four bits each.
If the accumulator contents bits 0-3 are greater than 9, OR the AC flag is set, then six is added to
produce a proper BCD digit.
If the carry is set, OR the four high bits 4-7 exceed nine, six is added to the value of these bits.
The carry flag will be set if the result is > 0x99, but not cleared otherwise */
UINT16 new_acc = R_ACC & 0xff;
if(GET_AC || (new_acc & 0x0f) > 0x09)
new_acc += 0x06;
if(GET_CY || ((new_acc & 0xf0) > 0x90) || (new_acc & ~0xff))
new_acc += 0x60;
SFR_W(ACC,new_acc&0xff);
if(new_acc & ~0xff)
SET_CY(1);
}
//DEC A /* 1: 0001 0100 */
INLINE void dec_a(void)
{
SFR_W(ACC,R_ACC-1);
}
//DEC data addr /* 1: 0001 0101 */
INLINE void dec_mem(void)
{
UINT8 addr = ROP_ARG(PC++); //Grab data address
UINT8 data = IRAM_R(addr);
IRAM_W(addr,data-1);
}
//DEC @R0/@R1 /* 1: 0001 011i */
INLINE void dec_ir(int r)
{
UINT8 data = IRAM_IR(R_R(r));
IRAM_W(R_R(r),data-1);
}
//DEC R0 to R7 /* 1: 0001 1rrr */
INLINE void dec_r(int r)
{
R_R(r) = R_R(r) - 1;
}
//DIV AB /* 1: 1000 0100 */
INLINE void div_ab(void)
{
if( R_B == 0 ) {
//Overflow flag is set!
SET_OV(1);
//Really the values are undefined according to the manual, but we'll just leave them as is..
//SFR_W(ACC,0xff);
//SFR_W(B,0xff);
}
else {
int a = (int)R_ACC/R_B;
int b = (int)R_ACC%R_B;
//A gets quotient byte, B gets remainder byte
SFR_W(ACC,a);
SFR_W(B, b);
//Overflow flag is cleared
SET_OV(0);
}
//Carry Flag is always cleared
SET_CY(0);
}
//DJNZ data addr, code addr /* 1: 1101 0101 */
INLINE void djnz_mem(void)
{
UINT8 addr = ROP_ARG(PC++); //Grab data address
INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address
IRAM_W(addr,IRAM_R(addr) - 1); //Decrement value contained at data address
if(IRAM_R(addr) != 0) //Branch if contents of data address is not 0
PC = PC + rel_addr;
}
//DJNZ R0 to R7,code addr /* 1: 1101 1rrr */
INLINE void djnz_r(int r)
{
INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address
R_R(r) = R_R(r) - 1; //Decrement value
if(R_R(r) != 0) //Branch if contents of R0 - R7 is not 0
PC = PC + rel_addr;
}
//INC A /* 1: 0000 0100 */
INLINE void inc_a(void)
{
SFR_W(ACC,R_ACC+1);
}
//INC data addr /* 1: 0000 0101 */
INLINE void inc_mem(void)
{
UINT8 addr = ROP_ARG(PC++); //Grab data address
UINT8 data = IRAM_R(addr);
IRAM_W(addr,data+1);
}
//.........这里部分代码省略.........
示例7: movx_a_idptr
//MOVX A,@DPTR /* 1: 1110 0000 */
//(Move External Ram 16 bit address to A)
INLINE void movx_a_idptr(void)
{
// UINT8 byte = DATAMEM_R(R_DPTR); //Grab 1 byte from External DATA memory pointed to by dptr
UINT32 addr = ERAM_ADDR(R_DPTR,0xFFFF);
UINT8 byte = DATAMEM_R(addr); //Grab 1 byte from External DATA memory pointed to by dptr
SFR_W(ACC,byte); //Store to ACC
}
示例8: xch_a_r
/*XCH A, RO to R7 1: 1100 1rrr */
INLINE void xch_a_r(int r)
{
UINT8 data = R_R(r); /*Grab data from R0-R7 */
UINT8 oldACC = R_ACC; /*Hold value of ACC */
SFR_W(ACC,data); /*Sets ACC to data */
R_R(r) = oldACC; /*Sets data address to old value of ACC */
}
示例9: swap_a
/*SWAP A 1: 1100 0100 */
INLINE void swap_a(void)
{
UINT8 a_nib_lo, a_nib_hi;
a_nib_hi = (R_ACC & 0x0f) << 4; /*Grab lo byte of ACC and move to hi */
a_nib_lo = (R_ACC & 0xf0) >> 4; /*Grab hi byte of ACC and move to lo */
SFR_W(ACC, a_nib_hi | a_nib_lo);
}
示例10: subb_a_r
/*SUBB A, R0 to R7 1: 1001 1rrr */
INLINE void subb_a_r(int r)
{
UINT8 data = R_R(r); /*Grab data from R0 - R7 */
UINT8 result = R_ACC - data - GET_CY; /*Subtract data & carry flag from accumulator */
DO_SUB_FLAGS(R_ACC,data,GET_CY); /*Set Flags */
SFR_W(ACC,result); /*Store 8 bit result of addtion in ACC */
}
示例11: subb_a_ir
/*SUBB A, @R0/@R1 1: 1001 011i */
INLINE void subb_a_ir(int r)
{
UINT8 data = IRAM_IR(R_R(r)); /*Grab data from memory pointed to by R0 or R1 */
UINT8 result = R_ACC - data - GET_CY; /*Subtract data & carry flag from accumulator */
DO_SUB_FLAGS(R_ACC,data,GET_CY); /*Set Flags */
SFR_W(ACC,result); /*Store 8 bit result of addtion in ACC */
}
示例12: add_a_mem
/*ADD A, data addr 1: 0010 0101 */
INLINE void add_a_mem(void)
{
UINT8 addr = ROP_ARG(PC++); /*Grab data address */
UINT8 data = IRAM_R(addr); /*Grab data from data address */
UINT8 result = R_ACC + data; /*Add data to accumulator */
DO_ADD_FLAGS(R_ACC,data,0); /*Set Flags */
SFR_W(ACC,result); /*Store 8 bit result of addtion in ACC */
}
示例13: xch_a_mem
/*XCH A, data addr 1: 1100 0101 */
INLINE void xch_a_mem(void)
{
UINT8 addr = ROP_ARG(PC++); /*Grab data address */
UINT8 data = IRAM_R(addr); /*Grab data */
UINT8 oldACC = R_ACC; /*Hold value of ACC */
SFR_W(ACC,data); /*Sets ACC to data */
IRAM_W(addr,oldACC); /*Sets data address to old value of ACC */
}
示例14: subb_a_byte
/*SUBB A, #data 1: 1001 0100 */
INLINE void subb_a_byte(void)
{
UINT8 data = ROP_ARG(PC++); /*Grab data */
UINT8 result = R_ACC - data - GET_CY; /*Subtract data & carry flag from accumulator */
DO_SUB_FLAGS(R_ACC,data,GET_CY); /*Set Flags */
SFR_W(ACC,result); /*Store 8 bit result of addtion in ACC */
}