• PicŪ Basic


  • Special high level mnemonics in Proton

    The Proton BASIC compiler contains some pseudo mnemonics that have the advantages of assembler efficiency while still maintaining a high-level feel.

    Rol
    The Rol command rotates Left through the Carry flag (STATUS.0).

    Syntax:

    Rol Variable {,Clear\Set}

    If the text Clear (or 0) is placed after the variable, the CARRY flag will be cleared before the rotate.
    If the text Set (or 1) is placed, the CARRY flag will be set before the rotate.
    However, if no text is placed after the variable, the CARRY flag is left untouched prior to the rotate.

    Code:
    Rol Var1,Clear  ' Clear the Carry flag before the rotate left
    
    Rol Var1,Set    ' Set the Carry flag before the rotate left
    
    Rol Var1        ' Do not touch the Carry flag before the rotate left
    The variable itself may be a Bit, Byte, Word, or Dword. Expressions, Arrays and Floating point variables are not supported.

    Ror
    The Ror command rotates Right through the Carry flag (STATUS.0).

    Syntax:

    Ror Variable {,Clear\Set}

    If the text Clear (or 0) is placed after the variable, the Carry flag will be cleared before the rotate.
    If the text Set (or 1) is placed, the CARRY flag will be set before the rotate.
    However, if no text is placed after the variable, the CARRY flag is left untouched prior to the rotate.

    Code:
    Ror Var1,Clear ' Clear the Carry flag before the rotate right
    
    Ror Var1,Set   ' Set the Carry flag before the rotate right
    
    Ror Var1       ' Do not touch the Carry flag before the rotate right
    The variable itself may be a Bit, Byte, Word, or Dword. Expressions, Arrays and Floating point variables are not supported.

    Djnz and others
    The Djnz command is one of several that increment or decrement a Byte variable, tests it for Zero or Carry (overflow) then jumps if zero or overflow is achieved.

    Djnz stands for Decrement and Jump if Not Zero.
    Ijnz stands for Increment and Jump if Not Zero.
    Djz stands for Decrement and Jump if Zero.
    Ijz stands for Increment and Jump if Zero.
    Djnc stands for Decrement and Jump if No Carry.
    Ijnc stands for Increment and Jump if No Carry.
    Djc stands for Decrement and Jump if Carry.
    Ijc stands for Increment and Jump if Carry.

    Syntax:

    Djnz Variable , Label

    The variable must be a Byte type.
    The label must be a valid BASIC label.

    What the above command means is: -

    Decrement Variable and Jump to Label if it has not reached Zero.

    The Carry type commands can be used to see if the variable has gone beyond 0 or over 255.

    Example:
    Code:
    Dim Var1 as Byte
    
    Var1 = 8 ' Setup for a loop of 8 cycles
    Loop:
    Djnz Var1,Loop ' Decrement Var1 until it reaches 0
    ' Continue code from here…
    The DJxx and IJxx command types will still maintain RAM bank switching, therefore some efficiency may be lost through that, however, this is unavoidable.

    Note.
    The commands outlined above offer the adventurous programmer the means of achieving a goal with maximum efficiency when used appropriately.
  • Recent Activity

    johngb-196

    UltraEdit adaption.

    Thread Starter: johngb

    I didn't know where to post this thread but as I guess this section is one of the most viewed I am posting here. After Les mentioned UltraEdit on...

    johngb Yesterday, 23:47 Go to last post
    Dave-S-350

    CWrite to a Dword Address

    Thread Starter: Dave-S

    Trying to CWrite to a Dword Address but it gets truncated. 0x16800 (dec 92160) and it writes to Address 0x6800 (dec 26624) The variable for the...

    Dave-S Yesterday, 16:26 Go to last post
    joesaliba-353

    Correct use of bit names

    Thread Starter: joesaliba

    So I have the following: - Symbol RBIF = INTCON.0 ' Port B Interrupt-On-Change (IOCx) Interrupt Flag bit Symbol INT0IF = INTCON.1 ' INT0...

    joesaliba Today, 06:27 Go to last post