Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subcall Datatypes IN v.s. IO #13

Open
vmaddur opened this issue May 7, 2020 · 1 comment
Open

Subcall Datatypes IN v.s. IO #13

vmaddur opened this issue May 7, 2020 · 1 comment

Comments

@vmaddur
Copy link

vmaddur commented May 7, 2020

Title says it all! I was wondering what the difference between "IN_16" vs "IO_16" was with respect to subcall parameters. Could you clarify this?

@dlech
Copy link
Member

dlech commented May 7, 2020

IO means the parameter is both an input (IN) parameter and an output (OUT) parameter.

Input parameters are set to the value that is passed into CALL when the subcall starts. Output parameters set the variable passed to CALL when the subcall return. So IO does both.

vmthread {
    DATA16 x
    MOVE16(5,x)
    // x has value of 5
    CALL(AddOne,x)
    // x still has value of 5
}

subcall AddOne {
    IN_16 n
    // n has value of 5
    ADD16(n,1,n)
    // n has value of 6
}
vmthread {
    DATA16 x
    MOVE16(5,x)
    // x has value of 5
    CALL(AddOne,x)
    // x has value of 1
}

subcall AddOne {
    OUT_16 n
    // n has value of 0
    ADD16(n,1,n)
    // n has value of 1
}
vmthread {
    DATA16 x
    MOVE16(5,x)
    // x has value of 5
    CALL(AddOne,x)
    // x has value of 6
}

subcall AddOne {
    IO_16 n
    // n has value of 5
    ADD16(n,1,n)
    // n has value of 6
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants