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

Memory Initialization Routine

Does anyone know what C-code source, header or library file gets compiled to generate the following memory initialization code using a Program Counter (PC) data table for the 8051? And what is the purpose and intended function of this table--how is it commonly used?

i have been reading thru various different .A51 files for comparison purposes and noticed that this code is nearly always identically found in any set of application programs. It made me think this table is generated by the compiler to perform some function, but what?

for example the PC table is found at x045B below:

L0006:
  042B E4               CLR A
  042C 93               MOVC A, @A+DPTR
  042D A3               INC DPTR
  042E F8               MOV R0, A
L0014:
  042F E4               CLR A
  0430 93               MOVC A, @A+DPTR
  0431 A3               INC DPTR
  0432 4003             JC L0012
  0434 F6               MOV @R0, A
  0435 8001             SJMP L0013

L0012:
  0437 F2               MOVX @R0, A
L0013:
  0438 08               INC R0
  0439 DFF4             DJNZ R7, L0014
  043B 8029             SJMP L0009

L0007:
  043D E4               CLR A
  043E 93               MOVC A, @A+DPTR
  043F A3               INC DPTR
  0440 F8               MOV R0, A
  0441 5407             ANL A, #7h
  0443 240C             ADD A, #0Ch
  0445 C8               XCH A, R0
  0446 C3               CLR C
  0447 33               RLC A
  0448 C4               SWAP A
  0449 540F             ANL A, #0Fh
  044B 4420             ORL A, #20h
  044D C8               XCH A, R0
  044E 83               MOVC A, @A+PC
  044F 4004             JC L0010
  0451 F4               CPL A
  0452 56               ANL A, @R0
  0453 8001             SJMP L0011

L0010:
  0455 46               ORL A, @R0
L0011:
  0456 F6               MOV @R0, A
  0457 DFE4             DJNZ R7, L0007
  0459 800B             SJMP L0009

  045B 01               DB 001h
  045C 02               DB 002h
  045D 04               DB 004h
  045E 08               DB 008h
  045F 10               DB 010h
  0460 20               DB 020h
  0461 40               DB 040h
  0462 80               DB 080h
L0003:
  0463 900B5F           MOV DPTR, #0B5Fh
L0009:
  0466 E4               CLR A
  0467 7E01             MOV R6, #1h
  0469 93               MOVC A, @A+DPTR
  046A 60BC             JZ L0004
  046C A3               INC DPTR
  046D FF               MOV R7, A
  046E 543F             ANL A, #3Fh
  0470 30E509           JNB ACC.5, L0005
  0473 541F             ANL A, #1Fh
  0475 FE               MOV R6, A
  0476 E4               CLR A
  0477 93               MOVC A, @A+DPTR
  0478 A3               INC DPTR
  0479 6001             JZ L0005
  047B 0E               INC R6
L0005:
  047C CF               XCH A, R7
  047D 54C0             ANL A, #0C0h
  047F 25E0             ADD A, ACC
  0481 60A8             JZ L0006
  0483 40B8             JC L0007
  0485 E4               CLR A
  0486 93               MOVC A, @A+DPTR
  0487 A3               INC DPTR
  0488 FA               MOV R2, A
  0489 E4               CLR A
  048A 93               MOVC A, @A+DPTR
  048B A3               INC DPTR
  048C F8               MOV R0, A
L0008:
  048D E4               CLR A
  048E 93               MOVC A, @A+DPTR
  048F A3               INC DPTR
  0490 C8               XCH A, R0
  0491 C582             XCH A, DPL
  0493 C8               XCH A, R0
  0494 CA               XCH A, R2
  0495 C583             XCH A, DPH
  0497 CA               XCH A, R2
  0498 F0               MOVX @DPTR, A
  0499 A3               INC DPTR
  049A C8               XCH A, R0
  049B C582             XCH A, DPL
  049D C8               XCH A, R0
  049E CA               XCH A, R2
  049F C583             XCH A, DPH
  04A1 CA               XCH A, R2
  04A2 DFE9             DJNZ R7, L0008
  04A4 DEE7             DJNZ R6, L0008
  04A6 80BE             SJMP L0009

Thank you,
kenneth

  • Does anyone know what C-code source, header or library file gets compiled to generate the following memory initialization code
    neither it is generated from scratch

    hat is the purpose and intended function of this table
    how else would something like

    void main (void
    {
    unsigned char whatever = 7;
    


    get 'whatever' initialized to 7

    --how is it commonly used?
    it is automatically included