• 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

    towlerg-21522

    Mysterious PORTB problem

    Thread Starter: xldaedalus

    I'm using Proton+ to develop firmware for a product with switches. The MCU is an 18F26K22. Most of the switches reside on PORTB. I am NOT using a...

    towlerg Yesterday, 15:45 Go to last post
    See_Mos-247

    PIC18F1330 PLL problem

    Thread Starter: rcurl

    I'm just starting out on a new project that uses a PIC18F1330. I haven't used this specific chip before, so I began by trying to blink an LED just...

    See_Mos Today, 11:23 Go to last post
    kuhrig-602

    Pic16f18877 oread

    Thread Starter: evoortman

    Hi, On a PIC16F18877 the OREAD command doesn't seem to work. The code is working on a PIC16F1939. Both controllers use 32MHz int osc. If i...

    kuhrig Today, 10:33 Go to last post
    palamont-28794

    MID$ Problem with a PIC18F25K22

    Thread Starter: palamont

    Hi everybody, I encounter a strange problem : I have a string of 230 characters. This string is divided into 10 segments of 23 characters, with a...

    palamont Today, 10:08 Go to last post