| ??? 07/13/08 22:06 Read: times |
#156672 - strcpy to a location in code memory Responding to: ???'s previous message |
temp points to "Test1" which resides in code memory.
So strcpy(temp, something) is not likely to succeed:) The corresponding assembler code for SDCC is slightly more compact but the compiler does not warn on copying to code memory either:
0000 358 _main:
369 ; strcpy.c:12: P2 = temp[4];
0000 90s00r04 370 mov dptr,#(__str_0 + 0x0004)
0003 E4 371 clr a
0004 93 372 movc a,@a+dptr
0005 F5 A0 373 mov _P2,a
374 ; strcpy.c:13: strcpy(temp, temp2);
0007 75*00r06 375 mov _strcpy_PARM_2,#__str_1
000A 75*01s00 376 mov (_strcpy_PARM_2 + 1),#(__str_1 >> 8)
000D 75*02 80 377 mov (_strcpy_PARM_2 + 2),#0x80
0010 90s00r00 378 mov dptr,#__str_0
0013 75 F0 80 379 mov b,#0x80
0016 12s00r00 380 lcall _strcpy
381 ; strcpy.c:14: P2 = temp[4];
0019 90s00r04 382 mov dptr,#(__str_0 + 0x0004)
001C E4 383 clr a
001D 93 384 movc a,@a+dptr
001E F5 A0 385 mov _P2,a
386 ; strcpy.c:15: while(1);
0020 387 00102$:
0020 80 FE 388 sjmp 00102$
389 .area CSEG (CODE)
390 .area CONST (CODE)
0000 391 __str_0:
0000 54 65 73 74 31 392 .ascii "Test1"
0005 00 393 .db 0x00
0006 394 __str_1:
0006 54 65 73 74 32 395 .ascii "Test2"
000B 00 396 .db 0x00
|
| Topic | Author | Date |
| Confused by strcopy - C newb. | 01/01/70 00:00 | |
| ... the disassembly | 01/01/70 00:00 | |
| strcpy to a location in code memory | 01/01/70 00:00 | |
| String literals in program memory. | 01/01/70 00:00 | |
| Thank you both... | 01/01/70 00:00 | |
'temp' holds an address, not the char array. | 01/01/70 00:00 |



