AnsweredAssumed Answered

Compiler generate wrong code when making index programming S08QD4.

Question asked by Per Hojfeldt on May 7, 2018
Latest reply on Jun 5, 2018 by ZhangJennie

Compiler does not clear H register so returned result is unpredictable.

Solution to clear H register before using index programing.

Eksample:

unsigned char A;

unsigned char B;

#define LOOKUP = 0xF000

A = LOOKUP[B];

Assembler code.

LDX   B;

LDA   0xF000,X

STA   A;

Makes an unpredictable result.

 

Solution.

asm CLRH;

A = LOOKUP[B];

Assembler code.

LDX   B;

CLRH;

LDA   0xF000,X

STA   A;

Makes right result.

Took a little while to figure that one out because no compiler error was reported.

Attachments

Outcomes