решил протестировать AVRStudio 4.19 набираю код long tz=7; void ssb(long t){ tz=t+sizeof(long); } int main() { ssb(6); ssb(7); ssb(6); return 0; } смотрю листинг на ассемблере 5: void ssb(long t){ +00000026: 93DF PUSH R29 Push register on stack +00000027: 93CF PUSH R28 Push register on stack +00000028: D000 RCALL PC+0x0001 Relative call subroutine +00000029: D000 RCALL PC+0x0001 Relative call subroutine +0000002A: B7CD IN R28,0x3D In from I/O location +0000002B: B7DE IN R29,0x3E In from I/O location +0000002C: 8369 STD Y+1,R22 Store indirect with displacement +0000002D: 837A STD Y+2,R23 Store indirect with displacement +0000002E: 838B STD Y+3,R24 Store indirect with displacement +0000002F: 839C STD Y+4,R25 Store indirect with displacement 7: tz=t+sizeof(long); +00000030: 8189 LDD R24,Y+1 Load indirect with displacement +00000031: 819A LDD R25,Y+2 Load indirect with displacement +00000032: 81AB LDD R26,Y+3 Load indirect with displacement +00000033: 81BC LDD R27,Y+4 Load indirect with displacement +00000034: 9604 ADIW R24,0x04 Add immediate to word +00000035: 1DA1 ADC R26,R1 Add with carry +00000036: 1DB1 ADC R27,R1 Add with carry +00000037: 93800060 STS 0x0060,R24 Store direct to data space +00000039: 93900061 STS 0x0061,R25 Store direct to data space +0000003B: 93A00062 STS 0x0062,R26 Store direct to data space +0000003D: 93B00063 STS 0x0063,R27 Store direct to data space 8: } +0000003F: 900F POP R0 Pop register from stack +00000040: 900F POP R0 Pop register from stack +00000041: 900F POP R0 Pop register from stack +00000042: 900F POP R0 Pop register from stack +00000043: 91CF POP R28 Pop register from stack +00000044: 91DF POP R29 Pop register from stack +00000045: 9508 RET Subroutine return @00000046: main 12: { +00000046: 93DF PUSH R29 Push register on stack +00000047: 93CF PUSH R28 Push register on stack +00000048: B7CD IN R28,0x3D In from I/O location +00000049: B7DE IN R29,0x3E In from I/O location 13: ssb(6); +0000004A: E066 LDI R22,0x06 Load immediate +0000004B: E070 LDI R23,0x00 Load immediate +0000004C: E080 LDI R24,0x00 Load immediate +0000004D: E090 LDI R25,0x00 Load immediate +0000004E: DFD7 RCALL PC-0x0028 Relative call subroutine 14: ssb(7); +0000004F: E067 LDI R22,0x07 Load immediate +00000050: E070 LDI R23,0x00 Load immediate +00000051: E080 LDI R24,0x00 Load immediate +00000052: E090 LDI R25,0x00 Load immediate +00000053: DFD2 RCALL PC-0x002D Relative call subroutine 15: ssb(6); +00000054: E066 LDI R22,0x06 Load immediate +00000055: E070 LDI R23,0x00 Load immediate +00000056: E080 LDI R24,0x00 Load immediate +00000057: E090 LDI R25,0x00 Load immediate +00000058: DFCD RCALL PC-0x0032 Relative call subroutine 16: return 0; +00000059: E080 LDI R24,0x00 Load immediate +0000005A: E090 LDI R25,0x00 Load immediate 17: } Откуда взялось : +0000002A: B7CD IN R28,0x3D In from I/O location +0000002B: B7DE IN R29,0x3E In from I/O location Это что глюк?
Потому что c регистром SP (как и вообще любым регистром кроме r0-r31)работают через in/out инструкции. Можно использовать и прямое чтение из SRAM, но это менее эффективно.