Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -1,5 +1,3 @@
|
|||
* Multiply in COBOL
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. myTest.
|
||||
DATA DIVISION.
|
||||
|
|
@ -18,7 +16,6 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. myMultiply.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
LINKAGE SECTION.
|
||||
01 x PIC 9(3).
|
||||
01 y PIC 9(3).
|
||||
26
Task/Function-definition/COBOL/function-definition-2.cobol
Normal file
26
Task/Function-definition/COBOL/function-definition-2.cobol
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. myTest.
|
||||
ENVIRONMENT DIVISION.
|
||||
CONFIGURATION SECTION.
|
||||
REPOSITORY.
|
||||
FUNCTION myMultiply.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 x PIC 9(3) VALUE 3.
|
||||
01 y PIC 9(3) VALUE 2.
|
||||
PROCEDURE DIVISION.
|
||||
DISPLAY myMultiply(x, y).
|
||||
STOP RUN.
|
||||
END PROGRAM myTest.
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
FUNCTION-ID. myMultiply.
|
||||
DATA DIVISION.
|
||||
LINKAGE SECTION.
|
||||
01 x PIC 9(3).
|
||||
01 y PIC 9(3).
|
||||
01 z pic 9(9).
|
||||
PROCEDURE DIVISION USING x, y RETURNING z.
|
||||
MULTIPLY x BY y GIVING z.
|
||||
EXIT FUNCTION.
|
||||
END FUNCTION myMultiply.
|
||||
2
Task/Function-definition/Deja-Vu/function-definition.djv
Normal file
2
Task/Function-definition/Deja-Vu/function-definition.djv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
multiply a b:
|
||||
* a b
|
||||
3
Task/Function-definition/GAP/function-definition.gap
Normal file
3
Task/Function-definition/GAP/function-definition.gap
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
multiply := function(a, b)
|
||||
return a*b;
|
||||
end;
|
||||
|
|
@ -0,0 +1 @@
|
|||
(a,b) -> a*b
|
||||
|
|
@ -1,5 +1,12 @@
|
|||
// a function definition
|
||||
var multiply = function(a,b) { a*b }
|
||||
// a function definition can be written either as
|
||||
var multiply = function(a, b) {
|
||||
a * b
|
||||
}
|
||||
|
||||
// or
|
||||
function multiply(a, b) {
|
||||
a * b
|
||||
}
|
||||
|
||||
// and calling a function
|
||||
$print( multiply(2,3) + "\n");
|
||||
$print(multiply(2,3));
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
@(do (defun mult (a b) (* a b))
|
||||
(format t "3 * 4 = ~a\n" (* 3 4)))
|
||||
(format t "3 * 4 = ~a\n" (* 3 4)))
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ multiply() {
|
|||
|
||||
# Call the function
|
||||
multiply 3 4 # The function is invoked in statement context
|
||||
echo $? # The dollarhook special variable gives the return value
|
||||
echo $? # The dollarhook special variable gives the return value
|
||||
|
|
|
|||
|
|
@ -2,23 +2,23 @@ section .text
|
|||
global _start
|
||||
|
||||
_multiply_regs:
|
||||
mul ebx
|
||||
mov eax, ebx
|
||||
ret
|
||||
mul ebx
|
||||
mov eax, ebx
|
||||
ret
|
||||
|
||||
_multiply_stack:
|
||||
enter 2,0
|
||||
mov eax, [esp+4]
|
||||
mov ebx, [esp+8]
|
||||
mul ebx
|
||||
mov eax, ebx
|
||||
leave
|
||||
ret
|
||||
enter 2,0
|
||||
mov eax, [esp+4]
|
||||
mov ebx, [esp+8]
|
||||
mul ebx
|
||||
mov eax, ebx
|
||||
leave
|
||||
ret
|
||||
|
||||
_start:
|
||||
mov ax, 6 ;The number to multiply by
|
||||
mov ebx, 16 ;base number to multiply.
|
||||
call _multiply_regs
|
||||
push 6
|
||||
push 16
|
||||
call _multiply_stack
|
||||
mov ax, 6 ;The number to multiply by
|
||||
mov ebx, 16 ;base number to multiply.
|
||||
call _multiply_regs
|
||||
push 6
|
||||
push 16
|
||||
call _multiply_stack
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
multiply proc arg1:dword, arg2:dword
|
||||
mov eax, arg1
|
||||
mov ebx, arg2
|
||||
mul ebx
|
||||
mov eax, ebx
|
||||
ret
|
||||
mov eax, arg1
|
||||
mov ebx, arg2
|
||||
mul ebx
|
||||
mov eax, ebx
|
||||
ret
|
||||
multiply endp
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
func Multiply(A, B); \the characters in parentheses are only a comment
|
||||
int A, B; \the arguments are actually declared here, as integers
|
||||
return A*B; \the default (undeclared) function type is integer
|
||||
return A*B; \the default (undeclared) function type is integer
|
||||
\no need to enclose a single statement in brackets
|
||||
|
||||
func real FloatMul(A, B); \floating point version
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue