Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,4 +1,5 @@
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function.
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).

View file

@ -1,4 +1,5 @@
---
category:
- Functions and subroutines
- Simple
note: Basic language learning

View file

@ -0,0 +1,4 @@
multiply(a, b: INTEGER): INTEGER
do
Result := a*b
end

View file

@ -0,0 +1,2 @@
(defun multiply (x y)
(* x y))

View file

@ -0,0 +1,3 @@
(defun multiply (x y)
"Return the product of X and Y."
(* x y))

View file

@ -0,0 +1,4 @@
multiply(x,y) = x*y
# then for example
print multiply(123,456)

View file

@ -0,0 +1,3 @@
multiply: func (a: Double, b: Double) -> Double {
a * b
}

View file

@ -1,4 +1,4 @@
use signatures;
use experimental 'signatures';
sub multiply ($x, $y) {
return $x * $y;
}

View file

@ -0,0 +1,3 @@
Function Multiply(a As Integer, b As Integer) As Integer
Return a * b
End Function

View file

@ -1,2 +1,2 @@
@(do (defun mult (a b) (* a b))
(format t "3 * 4 = ~a\n" (* 3 4)))
(put-line `3 * 4 = @(mult 3 4)`))

View file

@ -1,24 +1,7 @@
section .text
global _start
_multiply_regs:
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
_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
.text
.globl multiply
.type multiply,@function
multiply:
movl 4(%esp), %eax
mull 8(%esp)
ret

View file

@ -1,7 +1,24 @@
multiply proc arg1:dword, arg2:dword
mov eax, arg1
mov ebx, arg2
section .text
global _start
_multiply_regs:
mul ebx
mov eax, ebx
ret
multiply endp
_multiply_stack:
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

View file

@ -1,5 +1,7 @@
invoke multiply, 6, 16
;or..
push 16
push 6
call multiply
multiply proc arg1:dword, arg2:dword
mov eax, arg1
mov ebx, arg2
mul ebx
mov eax, ebx
ret
multiply endp

View file

@ -0,0 +1,5 @@
invoke multiply, 6, 16
;or..
push 16
push 6
call multiply