Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C program to find size of the processor

Status
Not open for further replies.
Is it for PC platform ?
 

If thats the case ... the program you write will be specifically for that target processor. There is no way a common program will run on 8/16/32 bit processor without any modifications.
 

My program written For ARM can execute in both 32 bit as well as 16 bit mode. Then why we call it 32 bit processor.

On what basis do we tell that the controller is 8, 16, 32,bit controller.
 

You are talking about 16-bit Thumb mode of ARM. That was designed only to improve code density but it reduces the functionality. And the Thumb code is compiled differently than 32-bit mode. So you still can't run the same piece of code on both 32-bit and 16-bit modes without re-compiling !!
So what is that you are trying to do out here ??

And talking about the basis on which you tell if its 8/16/32 bit processor, it is determined from the ALU's capacity of processing 8/16/32 bit data at a time.
 

Ya ALU is correct, Are they also dependent on data bus, internal registers, address bus, or peripherals, or any other parameter.

If i execute on keil by selecting 8 or 32 bit controllers as target ,then I Needed a ASM file at least which would tell me the size of the processor.

1. What I thought was taking the program counter count and depending on the number of jump of locations decide the size.
2. PUSH and POP of register to find the size.

In the same way is it possible to find it using a C program.

Added after 1 minutes:

Thumb code is compiled differently than 32-bit mode.

WHAT?????????????
 

ckshivaram said:
Thumb code is compiled differently than 32-bit mode.

WHAT?????????????
You need a separate compiler switch for THUMB mode. You might want to read more on this. This will clear your confusion.
 

Is it???????????????

Thanks for the information, you gave. But I worked in philips on internal core bus architecture and internal peripherals of bus timing and memory mapping and bootloader for more than 5 years and what you are telling is not true.

Please tell me which PDF file I have to read for this. I was a part of team who prepared the ARM pdf file from philips now called NXP.
And you were talking of seperate compiler, what on earth is that????

you can use keil IDE with the default compiler, it generates 16bit opcode for thumb mode.
If you include #pragma ARM and compile it generates 32 bit opcode.
Default mode of execution is thumb mode. It switches over to ARM mode when it enters any other mode. After coming out when it begins normal execution it reverts to thumb mode.

please tell me which pdf file or from which site other than NXP where you got the information you posted
I may like to enhance my knowledge.I think i am outdated i need to update. But I am still 30 years and i dont think I forget things easily.
 

Yea KEIL must be able to do that using PRAGMA directive. GCC requires "-mthumb" switch while compiling for generating thumb instructions !
I did not tell "separate compiler"... it was "separate compiler switch" i.e "-mthumb"!! I hope you know what "switch" in command line means.
And bye the way till date I haven't seen any datasheet from NXP/Philips which tells you how to compile your program. But you might want to read GCC manual.
 

HAI,

In order to find out whether the processor is 8 bit or 16bit or 32 bit or 64 bit, take two integer variables and find the difference of it.If the variables difference is 2 it is 16 bit else if difference is 4 then it is 32 bit like wise you can find out.

If any one having better idea comparatively above post in our edaboard.
 

sureshreddy said:
HAI,

In order to find out whether the processor is 8 bit or 16bit or 32 bit or 64 bit, take two integer variables and find the difference of it.If the variables difference is 2 it is 16 bit else if difference is 4 then it is 32 bit like wise you can find out.

If any one having better idea comparatively above post in our edaboard.
And what should be the values in those two integers ?
 

HAI,

The reply which I was posted previously that for how many bit complier.not for processor
The integer values is not matter in this ,but u have to take difference of that variables address, then based on that u can easily find out the compiler.

Here I am giving one example for how many bit compiler.

#include<stdio.h>
Main()
{
Int a=10,b=20,c;
C=&b-&c; // difference of address;
If(c==2)
Printf(“16 bit compiler\n”);
If(c==4);
Printf(“32 bit complier\n”);


}

Added after 4 minutes:

hai cksivaram

whether u required program for compiler or processor? reply me.

Added after 21 minutes:

Hai,


By seeing the processor pin diagram i can say whether it is a 8 bit or 16 bit.
 

In your code you are assuming that the variables will be placed at consecutive locations by the linker. Thats is not the case always ! What if in your code a is located at address 0x1000 and b at address 0x100A !! Such things happen after optimization steps are performed by the compiler.
 

HAI CMOS,

All local variables should be stored in stack segment. All that variables should store in consecutive memory locations not in random memory locations. so based on this point the program which I have written was correct for finding which compiler it is.

Another way of finding is that take one(1) and left shift it with 16 times and check it out it with 65536.if condition satisfies then it is 16 bit compiler. like wise u have to check for each compiler.
NOTE:
Low bit compiler code run in high bit compiler based on concept of back word compatibility, but high bit compiler code cannot run in low bit compiler. even though u are trying to store 32 bit value in 16 bit compiler you will get that variable value is zero.
 

sureshreddy said:
HAI CMOS,

All local variables should be stored in stack segment.
Yes it makes sense in that case.
 

A C compiler has no obligation to store automatic variables on the stack, or in consecutive order or with zero intervening bytes. Many compilers do that, but don't rely on it if you want portable code.

To determine the size of your compiler's integer, use sizeof(int)
 

For finding the size of the processor you use int, but what is the size of character for a 8 bit controller / processor. By looking at pin diagram of processor how do you find out the size.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top