Reputation: 11
Are these declarations correct?
#include <stdint.h>
#include <stdbool.h>
#include <reg_mg82f6d64.h>
uint8_t data *R0 = 0x00;
uint8_t data *R1 = 0x01;
uint8_t data *R2 = 0x02;
uint8_t data *R3 = 0x03;
uint8_t data *R6 = 0x06;
uint8_t data *R7 = 0x07;
uint16_t code *DPTRc = 0x0000;
uint16_t xdata *DPTRx = 0x0000; // pdata
uint8_t data *DPTRd = 0x00;
uint8_t idata *STACK[10] = {(uint8_t idata *)0x81};
In here I am trying to use them exact same on 8051 assembler with C features but sometime it goes wrong, for example i can not use SP register for PUSH, POP like on assembly.
void wrb(void) // (write read byte)
{
*STACK[1] = ACC; // i want to do PUSH(ACC);
while ((SPSTAT & 0x80) != 0);
ACC = STACK[1]; // // i want to do POP(ACC);
SPDAT = ACC;
while ((SPSTAT & 0x80) == 0);
ACC = SPDAT;
}
void PUSH(void)
{
SP++;
*(uint8_t idata *)SP = ACC;
}
void POP(void)
{
ACC = *(uint8_t idata *)SP;
SP--;
}
So when MCU has Stack Pointer why would i declare another array and use more memory size which is a bad development!
Upvotes: -1
Views: 67