Shop OBEX P1 Docs P2 Docs Learn Events
Compilation Consternation — Parallax Forums

Compilation Consternation

PJAllenPJAllen BannedPosts: 5,065
edited 2007-03-28 02:44 in General Discussion
·OK, this program will Compile and Run fine, but then it bombs when I add the part in Red [noparse][[/noparse]Unable to Assemble·due to errors in source code -- "...not within 1/2 of memory page"]
· It blinks S-O-S and then a rapid burst; then I wanted to try some dimming (Intensities), by changing values of PAUSEUS (HIGH + LOW = 1000.)
· I reckon there are better ways to do this, but what's the deal with the Compilation error.· OPTIONX?· STACKX?· Fiddle-stix.
DEVICE sx28, oschs3, TURBO, OPTIONX
IRC_CAL  IRC_SLOW
FREQ     28_000_000
PROGRAM  starter
 
starter:
  TRIS_A = $0F
  RA = 0
  X        var  byte
  Y        var  byte
  Hi_Nib   var  byte
  Byt_part var  byte

Message:
  GOSUB Alpha_S
  GOSUB Alpha_O
  GOSUB Alpha_S
  PAUSE 1250
 
' Fast Blink series here:
FOR Y = 0 TO 7
 HIGH RA.3
 PAUSE 100
 LOW RA.3
 PAUSE 100
 NEXT
 
PAUSE 2000
 
[color=red]'Intensities[/color]
[color=red]FOR Hi_Nib = 0 TO 7
  FOR Byt_Part = $00 TO $FF
    HIGH RA.3
    PAUSEUS 100
    LOW RA.3
    PAUSEUS 900
    NEXT 
  NEXT[/color]
 
GOTO Message
 
Alpha_S:
  FOR X = 0 TO 2
   HIGH RA.3
   PAUSE 200
   LOW RA.3
   PAUSE 300 
   NEXT
   PAUSE 750
  RETURN 
Alpha_O:
  FOR X = 0 TO 2
   HIGH RA.3
   PAUSE 500
   LOW RA.3
   PAUSE 300 
   NEXT
   PAUSE 750
  RETURN 

Comments

  • BeanBean Posts: 8,129
    edited 2007-03-28 01:10
    You need to declare the subroutines. After you do that, you can also·get·rid of the·GOSUB too.·
    DEVICE sx28, oschs3, TURBO, OPTIONX
    IRC_CAL  IRC_SLOW
    FREQ     28_000_000
    
     
    Alpha_S  SUB
    Alpha_O  SUB
     
    PROGRAM  starter
     
    starter:
      TRIS_A = $0F
      RA = 0
      X        var  byte
      Y        var  byte
      Hi_Nib   var  byte
      Byt_part var  byte
    
    Message:
      Alpha_S
      Alpha_O
      Alpha_S
      PAUSE 1250
     
    ' Fast Blink series here:
    FOR Y = 0 TO 7
     HIGH RA.3
     PAUSE 100
     LOW RA.3
     PAUSE 100
     NEXT
     
    PAUSE 2000
     
    [color=red]'Intensities[/color]
    [color=red]FOR Hi_Nib = 0 TO 7
      FOR Byt_Part = $00 TO $FF
        HIGH RA.3
        PAUSEUS 100
        LOW RA.3
        PAUSEUS 900
        NEXT 
      NEXT[/color]
     
    GOTO Message
     
    Alpha_S:
      FOR X = 0 TO 2
       HIGH RA.3
       PAUSE 200
       LOW RA.3
       PAUSE 300 
       NEXT
       PAUSE 750
      RETURN 
    Alpha_O:
      FOR X = 0 TO 2
       HIGH RA.3
       PAUSE 500
       LOW RA.3
       PAUSE 300 
       NEXT
       PAUSE 750
      RETURN
    
    

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Educate your children to self-control, to the habit of holding passion and prejudice and evil tendencies subject to an upright and reasoning will, and you have done much to abolish misery from their future and crimes from society"

    Benjamin Franklin
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-03-28 01:39
    That straightened that out -- and now I understand "SUB" a little better.

    So, "SUB" can be either GOTO or GOSUB depending on whether the subroutine called ends with RETURN?
  • JonnyMacJonnyMac Posts: 9,298
    edited 2007-03-28 02:44
    No, SUB declare subroutines that have an RETURN at the end of them. The nice thing about declaring is that you can specify how many parameters can be passed and the compiler will check that for you. You also can get rid of GOSUB when using declared subroutines. Finally, the calling mechanism allows the subroutines to be placed anywhere in memory ( the compiler builds a jump-table for you ).

    A FUNC (function) is like a subroutine except that it will return values. Technically a SUB can return a byte, but it's usually considered better form to use FUNC when the routine will return a value.
Sign In or Register to comment.