Memory reading problem in assembly

Thread Starter

Chris-Pap

Joined Mar 15, 2010
6
Hi guys.

I'm in a project for a home alarm system. Ι'm using AT89C51AC2. I have a problem with a part of the code. Here is the thing




PSIFIO2:
DELAY10: MOV R6,#0C3h ; delay for the keys to be pressed
DELAY11: MOV R7,#0FFh
DELAY21: NOP
NOP
DJNZ R7,DELAY21
DJNZ R6,DELAY11


mov R7,#90h
mov A,#0h
call SCAN2 ; scan2 is the routine that scans the keypad
MOV A,R5
CJNE A,#0FFh,ELEGXOSPSIFIOU2 ; check if any key has been pressed and jump to ELEGXOSPSIFIOU2
JMP PSIFIO2 ; ;if no key has been pressed jump to psifio2 and scan again.



ELEGXOSPSIFIOU2:
INC R7
MOV 96h,R5
MOV @R7,96h ;
MOV A,34h
CJNE A,#04h,GRAPSE2 ; Check if it's the 4th key that has been pressed. Go to Grapse 2
TELOS2: JMP ENTER2 ; OR ENTER2

I want to scan the keypad and the value of the pressed keys to be saved at successive memory locations (in my program 90H -93H)so i can compare them later in an other part of my program.

The scan2 routine returns the value of the pressed key to R5 and if no key is pressed returns FF. My problem is that when i press the key to build the code, i get 2 errors at the bolded line:

An A4 Bad indirect register and
an A9: Syntax error

What seems to be the problem;
 

Papabravo

Joined Feb 24, 2006
21,228
The instruction set does not allow any register to be used as an indirect pointer. Only R0 and R1 can be used as indirect pointers for addressing data memory with an 8-bit address. Go back to the instruction set manual and look at the encoding of those indirect addressing instructions and notice that only a single bit is reserved for the selection of the pointer register.
 
Top