I have to create an ASM file for the PIC18F452 that does the following:
(a) define the label MapName as the first of 8 consecutive registers containing a null-terminated string of not more than 7 characters. (b) access an 8-bit unsigned integer variable called MapIndex which was declared in a C file. (c) define an ASM function getMapChar which can be called from C using the function prototype char getMapChar(void). The function should return the appropriate character when the value of MapIndex is <= 7 or the value 255 if MapIndex is > 7. (d) make the labels MapName and getMapChar accessible to an external C file.
My code so far is shown below:
; Configuration word : WDT off, power-up timer on, code protect off, RC oscillator
list = p18f452
MapName equ 0x20
MapName1 equ 0x21
MapName2 equ 0x22
MapName3 equ 0x23
MapName4 equ 0x24
MapName5 equ 0x25
MapName6 equ 0x26
MapName7 equ 0x27
CurrentChar equ 0x28
extern MapIndex
org 0x00
goto getMapChar
getMapChar movlw 0x00
movwf MapName7
GLOBAL getMapChar
GLOBAL MapName
END
I have already done parts (a), (b) and (d) but I am having some problems with writing the code that moves through each of the consecutive registers automatically using the value of MapIndex. Could anyone help me please? It would be much appreciated.