Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 16, 2024, 07:13:31 19:13


Login with username, password and session length


Pages: [1]
Print
Author Topic: Conversion C18 to Proton+  (Read 5005 times)
0 Members and 1 Guest are viewing this topic.
Donovan
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 9
-Receive: 0


« on: December 22, 2010, 06:47:21 18:47 »

Hello,
I want to convert a C18 program to Proton+.

Has anyone a comparison list between C18 compiler and Proton+ compiler for data types and limits.

Type                              Size             Minimum              Maximum
char1,2                           8 bits           -128                         127
signed char                     8 bits          -128                          127
unsigned char                  8 bits            0                             255
int                                 16 bits          -32768                     32767
unsigned int                    16 bits             0                          65535
short                             16 bits           -32768                    32767
unsigned short                 16 bits             0                          65535
short long                       24 bits         -8,388,608                8,388,607
unsigned short long          24 bits              0                       16,777,215
long                              32 bits          -2,147,483,648         2,147,483,647
unsigned long                 32 bits               0                      4,294,967,295

float                              32 bits          -126 128 2–126 ≈ 1.17549435e - 38 2128 * (2-2–15) ≈ 6.80564693e + 38
double                         32 bits -126 128 2–126 ≈ 1.17549435e - 38 2128 * (2-2–15) ≈ 6.80564693e + 38

Thanks
Donovan


Logged
twonuts
Active Member
***
Offline Offline

Posts: 118

Thank You
-Given: 55
-Receive: 42


« Reply #1 on: December 28, 2010, 12:22:09 12:22 »

Hope the following helps.
Quote

From Proton manual

RAM Space Required

Each type of variable requires differing amounts of RAM memory for its allocation. The list below illustrates this.

Float Requires 4 bytes of RAM.
DWord Requires 4 bytes of RAM.
Word  Requires 2 bytes of RAM.
Byte  Requires 1 byte of RAM.
Bit Requires 1 byte of RAM for every 8 BIT variables used.
 
Each type of variable may hold a different minimum and maximum value.

FLOAT type variables may theoretically hold a value from -1e37 to +1e38, as well as fractional values, making this the most accurate of the variable family types. However, more so than dword types, this comes at a price as float calculations and comparisons will use more code space within the PICmicro. Use this type of variable sparingly, and only when strictly necessary. Smaller floating point values offer more accuracy.

DWORD type variables may hold a value from -2147483648 to +2147483647. This comes at a price however, as dword calculations and comparisons will use more code space within the PICmicro. Use this type of variable sparingly, and only when necessary.

WORD type variables may hold a value from 0 to 65535, which is usually large enough for most applications. It still uses more memory, but not nearly as much as a dword type.

BYTE type variables may hold a value for 0 to 255, and are the usual work horses of most programs. Code produced for BYTE sized variables is very low compared to word or dword types, and should be chosen if the program requires faster, or more efficient operation.

BIT type variables may hold a 0 or a 1. These are created 8 at a time, therefore declaring a single BIT type variable in a program will not save RAM space, but it will save code space, as BIT type variables produce the most efficient use of code for comparisons etc.

There are modifiers that may also be used with variables. These are HIGHBYTE, LOWBYTE, BYTE0, BYTE1, BYTE2, and BYTE3.

BYTE2, and BYTE3 may only be used in conjunction with a 32-bit dword type variable.
 
HIGHBYTE and BYTE1 are one and the same thing, when used with a word type variable, they refer to the High byte of a word type variable: -
 
 DIM WRD AS WORD    ' Declare a WORD sized variable
 DIM WRD_HI AS WRD.HIGHBYTE  ' WRD_HI now represents the HIGHBYTE of variable WRD
 
Variable WRD_HI is now accessed as a byte sized type, but any reference to it actually alters the high byte of WRD. However, if BYTE1 is used in conjunction with a dword type variable, it will extract the second byte. HIGHBYTE will still extract the high byte of the variable, as will BYTE3. The same is true of LOWBYTE and BYTE0, but they refer to the Low Byte of a word type variable: -
 
 DIM WRD AS WORD    ' Declare a WORD sized variable
 DIM WRD_LO AS WRD.LOWBYTE  ' WRD_LO now represents the LOWBYTE of variable WRD

Variable WRD_LO is now accessed as a byte sized type, but any reference to it actually alters the low byte of WRD. The modifier BYTE2 will extract the 3rd byte from a 32-bit dword type variable, as an alias. Likewise BYTE3 will extract the high byte of a 32-bit variable. RAM space for variables is allocated within the PICmicro in the order that they are placed in the BASIC code.
Logged
Donovan
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 9
-Receive: 0


« Reply #2 on: December 30, 2010, 09:45:23 09:45 »

Thank you for your help, but I'm looking for a 1:1 compare list. I have not a lot experience to do it for my self.

Donovan
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC