MEL PICBASIC Forum - Features

• ### Recent Forum Posts

#### Re: Doing something at predefined amount of steps?

for the sign, so long as a & b are the same variable type:

if (a - b) > a then
sign = 1 ' result will be negative
else
sign = 0 ' result will be positive or zero
endif

Art Today, 05:24

#### Re: Doing something at predefined amount of steps?

No, 200-300=65436.
65435 is -101 in two's complement because 65435+101 = 65536 which, when being truncated to 16 bits is 0.

If what you want is the difference between the two numbers while not...

HenrikOlsson Yesterday, 23:01

#### Re: Doing something at predefined amount of steps?

Thanks Henrik, so Say A=200 B=300, C in this case will be 65535-100=65435, right? So if I take 65535 and minus it result, I should receive correct difference between A and B, right?

CuriousOne Yesterday, 18:46

#### Re: Doing something at predefined amount of steps?

towlerg Yesterday, 18:13

#### Re: Doing something at predefined amount of steps?

It will wrap around, 0-1=65535 provided the variable where the result is stored is a WORD.

HenrikOlsson Yesterday, 17:23

#### Re: Doing something at predefined amount of steps?

Oh and by the way, currently I don't have access to machine with PBP, what will happen if C=A-B and B is > A ? all variables are word length. I need to determine difference between A and B, but...

CuriousOne Yesterday, 16:56

#### Re: Doing something at predefined amount of steps?

Yes, I meant exactly that one.

In my case, there will be 16F886 running at 8mhz and maximum frequency will be around 2khz, so I guess, modulo variant will also work. Will assemble test circuit...

CuriousOne Yesterday, 16:54

#### Re: Doing something at predefined amount of steps?

Wasn’t it just something like this?
not even timing of course because every fifth iteration takes slightly longer to execute, but could be balanced up if it mattered.

variable var word...

Art Yesterday, 15:30

#### Re: Doing something at predefined amount of steps?

I don't know for sure but since it involves division my guess is that this is slower. Speed isn't always everything though.

Tell you what, why don't you try both ways and measure the difference,...

HenrikOlsson Yesterday, 15:01

#### Re: Doing something at predefined amount of steps?

Thanks! this is way better and simpler. Speaking speed-wise, will this be faster in execution than my code with additional variable?

CuriousOne Yesterday, 14:42
• # Features

PICBASIC PRO™ Compiler 3.0
• Familiar BASIC syntax
• IF (condition) THEN / ELSE / ELSEIF /ENDIF
• SELECT CASE
• FOR… NEXT
• DO WHILE/UNTIL
• Direct Register Access
• All Special Function Registers are pre-mapped by PBP and accessible by name
• Built-In Commands for operations common to embedded development
• Accurate Delays in uS and mS resolutions
• Analog to Digital Conversion
• Asynchronous Serial Communications (RS-232, RS-485, etc)
• Synchronous Serial including I2C and SPI
• Character LCD
• PWM
• USB
• Parsing and Formatting of ASCII Strings
• Sinusoidal Frequency Generation and DTMF (requires hardware filtering)
• Pulse-Width Measurement
• Low-Power Mode
• Conditional Compilation with Command-Line Constants
• In-Line Assembly Language
• Easy Device Configuration
• Configuration settings listed for each supported device
• New #CONFIG directive eliminates the need to edit header files
• Interrupts in BASIC or Assembly Language
• Newly revised and expanded, 300+ page reference manual.
• MPLAB/MPLABX compatible.
• Technical Support via Telephone, Email, and Community Forum (phone and email support not available for Experimenter Edition.)