But it was about 1 variable.
There are 2 variables, for example:
Code: Select all
register unsigned int *Address = 0x0f89;
unsigned int short BitNum = 3;
Or it is impossible._asm { BSF Address +0, BitNum }
Code: Select all
register unsigned int *Address = 0x0f89;
unsigned int short BitNum = 3;
Or it is impossible._asm { BSF Address +0, BitNum }
Code: Select all
BSF Address +0, BitNum
Code: Select all
// PIC18F2550 on StartUSB board with 8MHz 2-pin crystal fitted for 48MHz clock
// build the project and run the debugger and step-over to get cycles count (delta)
// you are using StartUSB board, so you will need to run software simulator debugger, not hardware debugger
// simple LED flash program for StartUSB for PIC
// PIC18F2550 with 8MHz 2-pin crystal configured to give 48MHz CPU clock
// use with HID bootloader
// LEDs on RA1 and RB1
// both LEDs should blink half second off, half second on
// Board defines
#define LED_A LATA1_bit
#define LED_B LATB1_bit
// global variables
register unsigned int *Address = 0x0f89;
// defines
#define BitNum 3
void main() {
ADCON1 = 0x0f; // disable analogue
LATA = 0; // all outputs low
LATB = 0; // all outputs low
LATC = 0; // all outputs low
TRISA = 0; // all output
TRISB = 0; // all output
TRISC = 0; // all output
CMCON = 0; // disable comparators
LED_A = 1; // LED on
LED_B = 1; // both LEDs on indicates restart
Delay_ms(1000); // both LEDs on for 1 second - only at restart
LED_A = 0; // LED off
LED_B = 0; // both LEDs off
asm{
BSF Address + 0, BitNum
}
while(1);
}
Code: Select all
typedef struct PortsStruct {
unsigned char PortNum;
unsigned int* DLByte;
unsigned int* PLByte;
unsigned short int DLBit;
unsigned short int PLBit;
} PortsStruct, *pPortsStruct;
const struct PortsStruct Ports[9] = {
{1, &LATA, &LATA, 0, 1}, // Port1[0] - LATA RA0 & RA1
{2, &LATA, &LATA, 2, 3}, // Port2[1] - LATA RA2 & RA3
{3, &LATA, &LATA, 4, 5}, // Port3[2] - LATA RA4 & RA5
{4, &LATB, &LATB, 0, 1}, // Port4[3] - LATB RB0 & RB1
// ...
};
Code: Select all
portNum = 4
Code: Select all
pPort = &Ports;
pPortTmp = pPort + portNum - 1;
Address = pPortTmp->DataLineByte;
BitNum= pPortTmp->DLBit;
asm{
BSF Address + 0, BitNum
}