360trev
Full Member
Karma: +68/-2
Offline
Posts: 235
|
|
« Reply #2 on: May 05, 2022, 11:00:39 AM »
|
|
|
Here's a good example of VERY POOR code optimization... And this is typical of the whole code base by the way...
/**************************************************************** Process: zwgru_10ms Purpose: sequence calls x/_10ms ****************************************************************/ ZWGRU_10ms_BasicIgnitionAngle: ; Code Reference: RHS_raster_10ms 88 90 mov [-r0], r9 88 70 mov [-r0], r7 88 60 mov [-r0], r6
if(fnwue != 0xFF) { // ignition timing #1 zwnws = gkf_ipol_S8(KFZW2, *(SRL12ZUUB), esst_snm16zuub, esst_srl12zuub); } else if(fnwue != 0x00) { // ignition timing #2 zwnws = gkf_ipol_S8(KFZW , *(SRL12ZUUB), esst_snm16zuub, esst_srl12zuub); } else {
... }
28 02 sub r0, #2
F3 F8 67 8B movb rl4, fnwue ; fnwue: Weighting factor camshaft overlap (inlet) 47 F8 FF 00 cmpb rl4, #0FFh 3D 10 jmpr cc_NZ, lookup_KFZW
E6 FC 36 1F mov r12, #KFZW2_CELLS ; KFZW2 : Znndwinkelkennfeld Variante 2 [ZWGRU] E6 FD 13 01 mov r13, #SRL12ZUUB ; number of items on Y F2 FE 64 8E mov r14, esst_snm16zuub ; x index into CURVE F2 FF 76 8E mov r15, esst_srl12zuub ; y index into CURVE DA 00 B8 78 calls 0, gkf_ipol_S8_curve F1 E8 movb rl7, rl4 F7 F8 2D 8D movb zwnws, rl4 ; zwnws : [ZWGRU] E1 0C movb rl6, #0 EA 00 56 F3 jmpa cc_UC, clamp_values ; --------------------------------------------------------------------------- lookup_KFZW: ; Code Reference: ZWGRU_10ms_BasicIgnitionAngle F3 F8 67 8B movb rl4, fnwue ; fnwue : [NWS KWPDATR MDBAS ZWGRU] 3D 0F jmpr cc_NZ, lookup_KFZW2
E6 FC 76 1E mov r12, #KFZW_CELLS ; KFZW : Znndwinkelkennfeld [ZWGRU] E6 FD 13 01 mov r13, #SRL12ZUUB F2 FE 64 8E mov r14, esst_snm16zuub ; esst_snm16zuub : [SSTB ZWGRU ZWMIN] F2 FF 76 8E mov r15, esst_srl12zuub ; esst_srl12zuub : [SSTB ZWGRU ZWMIN] DA 00 B8 78 calls 0, gkf_ipol_S8_curve F1 C8 movb rl6, rl4 F7 F8 2D 8D movb zwnws, rl4 ; zwnws : Grundznndwinkel mit Berncksichtigung von Nockenwellensteuerung [ZWGRU] E1 0E movb rl7, #0 0D 2F jmpr cc_UC, clamp_values ; --------------------------------------------------------------------------- lookup_KFZW2: ; Code Reference: ZWGRU_10ms_BasicIgnitionAngle
And how easily it could be optimized...
/**************************************************************** Process: zwgru_10ms Purpose: sequence calls x/_10ms ****************************************************************/ ZWGRU_10ms_BasicIgnitionAngle: ; Code Reference: RHS_raster_10ms 88 90 mov [-r0], r9 88 70 mov [-r0], r7 88 60 mov [-r0], r6
if(fnwue != 0xFF) { // ignition timing #1 zwnws = gkf_ipol_S8(KFZW2, *(SRL12ZUUB), esst_snm16zuub, esst_srl12zuub); } else if(fnwue != 0x00) { // ignition timing #2 zwnws = gkf_ipol_S8(KFZW , *(SRL12ZUUB), esst_snm16zuub, esst_srl12zuub); } else {
... }
28 02 sub r0, #2
E6 FC 76 1E mov r12, #KFZW_CELLS ; KFZW : [ZWGRU]
F3 F8 67 8B movb rl10, fnwue ; fnwue: Weighting factor camshaft overlap (inlet) 47 F8 FF 00 cmpb rl10, #0FFh 3D 10 jmpr cc_NZ, lookup_KFZW
E6 FC 36 1F mov r12, #KFZW2_CELLS ; KFZW2 : [ZWGRU]
E6 FD 13 01 lookup_KFZW: mov r13, #SRL12ZUUB F2 FE 64 8E mov r14, esst_snm16zuub ; esst_snm16zuub : [SSTB ZWGRU ZWMIN] F2 FF 76 8E mov r15, esst_srl12zuub ; esst_srl12zuub : [SSTB ZWGRU ZWMIN] DA 00 B8 78 calls 0, gkf_ipol_S8_curve F1 C8 movb rl6, rl4 F7 F8 2D 8D movb zwnws, rl4 ; zwnws : [ZWGRU] E1 0E movb rl7, #0
|