Skip to content

Returning a struct from a function is not working as expected #6

@zu2

Description

@zu2

Returning a struct from a function is not working as expected. I thought that if the return value is 4 bytes or less, it would be returned as an int or long, but only 2 bytes are being returned.

struct complex {
    int r;
    int i;
};

struct complex sub() {
    struct complex com_1;

    com_1.r = 1234;
    com_1.i = 5678;

    return com_1;
}
_sub:
	des
	des
	des
	des
	ldab #$D2
	ldaa #$04
	jsr storetos
	ldab #$2E
	ldaa #$16
	staa $02,x
	stab $02+1,x
	ldaa $00,x
	ldab $00+1,x
L00DA:
	ins
	ins
	ins
	ins
	rts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions