argv

2023-12-31 Thread André Albergaria Coelho via Gcc

Why is the content of argv, on the stack? why not on data section?

since its on the stack..say, i have

argv[] = "HELLO WORLD";

need to push "HELL"

  push "O WO";

                push "RLD";

right? or is there any other mechanism to load the string into the stack?

sorry if this is too basic

andre

--
André Albergaria Coelho
andrealberga...@gmail.com



function parameters

2023-11-20 Thread André Albergaria Coelho via Gcc

Hello

#include 

void func(char *ptr) {
    printf("\n%i",sizeof(ptr));
}

int main(void) {
    char arr[10];
    printf("\n Sizeof arr %i",sizeof(arr));
    func(arr);

    return 0;
}

/* sizeof(arr) != sizeof(ptr), but they point to same thing. */


So problem. On main, arr has size 10, while on func, arr has size 8. But 
they are equal.



--
André Albergaria Coelho
andrealberga...@gmail.com


hey

2023-09-05 Thread André Albergaria Coelho via Gcc



This is basically if it has any interest..or else ignore...

This inverts the digits.

So 321 should be 123..not tested


We only invert the ten bases, but it can be ok for others.


A) 1*10^4 + 2*10^3 + 3*10^2 + 4*10^1 + 5 * 10^0

B) 10^4 + 10^2 + 10^0 + 10^-2 + 10^-4 Divide A) by B)


Re: abi

2023-07-09 Thread André Albergaria Coelho via Gcc

Can we debate in this mailing list?  thanks


On 7/9/23 22:04, Paul Koning wrote:

Because implementing an ABI, or dealing with an incompatibnle change, is hard 
work.



 you could just use one ABI..(that's what you have)..you can use other 
, only at a cost of specifying an ABI version


the abi is text though..so you only have to write a text file



  Also, ABI stability means that old binaries work


when you mean binaries, do you mean ELF files? executable files?



.  So ABI stability isn't so much a requirement for the compiler as it is a 
requirement for any sane operating system.


what does  a calling convention, has to do with syscalls?! and syscalls, 
and calling conventions, have to do with size and layouts?


used wikipedia definition 
..https://en.wikipedia.org/wiki/Application_binary_interface



how can the OS, have a binary interface?!!


for example:

prtinf("abc"),

asm  (say mov $123,%eax)

 binary instruction is 010110101 (for example)...how can the operating 
system know what interface to use?!



say i have 101010110101  1010101010101 , how does the O.S  works on 
binary files?! say how is the syscall used (at binary level)..it had to 
be compiled / assembled



int main() {

    write(123,_ptr,,count);

}

say write syscall is  "101010101001" in binary  ,so how does the O.S 
interfaces this ? does the O.S. separate binary numbers?!?



unless you meant ELF as "binary program"





An OS that changes ABI without an extremely good reason is an OS that 
doesn't care about compatibility, which means it doesn't care about its 
customers.






The MIPS examples I pointed to are a good illustration of this.  The original 
("O32") ABI is for MIPS with 32 bit registers and 32 bit addressing.  N32 and 
N64 were introduced by SGI to support 64 bit registers, and (for N64) 64 bit pointers.  
That's a very compelling benefit.  64 bbit addressing is obvious, and the performance 
benefit from using 64 bit registers on machines that have them is very large.  So there, 
the quite large cost of doing this was totally justified.


The benefit would be for the user...code like it wants (for example, 
return value in %ecx)..which is the ultimate reason to use compilers


and also, the benefit would be to use every ABI possible (choosing the best)



    paul


On Jul 9, 2023, at 4:55 PM, André Albergaria Coelho via Gcc  
wrote:

If we can select the ABi for our program (using gcc), why is there a need for 
ABI stability?!

why not put it on a define


#define abi v3

int main() {

}


Each user would just have to compile the code, to follow the abi...no need to 
worry changing it


thanks


andre


andre


abi

2023-07-09 Thread André Albergaria Coelho via Gcc
If we can select the ABi for our program (using gcc), why is there a 
need for ABI stability?!


why not put it on a define


#define abi v3

int main() {

}


Each user would just have to compile the code, to follow the abi...no 
need to worry changing it



thanks


andre



user sets ABI

2023-07-06 Thread André Albergaria Coelho via Gcc

What if the user chooses in own ABI, say specifying a config file like

My abi

" Parameters = pushed in stack"


say

gcc -abi "My abi" some.c -o some

what would be the problems of specifying an ABI?? would that improve the 
usage of user? less complex / more


simpler for user (say user is used to code asm in a way)


thanks

later


andre



abi

2023-07-06 Thread André Albergaria Coelho via Gcc

Could gcc have an option to specify ABI?

say


gcc something.c -g -abi 1 -o something


thanks


andre



null pointer

2023-01-07 Thread André Albergaria Coelho via Gcc
In c programming language, a NULL pointer would point to a designate 
memory location...



is this new or interessing ?!


best regards


andre



compile only

2022-10-16 Thread André Albergaria Coelho via Gcc
hey, what about not compiling functions, that arent called...and also , 
what about precompiled functions that arent changed


thanks in advance


andre