This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Convert assembly to Keil C

Assembly code for reading internal EEPROM of AT89S8252:

WMCON DATA 96h ; watchdog and memory control register
EEMEN EQU 00001000b ; EEPROM access enable bit
EEMWE EQU 00010000b ; EEPROM write enable bit
WDTRST EQU 00000010b ; EEPROM RDY/BSY bit

orl WMCON, #EEMEN ; enable EEPROM accesses
mov dptr, #ADDRESS ; address to read
movx a, @dptr ; read EEPROM
xrl WMCON, #EEMEN ; disable EEPROM accesses

I want to convert this code to a C function like this:

unsigned char eepromread(unsigned int address);


Address of data byte in EEPROM (content of DPTR register) can be set easily.
Please tell me how to convert the following instructions to Keil C.

mov dptr, #ADDRESS ; address to read
movx a, @dptr ; read EEPROM

Suppose that the result is saved to a unsigned char variable.

0