Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 02:35 21 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : armcfgenV142.bas strangeness

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 10:57pm 12 Jul 2020
Copy link to clipboard 
Print this post

I'm working through the MMBasic CSub generator program presented in the CSub for the Colour Maximite 2 thread and I'm having a problem with one of the lines.

In line 275, the variable 'm' first appears. But the usage makes no sense.
275  for j=0 to m-1
276    if s$=symbols$(j,1) then
277      if k<>0 and mode then print #2,""
          'The last function didn't end with a newline so output one
278        dat$=symbols$(j,2)
279        m=instr(dat$,".")
280        dat$=left$(dat$,m-1)
281        print #2,chr$(9)+"'"+dat$
282        k=0
283      endif
284  next j

'm' also appears in lines 279 and 280.
This variable is never defined or given a value earlier so it should have the value 0. Which means the "for j = ... next j" loop will never happen.

Is it just dead code or a typo or?

Thanks for any insight.
Visit Vegipete's *Mite Library for cool programs.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3010
Posted: 12:13am 13 Jul 2020
Copy link to clipboard 
Print this post

Perhaps "m" in line 275 should be "mm" as in other loops, the number of symbols in the symbol table.

~
Edited 2020-07-13 10:14 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 12:22am 13 Jul 2020
Copy link to clipboard 
Print this post

That could well be. Higher up, on line 217, that is exactly the case.
  for j=0 to mm-1

Visit Vegipete's *Mite Library for cool programs.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 07:19am 13 Jul 2020
Copy link to clipboard 
Print this post

Thanks for the spot but as if happens this code doesn't seem to be run for the ARM compiler. For the PIC the compiler puts static data into a section .rodata, but the ARM compiler seems to leave it in .text so the code is never used. I'll fix it anyway when I post the next version of the CMM2 firmware
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024