• 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

    amod-29593

    Hx711 calibration

    Thread Starter: amod

    Iam using load cell amplifier HX711 module.I have got raw values from module but iam not able to calibrate with load cell.I want make a universal...

    amod Today, 15:23 Go to last post
    Oldhack-15978

    16f720

    Thread Starter: Oldhack

    HELLO The 16F720 is driving me nuts, I had SOIC version and could not get them to run at all so I bought a couple of Dips (all from Digikey) and...

    Oldhack Today, 16:00 Go to last post
    hadv215-2509

    Fault in bit wise comparisons on release 3.6.1.2.

    Thread Starter: kbaykar

    Hi Les, I just downloaded the release 3.6.1.2 today and seeing that it supports 18F47K40. I am trying to port my code from 18F4685 to 18F47K40. ...

    hadv215 Today, 16:27 Go to last post