Can I change the return type from int to int8_t or int16_t?

I am using MIPS32 and coding in C.

Currently, many functions in my code return the data type 'int'.

Since my development is related to equipment with limited resources (even for bytes), and the return values ​​are only error codes (no more than 255), I plan to compress the return type either as int8_t or as int16_t.

What I'm trying to achieve is to reduce the caller's stack / memory usage.

Before you try, will this reduce the use of stack / memory in the caller? or

Since I heard about memory alignment (mostly like 4 bytes) and know little, will the sport look play here?

Example

int caller(){
    int8_t status;
    status = callee();

}

int8_t callee() {
    ...
    return -1;
}

, status int8_t int16_t int mips32?

+4
3

, , MIPS. https://courses.cs.washington.edu/courses/cse410/09sp/examples/MIPSCallingConventionsSummary.pdf

$31 $   .

, , , 32- 32 , .

, , MIPS? , , , . , X86, .

EDIT: , . .

$2- $3 $v0- $v1  ; 1 $v0.

, , . , MIPS 4 , . , , MIPS, , . , , , .

+2

, " 255" , uint not int.

uint_leastn_t. , , n .

uint_least8_t. , , 32- , , , , , int, .

0

MIPS32 ( , 64- int, float structs) a0 a3. , . , .

() , . , MIPS , , , , , .

, , .

, , ...

. , , . , , , , , .

-, ( ). , , . , ( ) .

-, , a0 a3, ABI , , printf ( stdarg.h va_list, va_start (), va_arg() ..). , 16 .

, , , , - , 8- 16- , - ( -) 8/16 (32 ), , , seb, seh andi. , .

, . . , (, , ABI , ). , , , .

0

Source: https://habr.com/ru/post/1613824/


All Articles