24-bit "short long"

A few years ago I mentioned on these forums that I work with a compiler on my school robotics team that has a 24-bit "short long" data type. Well, I've finally found out what compiler the software uses (it's a GUI-based programming software called EasyC V2, made by Intelitek: http://www.intelitekdownloads.com/ ).

http://imgur.com/y7rwthw
"MPLAB C18 C Compiler"

As you can see it, supports all of 8 bit, 16 bit, 24 bit, and 32 bit integral types, with "int" being 16 bits. I wonder why/how this is implemented? I don't know much about the microconctroller that the compiled HEX files are downloaded to, but for the Cortex microsontrollers we use different software (EasyC V4) that uses a GCC compiler set to target arm-none-eabi.

What do you think? A 24-bit data type along with the other 8, 16, and 32-bit types seems pretty strange.
Last edited on
For completeness? I really couldn't tell you why.
Well, let's forget the why, I'm sure there was a good reason. I just want to discuss this because it's interesting. How did they do it if the native word size is 16 bits?
closed account (zb0S216C)
Data types of any even length is perfectly fine; a structure in C++ can easily be 24-bytes in length, too. Though, "short long" is a type with an identity crisis; it's contradictory.

LB wrote:
"How did they do it if the native word size is 16 bits?"

...by reading two words from memory, concatenating the words and then discard the unused bytes.

Wazzak
Last edited on
Oh are you guys using the VEX robots? :D
@LB, can you post the ASM it generates?
It generates a HEX file, which if I open it, is actual HEX strings.

@drew88 Yes, this year we are only doing Vex. I program for over ten teams.
Last edited on
Compilers usually have an option to output assembly files. For gcc you can use the -S option.
It's not GCC, did you see the srceenshot? I'll read the manual and see if I can invoke it manually.
closed account (N36fSL3A)
I kinda want this compiler.
It comes with EasyC V2, you can download it and get a 7-day free trial of EasyC V2, but it's the compiler that you would want.
Is this HEX the raw machine code? Do you know what architecture for? If so, you could write some tiny programs (involving short long and arithmetic with it) and post HEXes for those...
@hamsterman no, it is literally just a text file with plain-text numbers in hex format, like they did std::cout << std::hex << numbers...

I'll try and see if I can compile some simple programs with it when I get to robotics club today.
Last edited on
That's awesome :D . Our school was doing a VEX club that I was going to program for, before the teachers went on strike and closed it down before we could really do anything with them T.T.

Also if its Vex then its a PIC or a Cortex-M3 architecture :O
Last edited on
Yes, I know the difference between PIC and Cortex, I often forget the PIC acronym though and just call it a microcontroller.
First attempt:
C:\Program Files\Intelitek\easyC V2 for Vex\Mcc18\bin>mcc18 -I=../h/ test.c
MPLAB C18 v2.40 (feature limited)
Copyright 1999-2004 Microchip Technology Inc.
This version of MPLAB C18 does not support the extended mode
and will not perform all optimizations.  To purchase a full
copy of MPLAB C18, please contact your local distributor or
visit buy.microchip.com.

WARNING:  This version of MPLAB C18 does not support procedural abstraction.  Pr
ocedural abstraction will not be run.

C:\Program Files\Intelitek\easyC V2 for Vex\Mcc18\bin\test.c:3:Error [1157] func
tion 'main' should be declared as 'void main (void)'
C:\Program Files\Intelitek\easyC V2 for Vex\Mcc18\bin\test.c:6:Warning [2066] ty
pe qualifier mismatch in assignment
Second attempt:
1
2
3
4
5
6
7
#include <stdio.h>

void main(void)
{
    unsigned short long test = (unsigned short long)(-1);
    printf("%ld", (long)test);
}
test.o: http://www.dropbox.com/s/pefhp4kxbiz0nua/test.o
Last edited on
Topic archived. No new replies allowed.