Confused about program space increasing.

Go To Last Post
27 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a smell function for my SPI

 

static char spi_mSend ( char data)
{
    SPDR = data;
    while(!(SPSR & (1<<SPIF)));
    _delay_us(100);
    return SPDR;
}

 

I wanted to remove the while since I don't really need to wait for the complete flag and also have to wait an additional 100us so I tried this.

 

static char spi_mSend ( char data)
{
    SPDR = data;
    _delay_us(125);
    return SPDR;
}

 

and my program spades when from

 

 

Program:   28486 bytes (86.9% Full)

to

Program:   28662 bytes (87.5% Full)

 

I'm just really curious why that would be?

 

 

This topic has a solution.
Last Edited: Sun. Jul 8, 2018 - 01:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have only got to inspect the LSS file.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I figure I'd see something in there that relates to my function, like the register names or function name but I see nothing. How can I find the ASM that relates to me function?

   1               		.file	"psx.c"
   2               	__SP_H__ = 0x3e
   3               	__SP_L__ = 0x3d
   4               	__SREG__ = 0x3f
   5               	__tmp_reg__ = 0
   6               	__zero_reg__ = 1
   7               		.text
   9               	doWork:
  10               	/* prologue: function */
  11               	/* frame size = 0 */
  12               	/* stack size = 0 */
  13               	.L__stack_usage = 0
  14 0000 0895      		ret
  17               	Init:
  18               	/* prologue: function */
  19               	/* frame size = 0 */
  20               	/* stack size = 0 */
  21               	.L__stack_usage = 0
  22 0002 1092 0000 		sts _PSX,__zero_reg__
  23 0006 8FE2      		ldi r24,lo8(47)
  24 0008 84B9      		out 0x4,r24
  25 000a 8FEF      		ldi r24,lo8(-1)
  26 000c 85B9      		out 0x5,r24
  27 000e 8FE7      		ldi r24,lo8(127)
  28 0010 8CBD      		out 0x2c,r24
  29 0012 1092 0000 		sts activeMotorCount,__zero_reg__
  30 0016 8091 0000 		lds r24,pressureButton1
  31 001a 8111      		cpse r24,__zero_reg__
  32 001c 00C0      		rjmp .L3
  33 001e 8DE0      		ldi r24,lo8(13)
  34 0020 8093 0000 		sts pressureButton1,r24
  35               	.L3:
  36 0024 8091 0000 		lds r24,pressureButton2
  37 0028 8111      		cpse r24,__zero_reg__
  38 002a 00C0      		rjmp .L4
  39 002c 8EE0      		ldi r24,lo8(14)
  40 002e 8093 0000 		sts pressureButton2,r24
  41               	.L4:
  42 0032 8091 0000 		lds r24,pressureButton3
  43 0036 8111      		cpse r24,__zero_reg__
  44 0038 00C0      		rjmp .L5
  45 003a 83E1      		ldi r24,lo8(19)
  46 003c 8093 0000 		sts pressureButton3,r24
  47               	.L5:
  48 0040 8091 0000 		lds r24,pressureButton4
  49 0044 8111      		cpse r24,__zero_reg__
  50 0046 00C0      		rjmp .L2
  51 0048 84E1      		ldi r24,lo8(20)
  52 004a 8093 0000 		sts pressureButton4,r24
  53               	.L2:
  54 004e 0895      		ret
  57               	RumbleConst:
  58               	/* prologue: function */
  59               	/* frame size = 0 */
  60               	/* stack size = 0 */
  61               	.L__stack_usage = 0
  62 0050 8093 0000 		sts largeMotor,r24
  63 0054 6093 0000 		sts largeMotorDuration,r22
  64 0058 0895      		ret
  67               	RumbleSine:
  68               	/* prologue: function */
  69               	/* frame size = 0 */
  70               	/* stack size = 0 */
  71               	.L__stack_usage = 0
  72 005a 8FEF      		ldi r24,lo8(-1)
  73 005c 8093 0000 		sts smallMotor,r24
  74 0060 6093 0000 		sts smallMotorDuration,r22
  75 0064 0895      		ret
  78               	spi_mSend:
  79               	/* prologue: function */
  80               	/* frame size = 0 */
  81               	/* stack size = 0 */
  82               	.L__stack_usage = 0
  83 0066 8EBD      		out 0x2e,r24
  84               	.L12:
  85 0068 0DB4      		in __tmp_reg__,0x2d
  86 006a 07FE      		sbrs __tmp_reg__,7
  87 006c 00C0      		rjmp .L12
  88 006e 8BE2      		ldi r24,lo8(299)
  89 0070 91E0      		ldi r25,hi8(299)
  90 0072 0197      		1: sbiw r24,1
  91 0074 01F4      		brne 1b
  92 0076 00C0      		rjmp .
  93 0078 0000      		nop
  94 007a 8EB5      		in r24,0x2e
  95 007c 0895      		ret
  98               	configMode:
  99 007e CF93      		push r28
 100 0080 DF93      		push r29
 101               	/* prologue: function */
 102               	/* frame size = 0 */
 103               	/* stack size = 2 */
 104               	.L__stack_usage = 2
 105 0082 D82F      		mov r29,r24
 106 0084 2998      		cbi 0x5,1
 107 0086 8BE2      		ldi r24,lo8(299)
 108 0088 91E0      		ldi r25,hi8(299)
 109 008a 0197      		1: sbiw r24,1
 110 008c 01F4      		brne 1b
 111 008e 00C0      		rjmp .
 112 0090 0000      		nop
 113 0092 81E0      		ldi r24,lo8(1)
 114 0094 0E94 0000 		call spi_mSend
 115 0098 83E4      		ldi r24,lo8(67)
 116 009a 0E94 0000 		call spi_mSend
 117 009e C82F      		mov r28,r24
 118 00a0 80E0      		ldi r24,0
 119 00a2 0E94 0000 		call spi_mSend
 120 00a6 8D2F      		mov r24,r29
 121 00a8 0E94 0000 		call spi_mSend
 122 00ac 80E0      		ldi r24,0
 123 00ae 0E94 0000 		call spi_mSend
 124 00b2 80E0      		ldi r24,0
 125 00b4 0E94 0000 		call spi_mSend
 126 00b8 80E0      		ldi r24,0
 127 00ba 0E94 0000 		call spi_mSend
 128 00be 80E0      		ldi r24,0
 129 00c0 0E94 0000 		call spi_mSend
 130 00c4 80E0      		ldi r24,0
 131 00c6 0E94 0000 		call spi_mSend
 132 00ca 299A      		sbi 0x5,1
 133 00cc 8BE2      		ldi r24,lo8(299)
 134 00ce 91E0      		ldi r25,hi8(299)
 135 00d0 0197      		1: sbiw r24,1
 136 00d2 01F4      		brne 1b
 137 00d4 00C0      		rjmp .
 138 00d6 0000      		nop
 139 00d8 8C2F      		mov r24,r28
 140               	/* epilogue start */
 141 00da DF91      		pop r29
 142 00dc CF91      		pop r28
 143 00de 0895      		ret
 146               	setMotors:
 147 00e0 CF93      		push r28
 148               	/* prologue: function */
 149               	/* frame size = 0 */
 150               	/* stack size = 1 */
 151               	.L__stack_usage = 1
 152 00e2 8091 0000 		lds r24,activeMotorCount
 153 00e6 8F5F      		subi r24,lo8(-(1))
 154 00e8 8093 0000 		sts activeMotorCount,r24
 155 00ec 2998      		cbi 0x5,1
 156 00ee 8BE2      		ldi r24,lo8(299)
 157 00f0 91E0      		ldi r25,hi8(299)
 158 00f2 0197      		1: sbiw r24,1
 159 00f4 01F4      		brne 1b
 160 00f6 00C0      		rjmp .
 161 00f8 0000      		nop
 162 00fa 81E0      		ldi r24,lo8(1)
 163 00fc 0E94 0000 		call spi_mSend
 164 0100 8DE4      		ldi r24,lo8(77)
 165 0102 0E94 0000 		call spi_mSend
 166 0106 80E0      		ldi r24,0
 167 0108 0E94 0000 		call spi_mSend
 168 010c 80E0      		ldi r24,0
 169 010e 0E94 0000 		call spi_mSend
 170 0112 C82F      		mov r28,r24
 171 0114 81E0      		ldi r24,lo8(1)
 172 0116 0E94 0000 		call spi_mSend
 173 011a 9091 0000 		lds r25,activeMotorCount
 174 011e 9431      		cpi r25,lo8(20)
 175 0120 01F0      		breq .L16
 176 0122 C80F      		add r28,r24
 177 0124 CF5F      		subi r28,lo8(-(1))
 178 0126 00C0      		rjmp .L15
 179               	.L16:
 180 0128 CFEF      		ldi r28,lo8(-1)
 181               	.L15:
 182 012a 8FEF      		ldi r24,lo8(-1)
 183 012c 0E94 0000 		call spi_mSend
 184 0130 8FEF      		ldi r24,lo8(-1)
 185 0132 0E94 0000 		call spi_mSend
 186 0136 8FEF      		ldi r24,lo8(-1)
 187 0138 0E94 0000 		call spi_mSend
 188 013c 8FEF      		ldi r24,lo8(-1)
 189 013e 0E94 0000 		call spi_mSend
 190 0142 299A      		sbi 0x5,1
 191 0144 8BE2      		ldi r24,lo8(299)
 192 0146 91E0      		ldi r25,hi8(299)
 193 0148 0197      		1: sbiw r24,1
 194 014a 01F4      		brne 1b
 195 014c 00C0      		rjmp .
 196 014e 0000      		nop
 197 0150 8C2F      		mov r24,r28
 198               	/* epilogue start */
 199 0152 CF91      		pop r28
 200 0154 0895      		ret
 203               	Probe:
 204 0156 CF93      		push r28
 205               	/* prologue: function */
 206               	/* frame size = 0 */
 207               	/* stack size = 1 */
 208               	.L__stack_usage = 1
 209 0158 CAE0      		ldi r28,lo8(10)
 210               	.L21:
 211 015a 2998      		cbi 0x5,1
 212 015c 8BE2      		ldi r24,lo8(299)
 213 015e 91E0      		ldi r25,hi8(299)
 214 0160 0197      		1: sbiw r24,1
 215 0162 01F4      		brne 1b
 216 0164 00C0      		rjmp .
 217 0166 0000      		nop
 218 0168 81E0      		ldi r24,lo8(1)
 219 016a 0E94 0000 		call spi_mSend
 220 016e 82E4      		ldi r24,lo8(66)
 221 0170 0E94 0000 		call spi_mSend
 222 0174 8093 0000 		sts ID,r24
 223 0178 80E0      		ldi r24,0
 224 017a 0E94 0000 		call spi_mSend
 225 017e 80E0      		ldi r24,0
 226 0180 0E94 0000 		call spi_mSend
 227 0184 80E0      		ldi r24,0
 228 0186 0E94 0000 		call spi_mSend
 229 018a 299A      		sbi 0x5,1
 230 018c 8BE2      		ldi r24,lo8(299)
 231 018e 91E0      		ldi r25,hi8(299)
 232 0190 0197      		1: sbiw r24,1
 233 0192 01F4      		brne 1b
 234 0194 00C0      		rjmp .
 235 0196 0000      		nop
 236 0198 8091 0000 		lds r24,ID
 237 019c 8150      		subi r24,lo8(-(-1))
 238 019e 8E3F      		cpi r24,lo8(-2)
 239 01a0 00F4      		brsh .L18
 240 01a2 81E0      		ldi r24,lo8(1)
 241 01a4 8093 0000 		sts startUp,r24
 242 01a8 8093 0000 		sts _PSX,r24
 243 01ac 81E4      		ldi r24,lo8(65)
 244 01ae 00C0      		rjmp .L19
 245               	.L18:
 246 01b0 87EB      		ldi r24,lo8(2999)
 247 01b2 9BE0      		ldi r25,hi8(2999)
 248 01b4 0197      		1: sbiw r24,1
 249 01b6 01F4      		brne 1b
 250 01b8 00C0      		rjmp .
 251 01ba 0000      		nop
 252 01bc C150      		subi r28,lo8(-(-1))
 253 01be 01F4      		brne .L21
 254 01c0 8CB5      		in r24,0x2c
 255 01c2 8F7B      		andi r24,lo8(-65)
 256 01c4 8CBD      		out 0x2c,r24
 257 01c6 80E0      		ldi r24,0
 258               	.L19:
 259               	/* epilogue start */
 260 01c8 CF91      		pop r28
 261 01ca 0895      		ret
 264               	psxStartUp:
 265 01cc CF93      		push r28
 266               	/* prologue: function */
 267               	/* frame size = 0 */
 268               	/* stack size = 1 */
 269               	.L__stack_usage = 1
 270 01ce 8CEF      		ldi r24,lo8(764)
 271 01d0 92E0      		ldi r25,hi8(764)
 272 01d2 0197      		1: sbiw r24,1
 273 01d4 01F4      		brne 1b
 274 01d6 00C0      		rjmp .
 275 01d8 0000      		nop
 276 01da 81E0      		ldi r24,lo8(1)
 277 01dc 0E94 0000 		call configMode
 278 01e0 8093 0000 		sts ID,r24
 279 01e4 2998      		cbi 0x5,1
 280 01e6 8BE2      		ldi r24,lo8(299)
 281 01e8 91E0      		ldi r25,hi8(299)
 282 01ea 0197      		1: sbiw r24,1
 283 01ec 01F4      		brne 1b
 284 01ee 00C0      		rjmp .
 285 01f0 0000      		nop
 286 01f2 81E0      		ldi r24,lo8(1)
 287 01f4 0E94 0000 		call spi_mSend
 288 01f8 85E4      		ldi r24,lo8(69)
 289 01fa 0E94 0000 		call spi_mSend
 290 01fe 80E0      		ldi r24,0
 291 0200 0E94 0000 		call spi_mSend
 292 0204 8AE5      		ldi r24,lo8(90)
 293 0206 0E94 0000 		call spi_mSend
 294 020a C82F      		mov r28,r24
 295 020c 8AE5      		ldi r24,lo8(90)
 296 020e 0E94 0000 		call spi_mSend
 297 0212 8AE5      		ldi r24,lo8(90)
 298 0214 0E94 0000 		call spi_mSend
 299 0218 8AE5      		ldi r24,lo8(90)
 300 021a 0E94 0000 		call spi_mSend
 301 021e 8AE5      		ldi r24,lo8(90)
 302 0220 0E94 0000 		call spi_mSend
 303 0224 8AE5      		ldi r24,lo8(90)
 304 0226 0E94 0000 		call spi_mSend
 305 022a 299A      		sbi 0x5,1
 306 022c 8BE2      		ldi r24,lo8(299)
 307 022e 91E0      		ldi r25,hi8(299)
 308 0230 0197      		1: sbiw r24,1
 309 0232 01F4      		brne 1b
 310 0234 00C0      		rjmp .
 311 0236 0000      		nop
 312 0238 C093 0000 		sts controllerType,r28
 313 023c 2998      		cbi 0x5,1
 314 023e 8BE2      		ldi r24,lo8(299)
 315 0240 91E0      		ldi r25,hi8(299)
 316 0242 0197      		1: sbiw r24,1
 317 0244 01F4      		brne 1b
 318 0246 00C0      		rjmp .
 319 0248 0000      		nop
 320 024a 81E0      		ldi r24,lo8(1)
 321 024c 0E94 0000 		call spi_mSend
 322 0250 84E4      		ldi r24,lo8(68)
 323 0252 0E94 0000 		call spi_mSend
 324 0256 80E0      		ldi r24,0
 325 0258 0E94 0000 		call spi_mSend
 326 025c 81E0      		ldi r24,lo8(1)
 327 025e 0E94 0000 		call spi_mSend
 328 0262 80E0      		ldi r24,0
 329 0264 0E94 0000 		call spi_mSend
 330 0268 80E0      		ldi r24,0
 331 026a 0E94 0000 		call spi_mSend
 332 026e 80E0      		ldi r24,0
 333 0270 0E94 0000 		call spi_mSend
 334 0274 80E0      		ldi r24,0
 335 0276 0E94 0000 		call spi_mSend
 336 027a 80E0      		ldi r24,0
 337 027c 0E94 0000 		call spi_mSend
 338 0280 299A      		sbi 0x5,1
 339 0282 8BE2      		ldi r24,lo8(299)
 340 0284 91E0      		ldi r25,hi8(299)
 341 0286 0197      		1: sbiw r24,1
 342 0288 01F4      		brne 1b
 343 028a 00C0      		rjmp .
 344 028c 0000      		nop
 345 028e 0E94 0000 		call setMotors
 346 0292 8F3F      		cpi r24,lo8(-1)
 347 0294 01F0      		breq .L23
 348 0296 81E0      		ldi r24,lo8(1)
 349 0298 8093 0000 		sts startUp,r24
 350               	.L23:
 351 029c 0E94 0000 		call setMotors
 352 02a0 8F3F      		cpi r24,lo8(-1)
 353 02a2 01F0      		breq .L24
 354 02a4 81E0      		ldi r24,lo8(1)
 355 02a6 8093 0000 		sts startUp,r24
 356 02aa 00C0      		rjmp .L25
 357               	.L24:
 358 02ac 1092 0000 		sts startUp,__zero_reg__
 359               	.L25:
 360 02b0 2998      		cbi 0x5,1
 361 02b2 8BE2      		ldi r24,lo8(299)
 362 02b4 91E0      		ldi r25,hi8(299)
 363 02b6 0197      		1: sbiw r24,1
 364 02b8 01F4      		brne 1b
 365 02ba 00C0      		rjmp .
 366 02bc 0000      		nop
 367 02be 81E0      		ldi r24,lo8(1)
 368 02c0 0E94 0000 		call spi_mSend
 369 02c4 8FE4      		ldi r24,lo8(79)
 370 02c6 0E94 0000 		call spi_mSend
 371 02ca 80E0      		ldi r24,0
 372 02cc 0E94 0000 		call spi_mSend
 373 02d0 8FEF      		ldi r24,lo8(-1)
 374 02d2 0E94 0000 		call spi_mSend
 375 02d6 8FEF      		ldi r24,lo8(-1)
 376 02d8 0E94 0000 		call spi_mSend
 377 02dc 83E0      		ldi r24,lo8(3)
 378 02de 0E94 0000 		call spi_mSend
 379 02e2 80E0      		ldi r24,0
 380 02e4 0E94 0000 		call spi_mSend
 381 02e8 80E0      		ldi r24,0
 382 02ea 0E94 0000 		call spi_mSend
 383 02ee 80E0      		ldi r24,0
 384 02f0 0E94 0000 		call spi_mSend
 385 02f4 299A      		sbi 0x5,1
 386 02f6 8BE2      		ldi r24,lo8(299)
 387 02f8 91E0      		ldi r25,hi8(299)
 388 02fa 0197      		1: sbiw r24,1
 389 02fc 01F4      		brne 1b
 390 02fe 00C0      		rjmp .
 391 0300 0000      		nop
 392 0302 80E0      		ldi r24,0
 393               	/* epilogue start */
 394 0304 CF91      		pop r28
 395 0306 0C94 0000 		jmp configMode
 398               	Update:
 399 030a EF92      		push r14
 400 030c FF92      		push r15
 401 030e 0F93      		push r16
 402 0310 1F93      		push r17
 403 0312 CF93      		push r28
 404 0314 DF93      		push r29
 405 0316 CDB7      		in r28,__SP_L__
 406 0318 DEB7      		in r29,__SP_H__
 407 031a A297      		sbiw r28,34
 408 031c 0FB6      		in __tmp_reg__,__SREG__
 409 031e F894      		cli
 410 0320 DEBF      		out __SP_H__,r29
 411 0322 0FBE      		out __SREG__,__tmp_reg__
 412 0324 CDBF      		out __SP_L__,r28
 413               	/* prologue: function */
 414               	/* frame size = 34 */
 415               	/* stack size = 40 */
 416               	.L__stack_usage = 40
 417 0326 2B9A      		sbi 0x5,3
 418 0328 239A      		sbi 0x4,3
 419 032a 8CB5      		in r24,0x2c
 420 032c 8064      		ori r24,lo8(64)
 421 032e 8CBD      		out 0x2c,r24
 422 0330 8BE2      		ldi r24,lo8(299)
 423 0332 91E0      		ldi r25,hi8(299)
 424 0334 0197      		1: sbiw r24,1
 425 0336 01F4      		brne 1b
 426 0338 00C0      		rjmp .
 427 033a 0000      		nop
 428 033c 8091 0000 		lds r24,_NeedsWrite
 429 0340 8823      		tst r24
 430 0342 01F0      		breq .L30
 431 0344 2998      		cbi 0x5,1
 432 0346 EBE2      		ldi r30,lo8(299)
 433 0348 F1E0      		ldi r31,hi8(299)
 434 034a 3197      		1: sbiw r30,1
 435 034c 01F4      		brne 1b
 436 034e 00C0      		rjmp .
 437 0350 0000      		nop
 438 0352 F12C      		mov r15,__zero_reg__
 439               	.L31:
 440 0354 4091 0000 		lds r20,payload_data_size
 441 0358 5091 0000 		lds r21,payload_data_size+1
 442 035c 0F2D      		mov r16,r15
 443 035e 1127      		clr r17
 444 0360 07FD      		sbrc r16,7
 445 0362 1095      		com r17
 446 0364 0417      		cp r16,r20
 447 0366 1507      		cpc r17,r21
 448 0368 00F4      		brsh .L152
 449 036a F801      		movw r30,r16
 450 036c E050      		subi r30,lo8(-(payload_data))
 451 036e F040      		sbci r31,hi8(-(payload_data))
 452 0370 8081      		ld r24,Z
 453 0372 0E94 0000 		call spi_mSend
 454 0376 E2E0      		ldi r30,lo8(2)
 455 0378 F0E0      		ldi r31,0
 456 037a EC0F      		add r30,r28
 457 037c FD1F      		adc r31,r29
 458 037e E00F      		add r30,r16
 459 0380 F11F      		adc r31,r17
 460 0382 8083      		st Z,r24
 461 0384 F394      		inc r15
 462 0386 00C0      		rjmp .L31
 463               	.L152:
 464 0388 5093 0000 		sts payload_return_data_size+1,r21
 465 038c 4093 0000 		sts payload_return_data_size,r20
 466 0390 4983      		std Y+1,r20
 467 0392 BE01      		movw r22,r28
 468 0394 6F5F      		subi r22,-1
 469 0396 7F4F      		sbci r23,-1
 470 0398 80E0      		ldi r24,lo8(payload_data)
 471 039a 90E0      		ldi r25,hi8(payload_data)
 472 039c 0E94 0000 		call memcpy
 473 03a0 1092 0000 		sts payload_data_size+1,__zero_reg__
 474 03a4 1092 0000 		sts payload_data_size,__zero_reg__
 475 03a8 1092 0000 		sts _NeedsWrite,__zero_reg__
 476 03ac 81E0      		ldi r24,lo8(1)
 477 03ae 8093 0000 		sts _DoNotReport,r24
 478 03b2 299A      		sbi 0x5,1
 479 03b4 00C0      		rjmp .L29
 480               	.L30:
 481 03b6 8091 0000 		lds r24,controllerType
 482 03ba 8430      		cpi r24,lo8(4)
 483 03bc 01F4      		brne .L34
 484 03be 81E0      		ldi r24,lo8(1)
 485 03c0 8093 0000 		sts _autoPause,r24
 486               	/* epilogue start */
 487 03c4 A296      		adiw r28,34
 488 03c6 0FB6      		in __tmp_reg__,__SREG__
 489 03c8 F894      		cli
 490 03ca DEBF      		out __SP_H__,r29
 491 03cc 0FBE      		out __SREG__,__tmp_reg__
 492 03ce CDBF      		out __SP_L__,r28
 493 03d0 DF91      		pop r29
 494 03d2 CF91      		pop r28
 495 03d4 1F91      		pop r17
 496 03d6 0F91      		pop r16
 497 03d8 FF90      		pop r15
 498 03da EF90      		pop r14
 499 03dc 0C94 0000 		jmp psxStartUp
 500               	.L34:
 501 03e0 2998      		cbi 0x5,1
 502 03e2 8BE2      		ldi r24,lo8(299)
 503 03e4 91E0      		ldi r25,hi8(299)
 504 03e6 0197      		1: sbiw r24,1
 505 03e8 01F4      		brne 1b
 506 03ea 00C0      		rjmp .
 507 03ec 0000      		nop
 508 03ee 8091 0000 		lds r24,smallMotor
 509 03f2 8823      		tst r24
 510 03f4 01F0      		breq .L35
 511 03f6 8091 0000 		lds r24,smallMotorDuration
 512 03fa 9FEF      		ldi r25,lo8(-1)
 513 03fc 980F      		add r25,r24
 514 03fe 9E3F      		cpi r25,lo8(-2)
 515 0400 00F4      		brsh .L36
 516 0402 9093 0000 		sts smallMotorDuration,r25
 517 0406 00C0      		rjmp .L37
 518               	.L36:
 519 0408 8F3F      		cpi r24,lo8(-1)
 520 040a 01F0      		breq .L37
 521 040c 1092 0000 		sts smallMotorDuration,__zero_reg__
 522 0410 1092 0000 		sts smallMotor,__zero_reg__
 523 0414 00C0      		rjmp .L37
 524               	.L35:
 525 0416 1092 0000 		sts smallMotorDuration,__zero_reg__
 526               	.L37:
 527 041a 8091 0000 		lds r24,largeMotor
 528 041e 8823      		tst r24
 529 0420 01F0      		breq .L38
 530 0422 8091 0000 		lds r24,largeMotorDuration
 531 0426 9FEF      		ldi r25,lo8(-1)
 532 0428 980F      		add r25,r24
 533 042a 9E3F      		cpi r25,lo8(-2)
 534 042c 00F4      		brsh .L39
 535 042e 9093 0000 		sts largeMotorDuration,r25
 536 0432 00C0      		rjmp .L40
 537               	.L39:
 538 0434 8F3F      		cpi r24,lo8(-1)
 539 0436 01F0      		breq .L40
 540 0438 1092 0000 		sts largeMotorDuration,__zero_reg__
 541 043c 1092 0000 		sts largeMotor,__zero_reg__
 542 0440 00C0      		rjmp .L40
 543               	.L38:
 544 0442 1092 0000 		sts largeMotorDuration,__zero_reg__
 545               	.L40:
 546 0446 81E0      		ldi r24,lo8(1)
 547 0448 0E94 0000 		call spi_mSend
 548 044c 82E4      		ldi r24,lo8(66)
 549 044e 0E94 0000 		call spi_mSend
 550 0452 8093 0000 		sts ps2buffer+1,r24
 551 0456 80E0      		ldi r24,0
 552 0458 0E94 0000 		call spi_mSend
 553 045c 182F      		mov r17,r24
 554 045e 8091 0000 		lds r24,smallMotor
 555 0462 0E94 0000 		call spi_mSend
 556 0466 8093 0000 		sts ps2buffer+3,r24
 557 046a 8091 0000 		lds r24,largeMotor
 558 046e 0E94 0000 		call spi_mSend
 559 0472 8093 0000 		sts ps2buffer+4,r24
 560 0476 9091 0000 		lds r25,ps2buffer+1
 561 047a 9093 0000 		sts ID,r25
 562 047e 9093 0000 		sts _cntrl,r25
 563 0482 1F3F      		cpi r17,lo8(-1)
 564 0484 01F4      		brne .L41
 565 0486 84E0      		ldi r24,lo8(4)
 566 0488 8093 0000 		sts controllerType,r24
 567 048c 299A      		sbi 0x5,1
 568 048e 00C0      		rjmp .L42
 569               	.L41:
 570 0490 9332      		cpi r25,lo8(35)
 571 0492 01F4      		brne .L43
 572 0494 81E0      		ldi r24,lo8(1)
 573 0496 8093 0000 		sts Negcon,r24
 574 049a 00C0      		rjmp .L44
 575               	.L43:
 576 049c 9134      		cpi r25,lo8(65)
 577 049e 01F4      		brne .L45
 578 04a0 81E0      		ldi r24,lo8(1)
 579 04a2 8093 0000 		sts ps2buffer+6,r24
 580 04a6 8093 0000 		sts ps2buffer+5,r24
 581 04aa 00C0      		rjmp .L46
 582               	.L45:
 583 04ac 9337      		cpi r25,lo8(115)
 584 04ae 01F4      		brne .L47
 585               	.L50:
 586 04b0 80E0      		ldi r24,0
 587 04b2 0E94 0000 		call spi_mSend
 588 04b6 8093 0000 		sts ps2buffer+5,r24
 589 04ba 80E0      		ldi r24,0
 590 04bc 0E94 0000 		call spi_mSend
 591 04c0 8093 0000 		sts ps2buffer+6,r24
 592 04c4 80E0      		ldi r24,0
 593 04c6 0E94 0000 		call spi_mSend
 594 04ca 8093 0000 		sts ps2buffer+7,r24
 595 04ce 8091 0000 		lds r24,ID
 596 04d2 8335      		cpi r24,lo8(83)
 597 04d4 01F4      		brne .L149
 598 04d6 80E0      		ldi r24,0
 599 04d8 0E94 0000 		call spi_mSend
 600 04dc 8095      		com r24
 601 04de 00C0      		rjmp .L151
 602               	.L47:
 603 04e0 892F      		mov r24,r25
 604 04e2 8D7F      		andi r24,lo8(-3)
 605 04e4 8135      		cpi r24,lo8(81)
 606 04e6 01F0      		breq .L50
 607 04e8 9F3F      		cpi r25,lo8(-1)
 608 04ea 01F0      		breq .L50
 609               	.L44:
 610 04ec 8091 0000 		lds r24,Negcon
 611 04f0 8111      		cpse r24,__zero_reg__
 612 04f2 00C0      		rjmp .L50
 613 04f4 00C0      		rjmp .L153
 614               	.L149:
 615 04f6 80E0      		ldi r24,0
 616 04f8 0E94 0000 		call spi_mSend
 617               	.L151:
 618 04fc 8093 0000 		sts ps2buffer+8,r24
 619 0500 8091 0000 		lds r24,controllerType
 620 0504 8330      		cpi r24,lo8(3)
 621 0506 01F4      		brne .L46
 622 0508 81E0      		ldi r24,lo8(1)
 623 050a 8093 0000 		sts startUp,r24
 624 050e 00C0      		rjmp .L46
 625               	.L153:
 626 0510 9937      		cpi r25,lo8(121)
 627 0512 01F4      		brne .L46
 628 0514 00E0      		ldi r16,lo8(ps2buffer+5)
 629 0516 10E0      		ldi r17,hi8(ps2buffer+5)
 630               	.L55:
 631 0518 80E0      		ldi r24,0
 632 051a 0E94 0000 		call spi_mSend
 633 051e F801      		movw r30,r16
 634 0520 8193      		st Z+,r24
 635 0522 8F01      		movw r16,r30
 636 0524 F0E0      		ldi r31,hi8(ps2buffer+21)
 637 0526 0030      		cpi r16,lo8(ps2buffer+21)
 638 0528 1F07      		cpc r17,r31
 639 052a 01F4      		brne .L55
 640               	.L46:
 641 052c 299A      		sbi 0x5,1
 642 052e 8091 0000 		lds r24,startUp
 643 0532 8111      		cpse r24,__zero_reg__
 644 0534 00C0      		rjmp .L56
 645 0536 8091 0000 		lds r24,ps2buffer+1
 646 053a 833F      		cpi r24,lo8(-13)
 647 053c 01F4      		brne .L42
 648               	.L56:
 649 053e 0E94 0000 		call psxStartUp
 650               	.L42:
 651 0542 8091 0000 		lds r24,ps2buffer+4
 652 0546 2FEF      		ldi r18,lo8(-1)
 653 0548 30E0      		ldi r19,0
 654 054a 281B      		sub r18,r24
 655 054c 3109      		sbc r19,__zero_reg__
 656 054e 26FD      		sbrc r18,6
 657 0550 00C0      		rjmp .L80
 658 0552 10E0      		ldi r17,0
 659 0554 00C0      		rjmp .L57
 660               	.L80:
 661 0556 12E0      		ldi r17,lo8(2)
 662               	.L57:
 663 0558 25FD      		sbrc r18,5
 664 055a 1860      		ori r17,lo8(8)
 665               	.L58:
 666 055c 27FD      		sbrc r18,7
 667 055e 1160      		ori r17,lo8(1)
 668               	.L59:
 669 0560 24FD      		sbrc r18,4
 670 0562 1460      		ori r17,lo8(4)
 671               	.L60:
 672 0564 4091 0000 		lds r20,ps2buffer+3
 673 0568 8FEF      		ldi r24,lo8(-1)
 674 056a 90E0      		ldi r25,0
 675 056c 841B      		sub r24,r20
 676 056e 9109      		sbc r25,__zero_reg__
 677 0570 80FD      		sbrc r24,0
 678 0572 1061      		ori r17,lo8(16)
 679               	.L61:
 680 0574 83FD      		sbrc r24,3
 681 0576 1062      		ori r17,lo8(32)
 682               	.L62:
 683 0578 22FD      		sbrc r18,2
 684 057a 1064      		ori r17,lo8(64)
 685               	.L63:
 686 057c 23FD      		sbrc r18,3
 687 057e 1068      		ori r17,lo8(-128)
 688               	.L64:
 689 0580 A901      		movw r20,r18
 690 0582 4170      		andi r20,1
 691 0584 5527      		clr r21
 692 0586 042F      		mov r16,r20
 693 0588 21FD      		sbrc r18,1
 694 058a 0260      		ori r16,lo8(2)
 695               	.L65:
 696 058c DC01      		movw r26,r24
 697 058e A071      		andi r26,16
 698 0590 BB27      		clr r27
 699 0592 84FD      		sbrc r24,4
 700 0594 0460      		ori r16,lo8(4)
 701               	.L66:
 702 0596 FC01      		movw r30,r24
 703 0598 E074      		andi r30,64
 704 059a FF27      		clr r31
 705 059c 86FD      		sbrc r24,6
 706 059e 0860      		ori r16,lo8(8)
 707               	.L67:
 708 05a0 BC01      		movw r22,r24
 709 05a2 6078      		andi r22,128
 710 05a4 7727      		clr r23
 711 05a6 87FD      		sbrc r24,7
 712 05a8 0061      		ori r16,lo8(16)
 713               	.L68:
 714 05aa AC01      		movw r20,r24
 715 05ac 4072      		andi r20,32
 716 05ae 5527      		clr r21
 717 05b0 85FD      		sbrc r24,5
 718 05b2 0062      		ori r16,lo8(32)
 719               	.L69:
 720 05b4 F090 0000 		lds r15,ps2buffer+5
 721 05b8 E090 0000 		lds r14,ps2buffer+6
 722 05bc 2E2D      		mov r18,r14
 723 05be 30E0      		ldi r19,0
 724 05c0 2F0D      		add r18,r15
 725 05c2 311D      		adc r19,__zero_reg__
 726 05c4 2230      		cpi r18,2
 727 05c6 3105      		cpc r19,__zero_reg__
 728 05c8 01F4      		brne .L70
 729 05ca AB2B      		or r26,r27
 730 05cc 01F0      		breq .L71
 731 05ce 1092 0000 		sts reportBuffer+5,__zero_reg__
 732               	.L71:
 733 05d2 EF2B      		or r30,r31
 734 05d4 01F0      		breq .L72
 735 05d6 8FEF      		ldi r24,lo8(-1)
 736 05d8 8093 0000 		sts reportBuffer+5,r24
 737               	.L72:
 738 05dc 672B      		or r22,r23
 739 05de 01F0      		breq .L73
 740 05e0 1092 0000 		sts reportBuffer+4,__zero_reg__
 741               	.L73:
 742 05e4 452B      		or r20,r21
 743 05e6 01F0      		breq .L74
 744 05e8 8FEF      		ldi r24,lo8(-1)
 745 05ea 8093 0000 		sts reportBuffer+4,r24
 746               	.L74:
 747 05ee 1093 0000 		sts reportBuffer+1,r17
 748 05f2 037C      		andi r16,lo8(-61)
 749 05f4 0093 0000 		sts reportBuffer+2,r16
 750 05f8 00C0      		rjmp .L29
 751               	.L70:
 752 05fa F092 0000 		sts reportBuffer+7,r15
 753 05fe E092 0000 		sts reportBuffer+8,r14
 754 0602 3091 0000 		lds r19,ps2buffer+7
 755 0606 3093 0000 		sts reportBuffer+4,r19
 756 060a 2091 0000 		lds r18,ps2buffer+8
 757 060e 2093 0000 		sts reportBuffer+5,r18
 758 0612 81FD      		sbrc r24,1
 759 0614 0064      		ori r16,lo8(64)
 760               	.L75:
 761 0616 82FD      		sbrc r24,2
 762 0618 0068      		ori r16,lo8(-128)
 763               	.L76:
 764 061a 1093 0000 		sts reportBuffer+1,r17
 765 061e 0093 0000 		sts reportBuffer+2,r16
 766 0622 E0E0      		ldi r30,lo8(ps2buffer+9)
 767 0624 F0E0      		ldi r31,hi8(ps2buffer+9)
 768 0626 A0E0      		ldi r26,lo8(psx_pressure_data)
 769 0628 B0E0      		ldi r27,hi8(psx_pressure_data)
 770               	.L78:
 771 062a 8191      		ld r24,Z+
 772 062c 8D93      		st X+,r24
 773 062e 80E0      		ldi r24,hi8(ps2buffer+21)
 774 0630 E030      		cpi r30,lo8(ps2buffer+21)
 775 0632 F807      		cpc r31,r24
 776 0634 01F4      		brne .L78
 777 0636 E091 0000 		lds r30,pressureButton1
 778 063a F0E0      		ldi r31,0
 779 063c E050      		subi r30,lo8(-(ps2buffer))
 780 063e F040      		sbci r31,hi8(-(ps2buffer))
 781 0640 8081      		ld r24,Z
 782 0642 8093 0000 		sts reportBuffer+10,r24
 783 0646 E091 0000 		lds r30,pressureButton2
 784 064a F0E0      		ldi r31,0
 785 064c E050      		subi r30,lo8(-(ps2buffer))
 786 064e F040      		sbci r31,hi8(-(ps2buffer))
 787 0650 8081      		ld r24,Z
 788 0652 8093 0000 		sts reportBuffer+11,r24
 789 0656 E091 0000 		lds r30,pressureButton3
 790 065a F0E0      		ldi r31,0
 791 065c E050      		subi r30,lo8(-(ps2buffer))
 792 065e F040      		sbci r31,hi8(-(ps2buffer))
 793 0660 8081      		ld r24,Z
 794 0662 8093 0000 		sts reportBuffer+6,r24
 795 0666 E091 0000 		lds r30,pressureButton4
 796 066a F0E0      		ldi r31,0
 797 066c E050      		subi r30,lo8(-(ps2buffer))
 798 066e F040      		sbci r31,hi8(-(ps2buffer))
 799 0670 8081      		ld r24,Z
 800 0672 8093 0000 		sts reportBuffer+9,r24
 801 0676 8091 0000 		lds r24,Negcon
 802 067a 8130      		cpi r24,lo8(1)
 803 067c 01F4      		brne .L79
 804 067e E092 0000 		sts reportBuffer+6,r14
 805 0682 3093 0000 		sts reportBuffer+9,r19
 806 0686 2093 0000 		sts reportBuffer+11,r18
 807 068a F092 0000 		sts reportBuffer+4,r15
 808 068e 80E8      		ldi r24,lo8(-128)
 809 0690 8093 0000 		sts reportBuffer+7,r24
 810 0694 8093 0000 		sts reportBuffer+5,r24
 811 0698 8093 0000 		sts reportBuffer+8,r24
 812               	.L79:
 813 069c 8CB5      		in r24,0x2c
 814 069e 8F7B      		andi r24,lo8(-65)
 815 06a0 8CBD      		out 0x2c,r24
 816               	.L29:
 817               	/* epilogue start */
 818 06a2 A296      		adiw r28,34
 819 06a4 0FB6      		in __tmp_reg__,__SREG__
 820 06a6 F894      		cli
 821 06a8 DEBF      		out __SP_H__,r29
 822 06aa 0FBE      		out __SREG__,__tmp_reg__
 823 06ac CDBF      		out __SP_L__,r28
 824 06ae DF91      		pop r29
 825 06b0 CF91      		pop r28
 826 06b2 1F91      		pop r17
 827 06b4 0F91      		pop r16
 828 06b6 FF90      		pop r15
 829 06b8 EF90      		pop r14
 830 06ba 0895      		ret
 832               	.global	psxGetGamepad
 834               	psxGetGamepad:
 835               	/* prologue: function */
 836               	/* frame size = 0 */
 837               	/* stack size = 0 */
 838               	.L__stack_usage = 0
 839 06bc 80E0      		ldi r24,lo8(PSX_Gamepad)
 840 06be 90E0      		ldi r25,hi8(PSX_Gamepad)
 841 06c0 0895      		ret
 843               	.global	PSX_Gamepad
 844               		.data
 847               	PSX_Gamepad:
 848 0000 0000      		.word	gs(Init)
 849 0002 0000      		.word	gs(Update)
 850 0004 0000      		.word	gs(Probe)
 851 0006 0000      		.word	gs(doWork)
 852 0008 0000      		.word	gs(RumbleSine)
 853 000a 0000      		.word	gs(RumbleConst)
 854               		.local	startUp
 855               		.comm	startUp,1,1
 856               		.local	Negcon
 857               		.comm	Negcon,1,1
 858               		.local	ID
 859               		.comm	ID,1,1
 862               	controllerType:
 863 000c 03        		.byte	3
 864               		.local	ps2buffer
 865               		.comm	ps2buffer,21,1
 866               		.local	activeMotorCount
 867               		.comm	activeMotorCount,1,1
 868               		.local	largeMotorDuration
 869               		.comm	largeMotorDuration,1,1
 870               		.local	smallMotorDuration
 871               		.comm	smallMotorDuration,1,1
 872               		.local	largeMotor
 873               		.comm	largeMotor,1,1
 874               		.local	smallMotor
 875               		.comm	smallMotor,1,1
 876               		.comm	stupid,1,1
 877               		.comm	_cntrl,1,1
 878               		.comm	_DoNotReport,1,1
 879               		.comm	_autoPause,1,1
 880               		.comm	_PSX,1,1
 881               		.comm	_NeedsLCDWrite,1,1
 882               		.comm	_NeedsWrite,1,1
 883               		.comm	pressureButton4,1,1
 884               		.comm	pressureButton3,1,1
 885               		.comm	pressureButton2,1,1
 886               		.comm	pressureButton1,1,1
 887               		.comm	reportBuffer,24,1
 888               		.comm	sega_buffer,9,1
 889               		.comm	psx_pressure_data,12,1
 890               		.comm	payload_return_data_size,2,1
 891               		.comm	payload_data_size,2,1
 892               		.comm	payload_data,256,1
 893               		.ident	"GCC: (AVR_8_bit_GNU_Toolchain_3.4.5_1522) 4.8.1"
 894               	.global __do_copy_data
 895               	.global __do_clear_bss
DEFINED SYMBOLS
                            *ABS*:00000000 psx.c
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:2      *ABS*:0000003e __SP_H__
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:3      *ABS*:0000003d __SP_L__
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:4      *ABS*:0000003f __SREG__
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:5      *ABS*:00000000 __tmp_reg__
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:6      *ABS*:00000001 __zero_reg__
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:9      .text:00000000 doWork
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:17     .text:00000002 Init
                            *COM*:00000001 _PSX
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:865    .bss:00000018 activeMotorCount
                            *COM*:00000001 pressureButton1
                            *COM*:00000001 pressureButton2
                            *COM*:00000001 pressureButton3
                            *COM*:00000001 pressureButton4
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:57     .text:00000050 RumbleConst
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:871    .bss:0000001b largeMotor
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:867    .bss:00000019 largeMotorDuration
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:67     .text:0000005a RumbleSine
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:873    .bss:0000001c smallMotor
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:869    .bss:0000001a smallMotorDuration
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:78     .text:00000066 spi_mSend
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:98     .text:0000007e configMode
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:146    .text:000000e0 setMotors
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:203    .text:00000156 Probe
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:857    .bss:00000002 ID
                             .bss:00000000 startUp
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:264    .text:000001cc psxStartUp
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:862    .data:0000000c controllerType
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:398    .text:0000030a Update
                            *COM*:00000001 _NeedsWrite
                            *COM*:00000002 payload_data_size
                            *COM*:00000100 payload_data
                            *COM*:00000002 payload_return_data_size
                            *COM*:00000001 _DoNotReport
                            *COM*:00000001 _autoPause
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:859    .bss:00000003 ps2buffer
                            *COM*:00000001 _cntrl
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:855    .bss:00000001 Negcon
                            *COM*:00000018 reportBuffer
                            *COM*:0000000c psx_pressure_data
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:834    .text:000006bc psxGetGamepad
C:\Users\ulao\AppData\Local\Temp\ccVbCz2B.s:847    .data:00000000 PSX_Gamepad
                            *COM*:00000001 stupid
                            *COM*:00000001 _NeedsLCDWrite
                            *COM*:00000009 sega_buffer

UNDEFINED SYMBOLS
memcpy
__do_copy_data
__do_clear_bss

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go on. It is your project. You need to compare each spi_msend function.
.
The one that you posted looks exactly as I would expect.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely the point is that you build twice. Once with and once without the "growing" function. You save the two LSS and finally you "diff" them (best if you use an intelligent diff that can ignore the opcode addresses at the start off each line). The diff result will be the code added.
.
+176 bytes for a single while() seems excessive so I suspect other forces are at play here - the diff will reveal all.

Last Edited: Sat. Jul 7, 2018 - 08:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
The one that you posted looks exactly as I would expect.

Obviously it is the other version that stinks.

S_K_U_N_X wrote:
I have a smell function for my SPI
clawson wrote:
I suspect other forces are at play here

So do I.  As shown, the delay has also changed.  [an interesting setup, having a 100+ us delay for a microsecond or two function]

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Sat. Jul 7, 2018 - 09:04 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My guess is that the 2. version just is small enough so the compiler decide to inline the function.

 

Test force it not to inline (or inline it)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:
My guess is that the 2. version just is small enough so the compiler decide to inline the function.

I didn't think of that.  Indeed a good avenue of investigation if there are a few instances.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you use _delay_us(100) elsewhere? If so, that would have been kept around and _delay_us(125) would have been added, separately, as a whole new block of code.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim you are wrong. The delays use __builtin_avr_delay_cycles()

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well this is the other LST without. I don't see spi_mSend in here? Did it go global on me? Is inline global, if so how do I force not inline. I do know how to inline a function bu not ! inline it.

   1               		.file	"psx.c"
   2               	__SP_H__ = 0x3e
   3               	__SP_L__ = 0x3d
   4               	__SREG__ = 0x3f
   5               	__tmp_reg__ = 0
   6               	__zero_reg__ = 1
   7               		.text
   9               	doWork:
  10               	/* prologue: function */
  11               	/* frame size = 0 */
  12               	/* stack size = 0 */
  13               	.L__stack_usage = 0
  14 0000 0895      		ret
  17               	Init:
  18               	/* prologue: function */
  19               	/* frame size = 0 */
  20               	/* stack size = 0 */
  21               	.L__stack_usage = 0
  22 0002 1092 0000 		sts _PSX,__zero_reg__
  23 0006 8FE2      		ldi r24,lo8(47)
  24 0008 84B9      		out 0x4,r24
  25 000a 8FEF      		ldi r24,lo8(-1)
  26 000c 85B9      		out 0x5,r24
  27 000e 8FE7      		ldi r24,lo8(127)
  28 0010 8CBD      		out 0x2c,r24
  29 0012 1092 0000 		sts activeMotorCount,__zero_reg__
  30 0016 8091 0000 		lds r24,pressureButton1
  31 001a 8111      		cpse r24,__zero_reg__
  32 001c 00C0      		rjmp .L3
  33 001e 8DE0      		ldi r24,lo8(13)
  34 0020 8093 0000 		sts pressureButton1,r24
  35               	.L3:
  36 0024 8091 0000 		lds r24,pressureButton2
  37 0028 8111      		cpse r24,__zero_reg__
  38 002a 00C0      		rjmp .L4
  39 002c 8EE0      		ldi r24,lo8(14)
  40 002e 8093 0000 		sts pressureButton2,r24
  41               	.L4:
  42 0032 8091 0000 		lds r24,pressureButton3
  43 0036 8111      		cpse r24,__zero_reg__
  44 0038 00C0      		rjmp .L5
  45 003a 83E1      		ldi r24,lo8(19)
  46 003c 8093 0000 		sts pressureButton3,r24
  47               	.L5:
  48 0040 8091 0000 		lds r24,pressureButton4
  49 0044 8111      		cpse r24,__zero_reg__
  50 0046 00C0      		rjmp .L2
  51 0048 84E1      		ldi r24,lo8(20)
  52 004a 8093 0000 		sts pressureButton4,r24
  53               	.L2:
  54 004e 0895      		ret
  57               	RumbleConst:
  58               	/* prologue: function */
  59               	/* frame size = 0 */
  60               	/* stack size = 0 */
  61               	.L__stack_usage = 0
  62 0050 8093 0000 		sts largeMotor,r24
  63 0054 6093 0000 		sts largeMotorDuration,r22
  64 0058 0895      		ret
  67               	RumbleSine:
  68               	/* prologue: function */
  69               	/* frame size = 0 */
  70               	/* stack size = 0 */
  71               	.L__stack_usage = 0
  72 005a 8FEF      		ldi r24,lo8(-1)
  73 005c 8093 0000 		sts smallMotor,r24
  74 0060 6093 0000 		sts smallMotorDuration,r22
  75 0064 0895      		ret
  78               	configMode:
  79               	/* prologue: function */
  80               	/* frame size = 0 */
  81               	/* stack size = 0 */
  82               	.L__stack_usage = 0
  83 0066 2998      		cbi 0x5,1
  84 0068 EBE2      		ldi r30,lo8(299)
  85 006a F1E0      		ldi r31,hi8(299)
  86 006c 3197      		1: sbiw r30,1
  87 006e 01F4      		brne 1b
  88 0070 00C0      		rjmp .
  89 0072 0000      		nop
  90 0074 91E0      		ldi r25,lo8(1)
  91 0076 9EBD      		out 0x2e,r25
  92 0078 EBE2      		ldi r30,lo8(299)
  93 007a F1E0      		ldi r31,hi8(299)
  94 007c 3197      		1: sbiw r30,1
  95 007e 01F4      		brne 1b
  96 0080 00C0      		rjmp .
  97 0082 0000      		nop
  98 0084 93E4      		ldi r25,lo8(67)
  99 0086 9EBD      		out 0x2e,r25
 100 0088 EBE2      		ldi r30,lo8(299)
 101 008a F1E0      		ldi r31,hi8(299)
 102 008c 3197      		1: sbiw r30,1
 103 008e 01F4      		brne 1b
 104 0090 00C0      		rjmp .
 105 0092 0000      		nop
 106 0094 1EBC      		out 0x2e,__zero_reg__
 107 0096 EBE2      		ldi r30,lo8(299)
 108 0098 F1E0      		ldi r31,hi8(299)
 109 009a 3197      		1: sbiw r30,1
 110 009c 01F4      		brne 1b
 111 009e 00C0      		rjmp .
 112 00a0 0000      		nop
 113 00a2 8EBD      		out 0x2e,r24
 114 00a4 8BE2      		ldi r24,lo8(299)
 115 00a6 91E0      		ldi r25,hi8(299)
 116 00a8 0197      		1: sbiw r24,1
 117 00aa 01F4      		brne 1b
 118 00ac 00C0      		rjmp .
 119 00ae 0000      		nop
 120 00b0 1EBC      		out 0x2e,__zero_reg__
 121 00b2 EBE2      		ldi r30,lo8(299)
 122 00b4 F1E0      		ldi r31,hi8(299)
 123 00b6 3197      		1: sbiw r30,1
 124 00b8 01F4      		brne 1b
 125 00ba 00C0      		rjmp .
 126 00bc 0000      		nop
 127 00be 1EBC      		out 0x2e,__zero_reg__
 128 00c0 8BE2      		ldi r24,lo8(299)
 129 00c2 91E0      		ldi r25,hi8(299)
 130 00c4 0197      		1: sbiw r24,1
 131 00c6 01F4      		brne 1b
 132 00c8 00C0      		rjmp .
 133 00ca 0000      		nop
 134 00cc 1EBC      		out 0x2e,__zero_reg__
 135 00ce EBE2      		ldi r30,lo8(299)
 136 00d0 F1E0      		ldi r31,hi8(299)
 137 00d2 3197      		1: sbiw r30,1
 138 00d4 01F4      		brne 1b
 139 00d6 00C0      		rjmp .
 140 00d8 0000      		nop
 141 00da 1EBC      		out 0x2e,__zero_reg__
 142 00dc 8BE2      		ldi r24,lo8(299)
 143 00de 91E0      		ldi r25,hi8(299)
 144 00e0 0197      		1: sbiw r24,1
 145 00e2 01F4      		brne 1b
 146 00e4 00C0      		rjmp .
 147 00e6 0000      		nop
 148 00e8 1EBC      		out 0x2e,__zero_reg__
 149 00ea EBE2      		ldi r30,lo8(299)
 150 00ec F1E0      		ldi r31,hi8(299)
 151 00ee 3197      		1: sbiw r30,1
 152 00f0 01F4      		brne 1b
 153 00f2 00C0      		rjmp .
 154 00f4 0000      		nop
 155 00f6 299A      		sbi 0x5,1
 156 00f8 8BE2      		ldi r24,lo8(299)
 157 00fa 91E0      		ldi r25,hi8(299)
 158 00fc 0197      		1: sbiw r24,1
 159 00fe 01F4      		brne 1b
 160 0100 00C0      		rjmp .
 161 0102 0000      		nop
 162 0104 80E0      		ldi r24,0
 163 0106 0895      		ret
 166               	setMotors:
 167               	/* prologue: function */
 168               	/* frame size = 0 */
 169               	/* stack size = 0 */
 170               	.L__stack_usage = 0
 171 0108 8091 0000 		lds r24,activeMotorCount
 172 010c 8F5F      		subi r24,lo8(-(1))
 173 010e 8093 0000 		sts activeMotorCount,r24
 174 0112 2998      		cbi 0x5,1
 175 0114 8BE2      		ldi r24,lo8(299)
 176 0116 91E0      		ldi r25,hi8(299)
 177 0118 0197      		1: sbiw r24,1
 178 011a 01F4      		brne 1b
 179 011c 00C0      		rjmp .
 180 011e 0000      		nop
 181 0120 81E0      		ldi r24,lo8(1)
 182 0122 8EBD      		out 0x2e,r24
 183 0124 8BE2      		ldi r24,lo8(299)
 184 0126 91E0      		ldi r25,hi8(299)
 185 0128 0197      		1: sbiw r24,1
 186 012a 01F4      		brne 1b
 187 012c 00C0      		rjmp .
 188 012e 0000      		nop
 189 0130 8DE4      		ldi r24,lo8(77)
 190 0132 8EBD      		out 0x2e,r24
 191 0134 8BE2      		ldi r24,lo8(299)
 192 0136 91E0      		ldi r25,hi8(299)
 193 0138 0197      		1: sbiw r24,1
 194 013a 01F4      		brne 1b
 195 013c 00C0      		rjmp .
 196 013e 0000      		nop
 197 0140 1EBC      		out 0x2e,__zero_reg__
 198 0142 8BE2      		ldi r24,lo8(299)
 199 0144 91E0      		ldi r25,hi8(299)
 200 0146 0197      		1: sbiw r24,1
 201 0148 01F4      		brne 1b
 202 014a 00C0      		rjmp .
 203 014c 0000      		nop
 204 014e 1EBC      		out 0x2e,__zero_reg__
 205 0150 8BE2      		ldi r24,lo8(299)
 206 0152 91E0      		ldi r25,hi8(299)
 207 0154 0197      		1: sbiw r24,1
 208 0156 01F4      		brne 1b
 209 0158 00C0      		rjmp .
 210 015a 0000      		nop
 211 015c 81E0      		ldi r24,lo8(1)
 212 015e 8EBD      		out 0x2e,r24
 213 0160 8BE2      		ldi r24,lo8(299)
 214 0162 91E0      		ldi r25,hi8(299)
 215 0164 0197      		1: sbiw r24,1
 216 0166 01F4      		brne 1b
 217 0168 00C0      		rjmp .
 218 016a 0000      		nop
 219 016c 8FEF      		ldi r24,lo8(-1)
 220 016e 8EBD      		out 0x2e,r24
 221 0170 8BE2      		ldi r24,lo8(299)
 222 0172 91E0      		ldi r25,hi8(299)
 223 0174 0197      		1: sbiw r24,1
 224 0176 01F4      		brne 1b
 225 0178 00C0      		rjmp .
 226 017a 0000      		nop
 227 017c 8FEF      		ldi r24,lo8(-1)
 228 017e 8EBD      		out 0x2e,r24
 229 0180 8BE2      		ldi r24,lo8(299)
 230 0182 91E0      		ldi r25,hi8(299)
 231 0184 0197      		1: sbiw r24,1
 232 0186 01F4      		brne 1b
 233 0188 00C0      		rjmp .
 234 018a 0000      		nop
 235 018c 8FEF      		ldi r24,lo8(-1)
 236 018e 8EBD      		out 0x2e,r24
 237 0190 8BE2      		ldi r24,lo8(299)
 238 0192 91E0      		ldi r25,hi8(299)
 239 0194 0197      		1: sbiw r24,1
 240 0196 01F4      		brne 1b
 241 0198 00C0      		rjmp .
 242 019a 0000      		nop
 243 019c 8FEF      		ldi r24,lo8(-1)
 244 019e 8EBD      		out 0x2e,r24
 245 01a0 8BE2      		ldi r24,lo8(299)
 246 01a2 91E0      		ldi r25,hi8(299)
 247 01a4 0197      		1: sbiw r24,1
 248 01a6 01F4      		brne 1b
 249 01a8 00C0      		rjmp .
 250 01aa 0000      		nop
 251 01ac 299A      		sbi 0x5,1
 252 01ae 8BE2      		ldi r24,lo8(299)
 253 01b0 91E0      		ldi r25,hi8(299)
 254 01b2 0197      		1: sbiw r24,1
 255 01b4 01F4      		brne 1b
 256 01b6 00C0      		rjmp .
 257 01b8 0000      		nop
 258 01ba 8FEF      		ldi r24,lo8(-1)
 259 01bc 0895      		ret
 262               	Probe:
 263               	/* prologue: function */
 264               	/* frame size = 0 */
 265               	/* stack size = 0 */
 266               	.L__stack_usage = 0
 267 01be 8AE0      		ldi r24,lo8(10)
 268 01c0 21E0      		ldi r18,lo8(1)
 269 01c2 32E4      		ldi r19,lo8(66)
 270               	.L16:
 271 01c4 2998      		cbi 0x5,1
 272 01c6 EBE2      		ldi r30,lo8(299)
 273 01c8 F1E0      		ldi r31,hi8(299)
 274 01ca 3197      		1: sbiw r30,1
 275 01cc 01F4      		brne 1b
 276 01ce 00C0      		rjmp .
 277 01d0 0000      		nop
 278 01d2 2EBD      		out 0x2e,r18
 279 01d4 EBE2      		ldi r30,lo8(299)
 280 01d6 F1E0      		ldi r31,hi8(299)
 281 01d8 3197      		1: sbiw r30,1
 282 01da 01F4      		brne 1b
 283 01dc 00C0      		rjmp .
 284 01de 0000      		nop
 285 01e0 3EBD      		out 0x2e,r19
 286 01e2 EBE2      		ldi r30,lo8(299)
 287 01e4 F1E0      		ldi r31,hi8(299)
 288 01e6 3197      		1: sbiw r30,1
 289 01e8 01F4      		brne 1b
 290 01ea 00C0      		rjmp .
 291 01ec 0000      		nop
 292 01ee 1092 0000 		sts ID,__zero_reg__
 293 01f2 1EBC      		out 0x2e,__zero_reg__
 294 01f4 EBE2      		ldi r30,lo8(299)
 295 01f6 F1E0      		ldi r31,hi8(299)
 296 01f8 3197      		1: sbiw r30,1
 297 01fa 01F4      		brne 1b
 298 01fc 00C0      		rjmp .
 299 01fe 0000      		nop
 300 0200 1EBC      		out 0x2e,__zero_reg__
 301 0202 EBE2      		ldi r30,lo8(299)
 302 0204 F1E0      		ldi r31,hi8(299)
 303 0206 3197      		1: sbiw r30,1
 304 0208 01F4      		brne 1b
 305 020a 00C0      		rjmp .
 306 020c 0000      		nop
 307 020e 1EBC      		out 0x2e,__zero_reg__
 308 0210 EBE2      		ldi r30,lo8(299)
 309 0212 F1E0      		ldi r31,hi8(299)
 310 0214 3197      		1: sbiw r30,1
 311 0216 01F4      		brne 1b
 312 0218 00C0      		rjmp .
 313 021a 0000      		nop
 314 021c 299A      		sbi 0x5,1
 315 021e EBE2      		ldi r30,lo8(299)
 316 0220 F1E0      		ldi r31,hi8(299)
 317 0222 3197      		1: sbiw r30,1
 318 0224 01F4      		brne 1b
 319 0226 00C0      		rjmp .
 320 0228 0000      		nop
 321 022a 9091 0000 		lds r25,ID
 322 022e 9150      		subi r25,lo8(-(-1))
 323 0230 9E3F      		cpi r25,lo8(-2)
 324 0232 00F4      		brsh .L13
 325 0234 81E0      		ldi r24,lo8(1)
 326 0236 8093 0000 		sts startUp,r24
 327 023a 8093 0000 		sts _PSX,r24
 328 023e 81E4      		ldi r24,lo8(65)
 329 0240 0895      		ret
 330               	.L13:
 331 0242 E7EB      		ldi r30,lo8(2999)
 332 0244 FBE0      		ldi r31,hi8(2999)
 333 0246 3197      		1: sbiw r30,1
 334 0248 01F4      		brne 1b
 335 024a 00C0      		rjmp .
 336 024c 0000      		nop
 337 024e 8150      		subi r24,lo8(-(-1))
 338 0250 01F0      		breq .+2
 339 0252 00C0      		rjmp .L16
 340 0254 8CB5      		in r24,0x2c
 341 0256 8F7B      		andi r24,lo8(-65)
 342 0258 8CBD      		out 0x2c,r24
 343 025a 80E0      		ldi r24,0
 344 025c 0895      		ret
 347               	psxStartUp:
 348               	/* prologue: function */
 349               	/* frame size = 0 */
 350               	/* stack size = 0 */
 351               	.L__stack_usage = 0
 352 025e 8CEF      		ldi r24,lo8(764)
 353 0260 92E0      		ldi r25,hi8(764)
 354 0262 0197      		1: sbiw r24,1
 355 0264 01F4      		brne 1b
 356 0266 00C0      		rjmp .
 357 0268 0000      		nop
 358 026a 81E0      		ldi r24,lo8(1)
 359 026c 0E94 0000 		call configMode
 360 0270 8093 0000 		sts ID,r24
 361 0274 2998      		cbi 0x5,1
 362 0276 8BE2      		ldi r24,lo8(299)
 363 0278 91E0      		ldi r25,hi8(299)
 364 027a 0197      		1: sbiw r24,1
 365 027c 01F4      		brne 1b
 366 027e 00C0      		rjmp .
 367 0280 0000      		nop
 368 0282 81E0      		ldi r24,lo8(1)
 369 0284 8EBD      		out 0x2e,r24
 370 0286 8BE2      		ldi r24,lo8(299)
 371 0288 91E0      		ldi r25,hi8(299)
 372 028a 0197      		1: sbiw r24,1
 373 028c 01F4      		brne 1b
 374 028e 00C0      		rjmp .
 375 0290 0000      		nop
 376 0292 85E4      		ldi r24,lo8(69)
 377 0294 8EBD      		out 0x2e,r24
 378 0296 8BE2      		ldi r24,lo8(299)
 379 0298 91E0      		ldi r25,hi8(299)
 380 029a 0197      		1: sbiw r24,1
 381 029c 01F4      		brne 1b
 382 029e 00C0      		rjmp .
 383 02a0 0000      		nop
 384 02a2 1EBC      		out 0x2e,__zero_reg__
 385 02a4 8BE2      		ldi r24,lo8(299)
 386 02a6 91E0      		ldi r25,hi8(299)
 387 02a8 0197      		1: sbiw r24,1
 388 02aa 01F4      		brne 1b
 389 02ac 00C0      		rjmp .
 390 02ae 0000      		nop
 391 02b0 8AE5      		ldi r24,lo8(90)
 392 02b2 8EBD      		out 0x2e,r24
 393 02b4 8BE2      		ldi r24,lo8(299)
 394 02b6 91E0      		ldi r25,hi8(299)
 395 02b8 0197      		1: sbiw r24,1
 396 02ba 01F4      		brne 1b
 397 02bc 00C0      		rjmp .
 398 02be 0000      		nop
 399 02c0 8AE5      		ldi r24,lo8(90)
 400 02c2 8EBD      		out 0x2e,r24
 401 02c4 8BE2      		ldi r24,lo8(299)
 402 02c6 91E0      		ldi r25,hi8(299)
 403 02c8 0197      		1: sbiw r24,1
 404 02ca 01F4      		brne 1b
 405 02cc 00C0      		rjmp .
 406 02ce 0000      		nop
 407 02d0 8AE5      		ldi r24,lo8(90)
 408 02d2 8EBD      		out 0x2e,r24
 409 02d4 8BE2      		ldi r24,lo8(299)
 410 02d6 91E0      		ldi r25,hi8(299)
 411 02d8 0197      		1: sbiw r24,1
 412 02da 01F4      		brne 1b
 413 02dc 00C0      		rjmp .
 414 02de 0000      		nop
 415 02e0 8AE5      		ldi r24,lo8(90)
 416 02e2 8EBD      		out 0x2e,r24
 417 02e4 8BE2      		ldi r24,lo8(299)
 418 02e6 91E0      		ldi r25,hi8(299)
 419 02e8 0197      		1: sbiw r24,1
 420 02ea 01F4      		brne 1b
 421 02ec 00C0      		rjmp .
 422 02ee 0000      		nop
 423 02f0 8AE5      		ldi r24,lo8(90)
 424 02f2 8EBD      		out 0x2e,r24
 425 02f4 8BE2      		ldi r24,lo8(299)
 426 02f6 91E0      		ldi r25,hi8(299)
 427 02f8 0197      		1: sbiw r24,1
 428 02fa 01F4      		brne 1b
 429 02fc 00C0      		rjmp .
 430 02fe 0000      		nop
 431 0300 8AE5      		ldi r24,lo8(90)
 432 0302 8EBD      		out 0x2e,r24
 433 0304 8BE2      		ldi r24,lo8(299)
 434 0306 91E0      		ldi r25,hi8(299)
 435 0308 0197      		1: sbiw r24,1
 436 030a 01F4      		brne 1b
 437 030c 00C0      		rjmp .
 438 030e 0000      		nop
 439 0310 299A      		sbi 0x5,1
 440 0312 8BE2      		ldi r24,lo8(299)
 441 0314 91E0      		ldi r25,hi8(299)
 442 0316 0197      		1: sbiw r24,1
 443 0318 01F4      		brne 1b
 444 031a 00C0      		rjmp .
 445 031c 0000      		nop
 446 031e 1092 0000 		sts controllerType,__zero_reg__
 447 0322 2998      		cbi 0x5,1
 448 0324 8BE2      		ldi r24,lo8(299)
 449 0326 91E0      		ldi r25,hi8(299)
 450 0328 0197      		1: sbiw r24,1
 451 032a 01F4      		brne 1b
 452 032c 00C0      		rjmp .
 453 032e 0000      		nop
 454 0330 81E0      		ldi r24,lo8(1)
 455 0332 8EBD      		out 0x2e,r24
 456 0334 8BE2      		ldi r24,lo8(299)
 457 0336 91E0      		ldi r25,hi8(299)
 458 0338 0197      		1: sbiw r24,1
 459 033a 01F4      		brne 1b
 460 033c 00C0      		rjmp .
 461 033e 0000      		nop
 462 0340 84E4      		ldi r24,lo8(68)
 463 0342 8EBD      		out 0x2e,r24
 464 0344 8BE2      		ldi r24,lo8(299)
 465 0346 91E0      		ldi r25,hi8(299)
 466 0348 0197      		1: sbiw r24,1
 467 034a 01F4      		brne 1b
 468 034c 00C0      		rjmp .
 469 034e 0000      		nop
 470 0350 1EBC      		out 0x2e,__zero_reg__
 471 0352 8BE2      		ldi r24,lo8(299)
 472 0354 91E0      		ldi r25,hi8(299)
 473 0356 0197      		1: sbiw r24,1
 474 0358 01F4      		brne 1b
 475 035a 00C0      		rjmp .
 476 035c 0000      		nop
 477 035e 81E0      		ldi r24,lo8(1)
 478 0360 8EBD      		out 0x2e,r24
 479 0362 8BE2      		ldi r24,lo8(299)
 480 0364 91E0      		ldi r25,hi8(299)
 481 0366 0197      		1: sbiw r24,1
 482 0368 01F4      		brne 1b
 483 036a 00C0      		rjmp .
 484 036c 0000      		nop
 485 036e 1EBC      		out 0x2e,__zero_reg__
 486 0370 8BE2      		ldi r24,lo8(299)
 487 0372 91E0      		ldi r25,hi8(299)
 488 0374 0197      		1: sbiw r24,1
 489 0376 01F4      		brne 1b
 490 0378 00C0      		rjmp .
 491 037a 0000      		nop
 492 037c 1EBC      		out 0x2e,__zero_reg__
 493 037e 8BE2      		ldi r24,lo8(299)
 494 0380 91E0      		ldi r25,hi8(299)
 495 0382 0197      		1: sbiw r24,1
 496 0384 01F4      		brne 1b
 497 0386 00C0      		rjmp .
 498 0388 0000      		nop
 499 038a 1EBC      		out 0x2e,__zero_reg__
 500 038c 8BE2      		ldi r24,lo8(299)
 501 038e 91E0      		ldi r25,hi8(299)
 502 0390 0197      		1: sbiw r24,1
 503 0392 01F4      		brne 1b
 504 0394 00C0      		rjmp .
 505 0396 0000      		nop
 506 0398 1EBC      		out 0x2e,__zero_reg__
 507 039a 8BE2      		ldi r24,lo8(299)
 508 039c 91E0      		ldi r25,hi8(299)
 509 039e 0197      		1: sbiw r24,1
 510 03a0 01F4      		brne 1b
 511 03a2 00C0      		rjmp .
 512 03a4 0000      		nop
 513 03a6 1EBC      		out 0x2e,__zero_reg__
 514 03a8 8BE2      		ldi r24,lo8(299)
 515 03aa 91E0      		ldi r25,hi8(299)
 516 03ac 0197      		1: sbiw r24,1
 517 03ae 01F4      		brne 1b
 518 03b0 00C0      		rjmp .
 519 03b2 0000      		nop
 520 03b4 299A      		sbi 0x5,1
 521 03b6 8BE2      		ldi r24,lo8(299)
 522 03b8 91E0      		ldi r25,hi8(299)
 523 03ba 0197      		1: sbiw r24,1
 524 03bc 01F4      		brne 1b
 525 03be 00C0      		rjmp .
 526 03c0 0000      		nop
 527 03c2 0E94 0000 		call setMotors
 528 03c6 8F3F      		cpi r24,lo8(-1)
 529 03c8 01F0      		breq .L18
 530 03ca 81E0      		ldi r24,lo8(1)
 531 03cc 8093 0000 		sts startUp,r24
 532               	.L18:
 533 03d0 0E94 0000 		call setMotors
 534 03d4 8F3F      		cpi r24,lo8(-1)
 535 03d6 01F0      		breq .L19
 536 03d8 81E0      		ldi r24,lo8(1)
 537 03da 8093 0000 		sts startUp,r24
 538 03de 00C0      		rjmp .L20
 539               	.L19:
 540 03e0 1092 0000 		sts startUp,__zero_reg__
 541               	.L20:
 542 03e4 2998      		cbi 0x5,1
 543 03e6 8BE2      		ldi r24,lo8(299)
 544 03e8 91E0      		ldi r25,hi8(299)
 545 03ea 0197      		1: sbiw r24,1
 546 03ec 01F4      		brne 1b
 547 03ee 00C0      		rjmp .
 548 03f0 0000      		nop
 549 03f2 81E0      		ldi r24,lo8(1)
 550 03f4 8EBD      		out 0x2e,r24
 551 03f6 8BE2      		ldi r24,lo8(299)
 552 03f8 91E0      		ldi r25,hi8(299)
 553 03fa 0197      		1: sbiw r24,1
 554 03fc 01F4      		brne 1b
 555 03fe 00C0      		rjmp .
 556 0400 0000      		nop
 557 0402 8FE4      		ldi r24,lo8(79)
 558 0404 8EBD      		out 0x2e,r24
 559 0406 8BE2      		ldi r24,lo8(299)
 560 0408 91E0      		ldi r25,hi8(299)
 561 040a 0197      		1: sbiw r24,1
 562 040c 01F4      		brne 1b
 563 040e 00C0      		rjmp .
 564 0410 0000      		nop
 565 0412 1EBC      		out 0x2e,__zero_reg__
 566 0414 8BE2      		ldi r24,lo8(299)
 567 0416 91E0      		ldi r25,hi8(299)
 568 0418 0197      		1: sbiw r24,1
 569 041a 01F4      		brne 1b
 570 041c 00C0      		rjmp .
 571 041e 0000      		nop
 572 0420 8FEF      		ldi r24,lo8(-1)
 573 0422 8EBD      		out 0x2e,r24
 574 0424 8BE2      		ldi r24,lo8(299)
 575 0426 91E0      		ldi r25,hi8(299)
 576 0428 0197      		1: sbiw r24,1
 577 042a 01F4      		brne 1b
 578 042c 00C0      		rjmp .
 579 042e 0000      		nop
 580 0430 8FEF      		ldi r24,lo8(-1)
 581 0432 8EBD      		out 0x2e,r24
 582 0434 8BE2      		ldi r24,lo8(299)
 583 0436 91E0      		ldi r25,hi8(299)
 584 0438 0197      		1: sbiw r24,1
 585 043a 01F4      		brne 1b
 586 043c 00C0      		rjmp .
 587 043e 0000      		nop
 588 0440 83E0      		ldi r24,lo8(3)
 589 0442 8EBD      		out 0x2e,r24
 590 0444 8BE2      		ldi r24,lo8(299)
 591 0446 91E0      		ldi r25,hi8(299)
 592 0448 0197      		1: sbiw r24,1
 593 044a 01F4      		brne 1b
 594 044c 00C0      		rjmp .
 595 044e 0000      		nop
 596 0450 1EBC      		out 0x2e,__zero_reg__
 597 0452 8BE2      		ldi r24,lo8(299)
 598 0454 91E0      		ldi r25,hi8(299)
 599 0456 0197      		1: sbiw r24,1
 600 0458 01F4      		brne 1b
 601 045a 00C0      		rjmp .
 602 045c 0000      		nop
 603 045e 1EBC      		out 0x2e,__zero_reg__
 604 0460 8BE2      		ldi r24,lo8(299)
 605 0462 91E0      		ldi r25,hi8(299)
 606 0464 0197      		1: sbiw r24,1
 607 0466 01F4      		brne 1b
 608 0468 00C0      		rjmp .
 609 046a 0000      		nop
 610 046c 1EBC      		out 0x2e,__zero_reg__
 611 046e 8BE2      		ldi r24,lo8(299)
 612 0470 91E0      		ldi r25,hi8(299)
 613 0472 0197      		1: sbiw r24,1
 614 0474 01F4      		brne 1b
 615 0476 00C0      		rjmp .
 616 0478 0000      		nop
 617 047a 299A      		sbi 0x5,1
 618 047c 8BE2      		ldi r24,lo8(299)
 619 047e 91E0      		ldi r25,hi8(299)
 620 0480 0197      		1: sbiw r24,1
 621 0482 01F4      		brne 1b
 622 0484 00C0      		rjmp .
 623 0486 0000      		nop
 624 0488 80E0      		ldi r24,0
 625 048a 0C94 0000 		jmp configMode
 628               	Update:
 629 048e EF92      		push r14
 630 0490 FF92      		push r15
 631 0492 0F93      		push r16
 632 0494 1F93      		push r17
 633 0496 CF93      		push r28
 634 0498 DF93      		push r29
 635 049a CDB7      		in r28,__SP_L__
 636 049c DEB7      		in r29,__SP_H__
 637 049e A297      		sbiw r28,34
 638 04a0 0FB6      		in __tmp_reg__,__SREG__
 639 04a2 F894      		cli
 640 04a4 DEBF      		out __SP_H__,r29
 641 04a6 0FBE      		out __SREG__,__tmp_reg__
 642 04a8 CDBF      		out __SP_L__,r28
 643               	/* prologue: function */
 644               	/* frame size = 34 */
 645               	/* stack size = 40 */
 646               	.L__stack_usage = 40
 647 04aa 2B9A      		sbi 0x5,3
 648 04ac 239A      		sbi 0x4,3
 649 04ae 8CB5      		in r24,0x2c
 650 04b0 8064      		ori r24,lo8(64)
 651 04b2 8CBD      		out 0x2c,r24
 652 04b4 8BE2      		ldi r24,lo8(299)
 653 04b6 91E0      		ldi r25,hi8(299)
 654 04b8 0197      		1: sbiw r24,1
 655 04ba 01F4      		brne 1b
 656 04bc 00C0      		rjmp .
 657 04be 0000      		nop
 658 04c0 8091 0000 		lds r24,_NeedsWrite
 659 04c4 8823      		tst r24
 660 04c6 01F0      		breq .L25
 661 04c8 2998      		cbi 0x5,1
 662 04ca EBE2      		ldi r30,lo8(299)
 663 04cc F1E0      		ldi r31,hi8(299)
 664 04ce 3197      		1: sbiw r30,1
 665 04d0 01F4      		brne 1b
 666 04d2 00C0      		rjmp .
 667 04d4 0000      		nop
 668 04d6 20E0      		ldi r18,0
 669               	.L26:
 670 04d8 4091 0000 		lds r20,payload_data_size
 671 04dc 5091 0000 		lds r21,payload_data_size+1
 672 04e0 822F      		mov r24,r18
 673 04e2 9927      		clr r25
 674 04e4 87FD      		sbrc r24,7
 675 04e6 9095      		com r25
 676 04e8 8417      		cp r24,r20
 677 04ea 9507      		cpc r25,r21
 678 04ec 00F4      		brsh .L146
 679 04ee FC01      		movw r30,r24
 680 04f0 E050      		subi r30,lo8(-(payload_data))
 681 04f2 F040      		sbci r31,hi8(-(payload_data))
 682 04f4 3081      		ld r19,Z
 683 04f6 3EBD      		out 0x2e,r19
 684 04f8 EBE2      		ldi r30,lo8(299)
 685 04fa F1E0      		ldi r31,hi8(299)
 686 04fc 3197      		1: sbiw r30,1
 687 04fe 01F4      		brne 1b
 688 0500 00C0      		rjmp .
 689 0502 0000      		nop
 690 0504 E2E0      		ldi r30,lo8(2)
 691 0506 F0E0      		ldi r31,0
 692 0508 EC0F      		add r30,r28
 693 050a FD1F      		adc r31,r29
 694 050c E80F      		add r30,r24
 695 050e F91F      		adc r31,r25
 696 0510 1082      		st Z,__zero_reg__
 697 0512 2F5F      		subi r18,lo8(-(1))
 698 0514 00C0      		rjmp .L26
 699               	.L146:
 700 0516 5093 0000 		sts payload_return_data_size+1,r21
 701 051a 4093 0000 		sts payload_return_data_size,r20
 702 051e 4983      		std Y+1,r20
 703 0520 BE01      		movw r22,r28
 704 0522 6F5F      		subi r22,-1
 705 0524 7F4F      		sbci r23,-1
 706 0526 80E0      		ldi r24,lo8(payload_data)
 707 0528 90E0      		ldi r25,hi8(payload_data)
 708 052a 0E94 0000 		call memcpy
 709 052e 1092 0000 		sts payload_data_size+1,__zero_reg__
 710 0532 1092 0000 		sts payload_data_size,__zero_reg__
 711 0536 1092 0000 		sts _NeedsWrite,__zero_reg__
 712 053a 81E0      		ldi r24,lo8(1)
 713 053c 8093 0000 		sts _DoNotReport,r24
 714 0540 299A      		sbi 0x5,1
 715 0542 00C0      		rjmp .L24
 716               	.L25:
 717 0544 8091 0000 		lds r24,controllerType
 718 0548 8430      		cpi r24,lo8(4)
 719 054a 01F4      		brne .L29
 720 054c 81E0      		ldi r24,lo8(1)
 721 054e 8093 0000 		sts _autoPause,r24
 722               	/* epilogue start */
 723 0552 A296      		adiw r28,34
 724 0554 0FB6      		in __tmp_reg__,__SREG__
 725 0556 F894      		cli
 726 0558 DEBF      		out __SP_H__,r29
 727 055a 0FBE      		out __SREG__,__tmp_reg__
 728 055c CDBF      		out __SP_L__,r28
 729 055e DF91      		pop r29
 730 0560 CF91      		pop r28
 731 0562 1F91      		pop r17
 732 0564 0F91      		pop r16
 733 0566 FF90      		pop r15
 734 0568 EF90      		pop r14
 735 056a 0C94 0000 		jmp psxStartUp
 736               	.L29:
 737 056e 2998      		cbi 0x5,1
 738 0570 8BE2      		ldi r24,lo8(299)
 739 0572 91E0      		ldi r25,hi8(299)
 740 0574 0197      		1: sbiw r24,1
 741 0576 01F4      		brne 1b
 742 0578 00C0      		rjmp .
 743 057a 0000      		nop
 744 057c 8091 0000 		lds r24,smallMotor
 745 0580 8823      		tst r24
 746 0582 01F0      		breq .L30
 747 0584 8091 0000 		lds r24,smallMotorDuration
 748 0588 9FEF      		ldi r25,lo8(-1)
 749 058a 980F      		add r25,r24
 750 058c 9E3F      		cpi r25,lo8(-2)
 751 058e 00F4      		brsh .L31
 752 0590 9093 0000 		sts smallMotorDuration,r25
 753 0594 00C0      		rjmp .L32
 754               	.L31:
 755 0596 8F3F      		cpi r24,lo8(-1)
 756 0598 01F0      		breq .L32
 757 059a 1092 0000 		sts smallMotorDuration,__zero_reg__
 758 059e 1092 0000 		sts smallMotor,__zero_reg__
 759 05a2 00C0      		rjmp .L32
 760               	.L30:
 761 05a4 1092 0000 		sts smallMotorDuration,__zero_reg__
 762               	.L32:
 763 05a8 8091 0000 		lds r24,largeMotor
 764 05ac 8823      		tst r24
 765 05ae 01F0      		breq .L33
 766 05b0 8091 0000 		lds r24,largeMotorDuration
 767 05b4 9FEF      		ldi r25,lo8(-1)
 768 05b6 980F      		add r25,r24
 769 05b8 9E3F      		cpi r25,lo8(-2)
 770 05ba 00F4      		brsh .L34
 771 05bc 9093 0000 		sts largeMotorDuration,r25
 772 05c0 00C0      		rjmp .L35
 773               	.L34:
 774 05c2 8F3F      		cpi r24,lo8(-1)
 775 05c4 01F0      		breq .L35
 776 05c6 1092 0000 		sts largeMotorDuration,__zero_reg__
 777 05ca 1092 0000 		sts largeMotor,__zero_reg__
 778 05ce 00C0      		rjmp .L35
 779               	.L33:
 780 05d0 1092 0000 		sts largeMotorDuration,__zero_reg__
 781               	.L35:
 782 05d4 81E0      		ldi r24,lo8(1)
 783 05d6 8EBD      		out 0x2e,r24
 784 05d8 EBE2      		ldi r30,lo8(299)
 785 05da F1E0      		ldi r31,hi8(299)
 786 05dc 3197      		1: sbiw r30,1
 787 05de 01F4      		brne 1b
 788 05e0 00C0      		rjmp .
 789 05e2 0000      		nop
 790 05e4 82E4      		ldi r24,lo8(66)
 791 05e6 8EBD      		out 0x2e,r24
 792 05e8 8BE2      		ldi r24,lo8(299)
 793 05ea 91E0      		ldi r25,hi8(299)
 794 05ec 0197      		1: sbiw r24,1
 795 05ee 01F4      		brne 1b
 796 05f0 00C0      		rjmp .
 797 05f2 0000      		nop
 798 05f4 1092 0000 		sts ps2buffer+1,__zero_reg__
 799 05f8 1EBC      		out 0x2e,__zero_reg__
 800 05fa EBE2      		ldi r30,lo8(299)
 801 05fc F1E0      		ldi r31,hi8(299)
 802 05fe 3197      		1: sbiw r30,1
 803 0600 01F4      		brne 1b
 804 0602 00C0      		rjmp .
 805 0604 0000      		nop
 806 0606 8091 0000 		lds r24,smallMotor
 807 060a 8EBD      		out 0x2e,r24
 808 060c 8BE2      		ldi r24,lo8(299)
 809 060e 91E0      		ldi r25,hi8(299)
 810 0610 0197      		1: sbiw r24,1
 811 0612 01F4      		brne 1b
 812 0614 00C0      		rjmp .
 813 0616 0000      		nop
 814 0618 1092 0000 		sts ps2buffer+3,__zero_reg__
 815 061c 8091 0000 		lds r24,largeMotor
 816 0620 8EBD      		out 0x2e,r24
 817 0622 EBE2      		ldi r30,lo8(299)
 818 0624 F1E0      		ldi r31,hi8(299)
 819 0626 3197      		1: sbiw r30,1
 820 0628 01F4      		brne 1b
 821 062a 00C0      		rjmp .
 822 062c 0000      		nop
 823 062e 1092 0000 		sts ps2buffer+4,__zero_reg__
 824 0632 8091 0000 		lds r24,ps2buffer+1
 825 0636 8093 0000 		sts ID,r24
 826 063a 8093 0000 		sts _cntrl,r24
 827 063e 8332      		cpi r24,lo8(35)
 828 0640 01F4      		brne .L38
 829 0642 91E0      		ldi r25,lo8(1)
 830 0644 9093 0000 		sts Negcon,r25
 831 0648 00C0      		rjmp .L39
 832               	.L38:
 833 064a 8134      		cpi r24,lo8(65)
 834 064c 01F4      		brne .L40
 835 064e 81E0      		ldi r24,lo8(1)
 836 0650 8093 0000 		sts ps2buffer+6,r24
 837 0654 8093 0000 		sts ps2buffer+5,r24
 838 0658 00C0      		rjmp .L41
 839               	.L40:
 840 065a 8337      		cpi r24,lo8(115)
 841 065c 01F4      		brne .L42
 842               	.L45:
 843 065e 1EBC      		out 0x2e,__zero_reg__
 844 0660 8BE2      		ldi r24,lo8(299)
 845 0662 91E0      		ldi r25,hi8(299)
 846 0664 0197      		1: sbiw r24,1
 847 0666 01F4      		brne 1b
 848 0668 00C0      		rjmp .
 849 066a 0000      		nop
 850 066c 1092 0000 		sts ps2buffer+5,__zero_reg__
 851 0670 1EBC      		out 0x2e,__zero_reg__
 852 0672 EBE2      		ldi r30,lo8(299)
 853 0674 F1E0      		ldi r31,hi8(299)
 854 0676 3197      		1: sbiw r30,1
 855 0678 01F4      		brne 1b
 856 067a 00C0      		rjmp .
 857 067c 0000      		nop
 858 067e 1092 0000 		sts ps2buffer+6,__zero_reg__
 859 0682 1EBC      		out 0x2e,__zero_reg__
 860 0684 8BE2      		ldi r24,lo8(299)
 861 0686 91E0      		ldi r25,hi8(299)
 862 0688 0197      		1: sbiw r24,1
 863 068a 01F4      		brne 1b
 864 068c 00C0      		rjmp .
 865 068e 0000      		nop
 866 0690 1092 0000 		sts ps2buffer+7,__zero_reg__
 867 0694 8091 0000 		lds r24,ID
 868 0698 8335      		cpi r24,lo8(83)
 869 069a 01F4      		brne .L144
 870 069c 1EBC      		out 0x2e,__zero_reg__
 871 069e EBE2      		ldi r30,lo8(299)
 872 06a0 F1E0      		ldi r31,hi8(299)
 873 06a2 3197      		1: sbiw r30,1
 874 06a4 01F4      		brne 1b
 875 06a6 00C0      		rjmp .
 876 06a8 0000      		nop
 877 06aa 8FEF      		ldi r24,lo8(-1)
 878 06ac 8093 0000 		sts ps2buffer+8,r24
 879 06b0 00C0      		rjmp .L47
 880               	.L42:
 881 06b2 982F      		mov r25,r24
 882 06b4 9D7F      		andi r25,lo8(-3)
 883 06b6 9135      		cpi r25,lo8(81)
 884 06b8 01F0      		breq .L45
 885 06ba 8F3F      		cpi r24,lo8(-1)
 886 06bc 01F0      		breq .L45
 887               	.L39:
 888 06be 9091 0000 		lds r25,Negcon
 889 06c2 9111      		cpse r25,__zero_reg__
 890 06c4 00C0      		rjmp .L45
 891 06c6 00C0      		rjmp .L147
 892               	.L144:
 893 06c8 1EBC      		out 0x2e,__zero_reg__
 894 06ca 8BE2      		ldi r24,lo8(299)
 895 06cc 91E0      		ldi r25,hi8(299)
 896 06ce 0197      		1: sbiw r24,1
 897 06d0 01F4      		brne 1b
 898 06d2 00C0      		rjmp .
 899 06d4 0000      		nop
 900 06d6 1092 0000 		sts ps2buffer+8,__zero_reg__
 901               	.L47:
 902 06da 8091 0000 		lds r24,controllerType
 903 06de 8330      		cpi r24,lo8(3)
 904 06e0 01F4      		brne .L41
 905 06e2 81E0      		ldi r24,lo8(1)
 906 06e4 8093 0000 		sts startUp,r24
 907 06e8 00C0      		rjmp .L41
 908               	.L147:
 909 06ea 8937      		cpi r24,lo8(121)
 910 06ec 01F4      		brne .L41
 911 06ee E0E0      		ldi r30,lo8(ps2buffer+5)
 912 06f0 F0E0      		ldi r31,hi8(ps2buffer+5)
 913               	.L50:
 914 06f2 1EBC      		out 0x2e,__zero_reg__
 915 06f4 8BE2      		ldi r24,lo8(299)
 916 06f6 91E0      		ldi r25,hi8(299)
 917 06f8 0197      		1: sbiw r24,1
 918 06fa 01F4      		brne 1b
 919 06fc 00C0      		rjmp .
 920 06fe 0000      		nop
 921 0700 1192      		st Z+,__zero_reg__
 922 0702 90E0      		ldi r25,hi8(ps2buffer+21)
 923 0704 E030      		cpi r30,lo8(ps2buffer+21)
 924 0706 F907      		cpc r31,r25
 925 0708 01F4      		brne .L50
 926               	.L41:
 927 070a 299A      		sbi 0x5,1
 928 070c 8091 0000 		lds r24,startUp
 929 0710 8111      		cpse r24,__zero_reg__
 930 0712 00C0      		rjmp .L51
 931 0714 8091 0000 		lds r24,ps2buffer+1
 932 0718 833F      		cpi r24,lo8(-13)
 933 071a 01F4      		brne .L37
 934               	.L51:
 935 071c 0E94 0000 		call psxStartUp
 936               	.L37:
 937 0720 8091 0000 		lds r24,ps2buffer+4
 938 0724 2FEF      		ldi r18,lo8(-1)
 939 0726 30E0      		ldi r19,0
 940 0728 281B      		sub r18,r24
 941 072a 3109      		sbc r19,__zero_reg__
 942 072c 26FD      		sbrc r18,6
 943 072e 00C0      		rjmp .L75
 944 0730 10E0      		ldi r17,0
 945 0732 00C0      		rjmp .L52
 946               	.L75:
 947 0734 12E0      		ldi r17,lo8(2)
 948               	.L52:
 949 0736 25FD      		sbrc r18,5
 950 0738 1860      		ori r17,lo8(8)
 951               	.L53:
 952 073a 27FD      		sbrc r18,7
 953 073c 1160      		ori r17,lo8(1)
 954               	.L54:
 955 073e 24FD      		sbrc r18,4
 956 0740 1460      		ori r17,lo8(4)
 957               	.L55:
 958 0742 4091 0000 		lds r20,ps2buffer+3
 959 0746 8FEF      		ldi r24,lo8(-1)
 960 0748 90E0      		ldi r25,0
 961 074a 841B      		sub r24,r20
 962 074c 9109      		sbc r25,__zero_reg__
 963 074e 80FD      		sbrc r24,0
 964 0750 1061      		ori r17,lo8(16)
 965               	.L56:
 966 0752 83FD      		sbrc r24,3
 967 0754 1062      		ori r17,lo8(32)
 968               	.L57:
 969 0756 22FD      		sbrc r18,2
 970 0758 1064      		ori r17,lo8(64)
 971               	.L58:
 972 075a 23FD      		sbrc r18,3
 973 075c 1068      		ori r17,lo8(-128)
 974               	.L59:
 975 075e A901      		movw r20,r18
 976 0760 4170      		andi r20,1
 977 0762 5527      		clr r21
 978 0764 042F      		mov r16,r20
 979 0766 21FD      		sbrc r18,1
 980 0768 0260      		ori r16,lo8(2)
 981               	.L60:
 982 076a DC01      		movw r26,r24
 983 076c A071      		andi r26,16
 984 076e BB27      		clr r27
 985 0770 84FD      		sbrc r24,4
 986 0772 0460      		ori r16,lo8(4)
 987               	.L61:
 988 0774 FC01      		movw r30,r24
 989 0776 E074      		andi r30,64
 990 0778 FF27      		clr r31
 991 077a 86FD      		sbrc r24,6
 992 077c 0860      		ori r16,lo8(8)
 993               	.L62:
 994 077e BC01      		movw r22,r24
 995 0780 6078      		andi r22,128
 996 0782 7727      		clr r23
 997 0784 87FD      		sbrc r24,7
 998 0786 0061      		ori r16,lo8(16)
 999               	.L63:
 1000 0788 AC01      		movw r20,r24
 1001 078a 4072      		andi r20,32
 1002 078c 5527      		clr r21
 1003 078e 85FD      		sbrc r24,5
 1004 0790 0062      		ori r16,lo8(32)
 1005               	.L64:
 1006 0792 F090 0000 		lds r15,ps2buffer+5
 1007 0796 E090 0000 		lds r14,ps2buffer+6
 1008 079a 2E2D      		mov r18,r14
 1009 079c 30E0      		ldi r19,0
 1010 079e 2F0D      		add r18,r15
 1011 07a0 311D      		adc r19,__zero_reg__
 1012 07a2 2230      		cpi r18,2
 1013 07a4 3105      		cpc r19,__zero_reg__
 1014 07a6 01F4      		brne .L65
 1015 07a8 AB2B      		or r26,r27
 1016 07aa 01F0      		breq .L66
 1017 07ac 1092 0000 		sts reportBuffer+5,__zero_reg__
 1018               	.L66:
 1019 07b0 EF2B      		or r30,r31
 1020 07b2 01F0      		breq .L67
 1021 07b4 8FEF      		ldi r24,lo8(-1)
 1022 07b6 8093 0000 		sts reportBuffer+5,r24
 1023               	.L67:
 1024 07ba 672B      		or r22,r23
 1025 07bc 01F0      		breq .L68
 1026 07be 1092 0000 		sts reportBuffer+4,__zero_reg__
 1027               	.L68:
 1028 07c2 452B      		or r20,r21
 1029 07c4 01F0      		breq .L69
 1030 07c6 8FEF      		ldi r24,lo8(-1)
 1031 07c8 8093 0000 		sts reportBuffer+4,r24
 1032               	.L69:
 1033 07cc 1093 0000 		sts reportBuffer+1,r17
 1034 07d0 037C      		andi r16,lo8(-61)
 1035 07d2 0093 0000 		sts reportBuffer+2,r16
 1036 07d6 00C0      		rjmp .L24
 1037               	.L65:
 1038 07d8 F092 0000 		sts reportBuffer+7,r15
 1039 07dc E092 0000 		sts reportBuffer+8,r14
 1040 07e0 3091 0000 		lds r19,ps2buffer+7
 1041 07e4 3093 0000 		sts reportBuffer+4,r19
 1042 07e8 2091 0000 		lds r18,ps2buffer+8
 1043 07ec 2093 0000 		sts reportBuffer+5,r18
 1044 07f0 81FD      		sbrc r24,1
 1045 07f2 0064      		ori r16,lo8(64)
 1046               	.L70:
 1047 07f4 82FD      		sbrc r24,2
 1048 07f6 0068      		ori r16,lo8(-128)
 1049               	.L71:
 1050 07f8 1093 0000 		sts reportBuffer+1,r17
 1051 07fc 0093 0000 		sts reportBuffer+2,r16
 1052 0800 E0E0      		ldi r30,lo8(ps2buffer+9)
 1053 0802 F0E0      		ldi r31,hi8(ps2buffer+9)
 1054 0804 A0E0      		ldi r26,lo8(psx_pressure_data)
 1055 0806 B0E0      		ldi r27,hi8(psx_pressure_data)
 1056               	.L73:
 1057 0808 8191      		ld r24,Z+
 1058 080a 8D93      		st X+,r24
 1059 080c 80E0      		ldi r24,hi8(ps2buffer+21)
 1060 080e E030      		cpi r30,lo8(ps2buffer+21)
 1061 0810 F807      		cpc r31,r24
 1062 0812 01F4      		brne .L73
 1063 0814 E091 0000 		lds r30,pressureButton1
 1064 0818 F0E0      		ldi r31,0
 1065 081a E050      		subi r30,lo8(-(ps2buffer))
 1066 081c F040      		sbci r31,hi8(-(ps2buffer))
 1067 081e 8081      		ld r24,Z
 1068 0820 8093 0000 		sts reportBuffer+10,r24
 1069 0824 E091 0000 		lds r30,pressureButton2
 1070 0828 F0E0      		ldi r31,0
 1071 082a E050      		subi r30,lo8(-(ps2buffer))
 1072 082c F040      		sbci r31,hi8(-(ps2buffer))
 1073 082e 8081      		ld r24,Z
 1074 0830 8093 0000 		sts reportBuffer+11,r24
 1075 0834 E091 0000 		lds r30,pressureButton3
 1076 0838 F0E0      		ldi r31,0
 1077 083a E050      		subi r30,lo8(-(ps2buffer))
 1078 083c F040      		sbci r31,hi8(-(ps2buffer))
 1079 083e 8081      		ld r24,Z
 1080 0840 8093 0000 		sts reportBuffer+6,r24
 1081 0844 E091 0000 		lds r30,pressureButton4
 1082 0848 F0E0      		ldi r31,0
 1083 084a E050      		subi r30,lo8(-(ps2buffer))
 1084 084c F040      		sbci r31,hi8(-(ps2buffer))
 1085 084e 8081      		ld r24,Z
 1086 0850 8093 0000 		sts reportBuffer+9,r24
 1087 0854 8091 0000 		lds r24,Negcon
 1088 0858 8130      		cpi r24,lo8(1)
 1089 085a 01F4      		brne .L74
 1090 085c E092 0000 		sts reportBuffer+6,r14
 1091 0860 3093 0000 		sts reportBuffer+9,r19
 1092 0864 2093 0000 		sts reportBuffer+11,r18
 1093 0868 F092 0000 		sts reportBuffer+4,r15
 1094 086c 80E8      		ldi r24,lo8(-128)
 1095 086e 8093 0000 		sts reportBuffer+7,r24
 1096 0872 8093 0000 		sts reportBuffer+5,r24
 1097 0876 8093 0000 		sts reportBuffer+8,r24
 1098               	.L74:
 1099 087a 8CB5      		in r24,0x2c
 1100 087c 8F7B      		andi r24,lo8(-65)
 1101 087e 8CBD      		out 0x2c,r24
 1102               	.L24:
 1103               	/* epilogue start */
 1104 0880 A296      		adiw r28,34
 1105 0882 0FB6      		in __tmp_reg__,__SREG__
 1106 0884 F894      		cli
 1107 0886 DEBF      		out __SP_H__,r29
 1108 0888 0FBE      		out __SREG__,__tmp_reg__
 1109 088a CDBF      		out __SP_L__,r28
 1110 088c DF91      		pop r29
 1111 088e CF91      		pop r28
 1112 0890 1F91      		pop r17
 1113 0892 0F91      		pop r16
 1114 0894 FF90      		pop r15
 1115 0896 EF90      		pop r14
 1116 0898 0895      		ret
 1118               	.global	psxGetGamepad
 1120               	psxGetGamepad:
 1121               	/* prologue: function */
 1122               	/* frame size = 0 */
 1123               	/* stack size = 0 */
 1124               	.L__stack_usage = 0
 1125 089a 80E0      		ldi r24,lo8(PSX_Gamepad)
 1126 089c 90E0      		ldi r25,hi8(PSX_Gamepad)
 1127 089e 0895      		ret
 1129               	.global	PSX_Gamepad
 1130               		.data
 1133               	PSX_Gamepad:
 1134 0000 0000      		.word	gs(Init)
 1135 0002 0000      		.word	gs(Update)
 1136 0004 0000      		.word	gs(Probe)
 1137 0006 0000      		.word	gs(doWork)
 1138 0008 0000      		.word	gs(RumbleSine)
 1139 000a 0000      		.word	gs(RumbleConst)
 1140               		.local	startUp
 1141               		.comm	startUp,1,1
 1142               		.local	Negcon
 1143               		.comm	Negcon,1,1
 1144               		.local	ID
 1145               		.comm	ID,1,1
 1148               	controllerType:
 1149 000c 03        		.byte	3
 1150               		.local	ps2buffer
 1151               		.comm	ps2buffer,21,1
 1152               		.local	activeMotorCount
 1153               		.comm	activeMotorCount,1,1
 1154               		.local	largeMotorDuration
 1155               		.comm	largeMotorDuration,1,1
 1156               		.local	smallMotorDuration
 1157               		.comm	smallMotorDuration,1,1
 1158               		.local	largeMotor
 1159               		.comm	largeMotor,1,1
 1160               		.local	smallMotor
 1161               		.comm	smallMotor,1,1
 1162               		.comm	stupid,1,1
 1163               		.comm	_cntrl,1,1
 1164               		.comm	_DoNotReport,1,1
 1165               		.comm	_autoPause,1,1
 1166               		.comm	_PSX,1,1
 1167               		.comm	_NeedsLCDWrite,1,1
 1168               		.comm	_NeedsWrite,1,1
 1169               		.comm	pressureButton4,1,1
 1170               		.comm	pressureButton3,1,1
 1171               		.comm	pressureButton2,1,1
 1172               		.comm	pressureButton1,1,1
 1173               		.comm	reportBuffer,24,1
 1174               		.comm	sega_buffer,9,1
 1175               		.comm	psx_pressure_data,12,1
 1176               		.comm	payload_return_data_size,2,1
 1177               		.comm	payload_data_size,2,1
 1178               		.comm	payload_data,256,1
 1179               		.ident	"GCC: (AVR_8_bit_GNU_Toolchain_3.4.5_1522) 4.8.1"
 1180               	.global __do_copy_data
 1181               	.global __do_clear_bss
DEFINED SYMBOLS
                            *ABS*:00000000 psx.c
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:2      *ABS*:0000003e __SP_H__
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:3      *ABS*:0000003d __SP_L__
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:4      *ABS*:0000003f __SREG__
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:5      *ABS*:00000000 __tmp_reg__
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:6      *ABS*:00000001 __zero_reg__
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:9      .text:00000000 doWork
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:17     .text:00000002 Init
                            *COM*:00000001 _PSX
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1151   .bss:00000018 activeMotorCount
                            *COM*:00000001 pressureButton1
                            *COM*:00000001 pressureButton2
                            *COM*:00000001 pressureButton3
                            *COM*:00000001 pressureButton4
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:57     .text:00000050 RumbleConst
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1157   .bss:0000001b largeMotor
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1153   .bss:00000019 largeMotorDuration
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:67     .text:0000005a RumbleSine
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1159   .bss:0000001c smallMotor
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1155   .bss:0000001a smallMotorDuration
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:78     .text:00000066 configMode
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:166    .text:00000108 setMotors
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:262    .text:000001be Probe
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1143   .bss:00000002 ID
                             .bss:00000000 startUp
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:347    .text:0000025e psxStartUp
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1148   .data:0000000c controllerType
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:628    .text:0000048e Update
                            *COM*:00000001 _NeedsWrite
                            *COM*:00000002 payload_data_size
                            *COM*:00000100 payload_data
                            *COM*:00000002 payload_return_data_size
                            *COM*:00000001 _DoNotReport
                            *COM*:00000001 _autoPause
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1145   .bss:00000003 ps2buffer
                            *COM*:00000001 _cntrl
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1141   .bss:00000001 Negcon
                            *COM*:00000018 reportBuffer
                            *COM*:0000000c psx_pressure_data
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1120   .text:0000089a psxGetGamepad
C:\Users\ulao\AppData\Local\Temp\cc39L7iY.s:1133   .data:00000000 PSX_Gamepad
                            *COM*:00000001 stupid
                            *COM*:00000001 _NeedsLCDWrite
                            *COM*:00000009 sega_buffer

UNDEFINED SYMBOLS
memcpy
__do_copy_data
__do_clear_bss

 

Last Edited: Sun. Jul 8, 2018 - 01:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok it is inlining it.

 

this

 

_delay_us(50);
_delay_us(50);//this is the communication frame time. You need to rest between bytes.
_delay_us(20);

 

does not make it grow.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You appear to be building without -g which makes LST/LSS files almost entirely pointless and unreadable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The OP implied that your AVR was 87% full.    The Compiler/Optimiser will be making decisions about inlining various sequences.   Your change has probably altered the decision-making.

 

Quite honestly,  there is little point in worrying over the odd _delay_us() macro.    If your App was touching 99.9% Flash you start to look at your source code.

 

I am always sailing close to the wind on Uno targets.    I need to be sure that all library examples will run out of the box on a Uno.   

Sometimes a slight rearrangement of logic will alter the Flash usage.

 

It can be difficult to see where the change has occurred.   Obviously you look at the changed statement area first.    If this does not account for it,   you have to suspect "inlining decision" effects.

 

If you are only 87% Flash,   there is no point in losing sleep over it.     Tracking inlining effects requires an intimate knowledge of your program.    Your head will hurt.    I do not want to hurt my head.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have a lot of send of the same data in a row, so perhaps make/change the function to also to take a count.

 

and you have many delay with the same length, (end up loading 299), make a function and shorten the delay a tad.

 

Add:

And as David say no panic in the 87% full range, if you have all the IO drivers etc up running it always surprises me how much functionality thant can be made form 95-100 % full

and remember opposite RAM use it's fine to use the flash 100%.

Last Edited: Sun. Jul 8, 2018 - 10:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are only 87% Flash,   there is no point in losing sleep over it.  

au contraire. In my case, The max I can do is %87.5 because of my boot-loader.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah-ha.   That makes it very important.

4kB is an awful lot for a bootloader.    Optiboot (and others) fit in 512 bytes.

Obviously a USB chip is a lot more complicated.

 

I suggest that you go through the standard checklist.   e.g.

1.  appropriate size and scope of variables

2.  avoid f-p if possible

3.  avoid big C library functions and big C++ class methods.

4.  avoid inline code

5.  appropriate size of data.   e.g. smaller fonts,  smaller images,  less resolution, ...

 

Yes,  you will find the Compiler making all sorts of decisions that you never thought of.    And it gets very critical when you are at the limit of Flash.

 

I find your SPI requirements "unusual".    But hey-ho,   make sure that there is a single function call.    The _delay_us() macros expand to trivial ASM sequence.    There are lower hanging fruits to pick before you worry about _delay_us().

 

The linker is pretty good.    You can use a C++ class with massive number of methods.    Your executable will only contain code that is actually referenced.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok to be honest there is more then the bootloader, there is this annoying bug that at this time I'm stuck with.

https://www.avrfreaks.net/forum/...

but that plus the bootloader is there and I can't undo what is done.

 

I have been optimizing code and have read these write-ups on these concepts you mention. Never saw the inline one but I now will look out for it. I'm sure there are lots of other areas I can improve on and I do over time as I learn more. The SPI code has a flow that calls the functions that call the ISP function, that call delays... so maybe there is room for improvement there.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah-ha.  You have a V-USB bootloader in a ATmega328P chip.

 

I have never used a V-USB bootloader but I am pretty sure that other people have.   So I would expect it to be fully debugged by now.    You should treat a bootloader as an independent project that must always be 100% perfect.

 

So you just have the regular problem of fitting your App into 28kB.

 

28kB is plenty enough for most project code.    As I said earlier,   big fonts or images eat up Flash.    Most logic and maths will be fine in 28kB.   Just use the regular checklist.

I would not worry about inlining.   Normally a punter is trying to persuade the Compiler to inline code.    The Compiler seldom inlines if it can not afford the space i.e. -Os

 

David.  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

LOL, no not %100 but close. I solved 2 bugs myself (and this was around 2010). Although I so pose since I reported them I fall in to the (would expect it to be fully debugged by now). but the boot loader was not written by that team and if you follow that link I mentioned, you will see it was over looked and a page bug. It is a nice project and I'm truly thankful for it but not %100...

 

However again, I see your point. I started with 8, then to 16, now on 28. The project is just one of those growing types and its about at the EOL and its time for lufa and a bigger chip.

 

Last Edited: Sun. Jul 8, 2018 - 03:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 I started with 8, then to 16, now on 28.

 

Then I guess it's time to walk a step or two back, and rewrite the code :)

 

If speed don't really matter there is many ways to make the code small, for me it seems always to be RAM I run out of first :)

 

And if everything else fail some ASM code with something like a small interpreter often can half the code size over C.   

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's been rewritten a few times now. Ram is certainly my biggest enemy. The device I created supports peripherals and converts them to USB, there are few types of these devices that use common talk (i2c, spi) but there are at least 50 proprietary protocols these device need to talk with that take up most of the space. The USB report table is one of the biggest culprits of program space but time shows me I'm the worst. Though as I learn I do review the code and make changer where possible.  I do need to convert some of my c to ASM, that is something that would help. Especially the stuff that is very sound and will not need changing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mega3208 has 4KB of SRAM and might be considered as a follow-on to mega328PB.

https://www.avrfreaks.net/forum/megaavr-0-series?page=1#comment-2496761

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are paying for silicon the $1..$2 that a PL2303/FT232/etc might cost will buy back about 3.5K of bootloader flash.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ATMEGA3208, Wow this will indeed come in handy thx!

 

I have already ordered a few ISP to usb chip and planning an add on. I also figured I may as-well go BT while I'm at it. I'll still need the boot-loader to flash my chip but I could easily remove the USP stuff in the flashed portion.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can we see source code?  And Makefile?

 

There are a lot of sequences like:

     out 0x2e,__zero_reg__
     ldi r30,lo8(299)
     ldi r31,hi8(299)
  1: sbiw r30,1
     brne 1b
     nop
     rjmp .
     nop
     ldi r24,lo8(-1)
     out 0x2e,r24
    ldi r24,lo8(299)
    ldi r25,hi8(299)
 1: sbiw r24,1
    brne 1b
    rjmp .
    nop

That are probably something like:

   motor1Port = 0;
   _delay_us(75);
    motor1Port = 0xFF;
   _delay_us(75);

 

That would end up taking a lot less code space if re-implemented as a function:

void tweakMotor1(val) {
    motor1Port = val;
    _delay_us(75);
}

tweakMotor1(0);
tweakMotor1(0xFF);

Whether or not you have to tell the compiler explicitly NOT to inline the function ... depends.  But you can, if you need to.

I have frequently been un-impressed with some of the decisions made by gcc's optimization ...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

S_K_U_N_X wrote:
I'll still need the boot-loader to flash my chip but ...
fyi for mega3208, Microchip has a UART bootloader for it with a TWI option.

That bootloader seems to be small though I only quick read its app note.

Its matching loader is written in Python for a virtual serial port on USB.

Microchip Technology Inc

Microchip Technology

Application Notes

AN2634 Bootloader for tinyAVR 0- and 1-series, and megaAVR 0-series

http://www.microchip.com//wwwAppNotes/AppNotes.aspx?appnote=en604508

via https://www.microchip.com/wwwproducts/en/ATMEGA3208

 

P.S.

S_K_U_N_X wrote:
I also figured I may as-well go BT while I'm at it.
Some of the Bluetooth chips and modules are open enough such that the megaAVR application could be ported (iow the MCU changes)

Otherwise, transparent UART seems to be a popular feature for Bluetooth Low Energy though the maximum speed varies between manufacturers.

https://www.microchip.com/wwwproducts/en/BM78 (doesn't cover the entire industrial temperature range)

 

"Dare to be naïve." - Buckminster Fuller