Reputation: 1548
How can a write a procedure in MASM that accepts one or more parameters and return one or more values ?
I am trying the following code,
DATA SEGMENT
DATA ENDS
;;===================================
MYPROCS SEGMENT
CONV_ROUT PROC VAL:BYTE
RET VAL
CONV_ROUT ENDP
MYPROCS ENDS
;;===================================
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
CALL FAR PTR CONV_ROUT AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
Currently, the above code gives the following error
q3.asm(7): error A2119: language type must be specified
q3.asm(9): error A2006: undefined symbol : VAL
q3.asm(19): error A2206: missing operator in expression
Upvotes: 0
Views: 2921
Reputation: 14409
You must decide which "calling convention" you take. The following example uses "stdcall". The arguments are passed on the stack and the return value is in AX. The stack will be cleared by the procedure ("callee").
.MODEL SMALL, STDCALL
DATA SEGMENT
DATA ENDS
;;===================================
MYPROCS SEGMENT
ASSUME CS:MYPROCS
CONV_ROUT PROC FAR VAL:WORD
MOV AX, VAL
RET
CONV_ROUT ENDP
MYPROCS ENDS
;;===================================
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
PUSH AX
CALL FAR PTR CONV_ROUT
MOV AX,4C00H
INT 21H
CODE ENDS
END START
I would advise you not to use far calls and far procedures, if you don't really need it.
Upvotes: 1