0000104c : void send_arm_pos(struct arm_pos ap) { 104c: 1b 9a leas -6,SP 0000104e <.LM9>: int i; for(i = 0; i < 5; i++) 104e: 69 80 clr 0,SP 1050: 69 81 clr 1,SP 1052: ec 80 ldd 0,SP 1054: 8c 00 04 cpd #4 <.Ldebug_info0+0x4> 1057: 2f 02 ble 105b <.LM10> 1059: 20 44 bra 109f <.LM12> 0000105b <.LM10>: { send_servo_cmd((ap.sd[i]).servo_no, (ap.sd[i]).servo_pos); //Doesn't work. 105b: 18 02 80 82 movw 0,SP, 2,SP **** SP+2 contains value of i. 105f: cc 00 03 ldd #3 <.Ldebug_info0+0x3> 1062: ed 82 ldy 2,SP 1064: 13 emul 1065: 6c 82 std 2,SP **** SP+2 contains 3*i. 1067: b7 74 tfr SP,D 1069: c3 00 08 addd #8 <.Ldebug_info0+0x8> **** D points to beginning of array. 106c: ee 82 ldx 2,SP 106e: 1a e6 leax D,X **** D points to (array + 3*i). 1070: 6e 84 stx 4,SP **** SP+4 contains (array + 3*i). 1072: 18 02 80 82 movw 0,SP, 2,SP 1076: cc 00 03 ldd #3 <.Ldebug_info0+0x3> 1079: ed 82 ldy 2,SP 107b: 13 emul 107c: 6c 82 std 2,SP 107e: b7 74 tfr SP,D 1080: c3 00 08 addd #8 <.Ldebug_info0+0x8> 1083: e3 82 addd 2,SP 1085: b7 45 tfr D,X 1087: 08 inx **** X points to (array + 3*i + 1). 1088: 18 02 00 ae movw 0,X, 2,-SP **** Put servo_pos parameter onto stack. 108c: e6 f3 00 04 ldab [4,SP] ****** Should be ldab [6,SP] to access the servo_no parameter. 1090: 07 ad bsr 103f 1092: 1b 82 leas 2,SP 00001094 <.LM11>: 1094: ed 80 ldy 0,SP 1096: b7 64 tfr Y,D 1098: c3 00 01 addd #1 <.Ldebug_info0+0x1> 109b: 6c 80 std 0,SP 109d: 20 b3 bra 1052 <.LM9+0x4> 0000109f <.LM12>: } } 109f: 1b 86 leas 6,SP 10a1: 3d rts