I'm not very good at assembly language but can't you just pass it the variable name, like _inBuff, which would be the "start adress" of the array?
/Henrik.
I'm not very good at assembly language but can't you just pass it the variable name, like _inBuff, which would be the "start adress" of the array?
/Henrik.
There must be some awful mistakes, I can't get this code working
Code:#CONFIG CONFIG OSC = IRCIO67 ;Internal oscillator block, port function on RA6 and RA7 CONFIG WDT = ON ;WDT enabled CONFIG WDTPS = 64 ;1:64 CONFIG PWRT = ON ;PWRT enabled CONFIG BOREN = BOHW ;Brown-out Reset enabled in hardware only (SBOREN is disabled) CONFIG BORV = 3 ;VBOR set to 2.1V CONFIG MCLRE = OFF ;RE3 input pin enabled; MCLR disabled CONFIG LPT1OSC = OFF ;Timer1 configured for higher power operation CONFIG PBADEN = OFF ;PORTB<4:0> pins are configured as digital I/O on Reset CONFIG XINST = OFF ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode) CONFIG LVP = OFF ;Single-Supply ICSP disabled CONFIG STVREN = ON CONFIG CP0 = ON CONFIG CP1 = ON CONFIG CP2 = ON CONFIG CP3 = ON #ENDCONFIG Define USE_LFSR 1 DEFINE OSC 8 DEFINE DEBUG_REG PORTB DEFINE DEBUG_BIT 4 DEFINE DEBUG_BAUD 9600 DEFINE DEBUG_MODE 0 OSCCON =%01110000 Led VAR PORTB.3 inbuff VAR BYTE[100] x VAR BYTE y VAR BYTE LS0 VAR Word LS1 VAR Word goto Start ASM LoadString macro Text, Dest movlw low Text movwf _LS0 movlw High Text movwf _LS0 + 1 movlw low Dest movwf _LS1 movlw High Dest movwf _LS1 + 1 L?CALL _Lstr endm ENDASM Lstr: y=0 repeat peekcode LS0, x LS1(y)=x y=y+1 LS0=LS0+2 until x=0 return Start: @ LoadString _ROM_CfgString, inbuff debug str inbuff\100,13,10 pause 500 high led pause 500 low led goto start end ROM_CfgString: PokeCode "This a test string",0
try a forum search "embedded string"
What I can't find how to do, is to pass to the macro the address of an array.
as henrik said
inBuff VAR BYTE[100]
in asm the array address is
_inBuff
or give a new name
ASM
mybuff =_inBuff
ENDASM
note label in col 0
make sure you don't overrun your buffer
Hi, I undestand, but I can't put togheter something of working. If you want to have a look to this code, you'll see in my comments where are my doubts.
Anyway the code doesn't compile and give errors ...
Code:inbuff VAR BYTE[100] x VAR BYTE y VAR BYTE LS0 VAR WORD LS1 VAR WORD Lp1: @ LoadInbuff _ROM_CfgString, _Inbuff ; I would like to transfer the ROM string in RAM Inbuff debug str inbuff\100,13,10 goto lp1 ASM LoadInbuff macro Text, Dest CHK?RP _LS0 movlw low Text ; here I load in LS0 the ROM address of the source string movwf _LS0 movlw High Text movwf _LS0 + 1 CHK?RP _LS1 ; here I suppose to load in LS1 the address of the destination buffer movlw low Dest ; but I feel something is wrong movwf _LS1 movlw High Dest movwf _LS1 + 1 L?CALL _Lstr endm ENDASM Lstr: y=0 do peekcode LS0, x ; --->>> what to do here to write the value x to the destination buffer ?? if x=0 then exit y=y+1 LS0=LS0+2 loop return ROM_CfgString: PokeCode "This a test string",0
add this to your code
ARRAYWRITE inbuff,3,,["123"]
and then look at the lst file generated
see how arraywrite works
the array address goes in like this01487 LIST
000004 C00C FFE9 01488 ARRAYWRITE movff R5, FSR0L ; Put the array pointer into FSR0
000008 C00D FFEA 01489 movff R5 + 1, FSR0H
00000C 6EEE 01490 movwf POSTINC0 ; Put the char into the array and bump up the address
00000E CFE9 F00C 01491 movff FSR0L, R5 ; Save new pointer
000012 CFEA F00D 01492 movff FSR0H, R5 + 1
C:\PBP3\EXAMPLES\MARCICK.PBP 00074 ARRAYWRITE inbuff,3,,["123"]
00192 ARRAYWRITENAME?B _inbuff
M MOVE?CW _inbuff, R5
M ifdef USE_LINKER
M CHK?RP R5
M movlw low (_inbuff)
M movwf R5
M movlw high (_inbuff)
M movwf (R5) + 1
you need to emulate this using your own vars don't use r5 of course
interrupts will need to be disabled too
ps the forum totally destroys white space you need to look at your xxx.lst file to make it out properly
Last edited by richard; - 15th April 2015 at 13:49. Reason: clean up
Bookmarks