# Machine code Input/Output defaults

We already have a question about default I/O for general submissions. However, entries in machine code have different built-in I/O capabilities from entries in high-level languages. Should they be allowed by default to input/output differently?

In this question, consider a machine code function to be a program that includes a return or similar command. (Classifying machine code entries into programs vs. functions is a separate issue; if you disagree, respond in comments.)

The current consensus is that functions and full programs may do I/O using the same methods, but just in case that changes, I'm making a distinction. Some options for input and output (to be considered separately):

• Through any port
• Through a specified port
• In any register
• In a specified register (e.g. the accumulator)
• Using cdecl/stdcall conventions (thanks, @feersum)

I was inspired to ask this question by my answer to the Truth Machine catalog, which uses the single data bus on a Motorola MC14500 microcontroller as I/O. The OP ruled that valid, but we should have defaults for the future.

• Writing an answer as a function in x86 assembly is something I've been intending to try soon. In that case there are well-defined protocols for receiving and returning parameters (cdecl or stdcall). – feersum Nov 7 '15 at 7:10
• What do you mean by port? – Peter Taylor Nov 7 '15 at 8:09
• @PeterTaylor Port and port. – jimmy23013 Nov 7 '15 at 15:21
• Maybe we should use stack (like functions is c do) when using systems that are capable for that? – Hannes Karppila Nov 8 '15 at 20:05

That kind of functions should end with ret (or similar) statement.