I have created a string in flowcode 4 called xxx and initialised it to "abcd". Does anyone know how to set up the fsr register in assembler so that I can access the individual letters of the string. I have tried to set the first letter to upper case A using the following assembly language code in a C asm{..} block but it does not appear to work:
movlw _FCV_XXX
movwf _fsr
movlw 0x41
movwf _indf
If I need to explicitly manipulate the RP1 and RP0 bits of the status register, how do I do that so that the fsr points to the data memory bank that holds the string ?
access flowcode string from assembler - solution
flowcode string access from assembler 2
Following on from my previous post "flowcode string access from assembler "........
I have just discovered that the instruction: movlw _FCV_INIT, moves the least significant 8 bits of the nine bit flowcode variable address (variable name is init) into the w register.
Does anyone know how to access the ninth address bit, so it can be placed in the status register's IRP bit, in assembler ?
I have just discovered that the instruction: movlw _FCV_INIT, moves the least significant 8 bits of the nine bit flowcode variable address (variable name is init) into the w register.
Does anyone know how to access the ninth address bit, so it can be placed in the status register's IRP bit, in assembler ?
- Steve
- Matrix Staff
- Posts: 3433
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
Re: flowcode string access from assembler 2
You'll have to forgive me because my assembler skills are more than a little rusty, and I cannot guarantee that the following will work.
I am assuming that the variable name of the array is actually an "int" datatype (i.e. 16 bits) so that it can hold all 9-bits of the address. If this is the case, then you will need to do something like the following in C:
And then in assembly do something like this:
I am assuming that the variable name of the array is actually an "int" datatype (i.e. 16 bits) so that it can hold all 9-bits of the address. If this is the case, then you will need to do something like the following in C:
Code: Select all
int addr_hi;
addr_hi = (FCV_INIT & 0xF00) >> 8;
Code: Select all
BCF STATUS,IRP
BTFSC _ADDR_HI
BSF STATUS, IRP
MOVLW _FCV_INIT
MOVWF FSR
access flowcode string from assembler - solution
To access a flowcode string XXX using indirect addressing.
1. In supplementary code add:
unsigned char msb;
#define irp 7
2. In a C asm{..} block use the following code to get the start address of the string into irp status reg bit & fsr reg
movlw HIGH(_FCV_XXX)
movwf _msb
bsf _status,irp
btfss _msb,0
bcf _status,irp
movlw LOW(_FCV_XXX)
movwf _fsr
3. To set the first byte of the string to upper case A
movlw 0x41
movwf _indf
The MPLAB MPASM User's manual has lots of useful info about assembler directives etc.
1. In supplementary code add:
unsigned char msb;
#define irp 7
2. In a C asm{..} block use the following code to get the start address of the string into irp status reg bit & fsr reg
movlw HIGH(_FCV_XXX)
movwf _msb
bsf _status,irp
btfss _msb,0
bcf _status,irp
movlw LOW(_FCV_XXX)
movwf _fsr
3. To set the first byte of the string to upper case A
movlw 0x41
movwf _indf
The MPLAB MPASM User's manual has lots of useful info about assembler directives etc.