We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, there is huge misunderstood in C166, just try this: #pragma code // and char * cptr; // and this: cptr[-1]=*cptr++; and look at the assmbled machine code. and ... have a lot of fun ...
Hi Jon. I decided to send another interesting example. And also I have also decrypted the name of "CA166" which means C in 42.0% and the rest is assembler in C so all of us should be grateful for that C inserts "nop" after changing CP or DPPx. C166 COMPILER V4.20c, BS 01/09/2002 11:28:53 PAGE 1 C166 COMPILER V4.20c, COMPILATION OF MODULE BS OBJECT MODULE PLACED IN bs.OBJ COMPILER INVOKED BY: C:\KEIL\C166\BIN\C166.EXE bs.c MOD167 DEBUG stmt lvl source 1 #pragma code 2 3 struct again 4 { 5 char a; 6 }; 7 8 void bs_test(char * cptr) 9 { 10 1 cptr[-1]=*cptr++; 11 1 *cptr++=cptr[1]; 12 1 } 13 14 void bs_come_back(struct again * saptr) 15 { 16 1 saptr[-1]=*saptr++; 17 1 } C166 COMPILER V4.20c, BS 01/09/2002 11:28:53 PAGE 2 ASSEMBLY LISTING OF GENERATED OBJECT CODE ; FUNCTION bs_test (BEGIN RMASK = @0x4160) ; SOURCE LINE # 8 ;---- Variable 'cptr' assigned to Register 'R8' ---- ; SOURCE LINE # 10 0000 99A8 MOVB RL5,[R8+] 0002 E4A8FFFF MOVB [R8+#0FFFFH],RL5 ; SOURCE LINE # 11 0006 F4C80100 MOVB RL6,[R8+#01H] 000A F058 MOV R5,R8 000C 0881 ADD R8,#01H 000E B9C5 MOVB [R5],RL6 ; SOURCE LINE # 12 0010 CB00 RET ; FUNCTION bs_test (END RMASK = @0x4160) ; FUNCTION bs_come_back (BEGIN RMASK = @0x41D0) ; SOURCE LINE # 14 ;---- Variable 'saptr' assigned to Register 'R8' ---- ; SOURCE LINE # 16 0012 F048 MOV R4,R8 0014 0881 ADD R8,#01H 0016 F068 MOV R6,R8 0018 2861 SUB R6,#01H 001A E017 MOV R7,#01H 001C ?C0001: 001C E964 MOVB [R6],[R4+] 001E 0861 ADD R6,#01H 0020 2871 SUB R7,#01H 0022 3DFC JMPR cc_NZ,?C0001 ; SOURCE LINE # 17 0024 CB00 RET ; FUNCTION bs_come_back (END RMASK = @0x41D0) MODULE INFORMATION: INITIALIZED UNINITIALIZED CODE SIZE = 38 -------- NEAR-CONST SIZE = -------- -------- FAR-CONST SIZE = -------- -------- HUGE-CONST SIZE = -------- -------- XHUGE-CONST SIZE = -------- -------- NEAR-DATA SIZE = -------- -------- FAR-DATA SIZE = -------- -------- XHUGE-DATA SIZE = -------- -------- IDATA-DATA SIZE = -------- -------- SDATA-DATA SIZE = -------- -------- BDATA-DATA SIZE = -------- -------- HUGE-DATA SIZE = -------- -------- BIT SIZE = -------- -------- INIT'L SIZE = -------- -------- END OF MODULE INFORMATION. C166 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)