diff options
Diffstat (limited to 'archive/3.transect/ex8.k2')
-rw-r--r-- | archive/3.transect/ex8.k2 | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/archive/3.transect/ex8.k2 b/archive/3.transect/ex8.k2 deleted file mode 100644 index dfef03b0..00000000 --- a/archive/3.transect/ex8.k2 +++ /dev/null @@ -1,36 +0,0 @@ -# Example reading commandline arguments: compute length of first arg. - -fn main argc : int, argv : (array (ref array char)) -> [ - var tmp : (index char) - tmp <- index 1, %size(ref array char) - var tmp2 : (address (ref array char)) - tmp2 <- advance argv, tmp - var s/EBX : (ref array char) - s/EBX <- copy *tmp2 - var result/EAX : int - result/EAX <- ascii_length s/EBX - call exit, result/EAX -] - -fn ascii_length s : (ref array char) -> result : int [ - var result/EBX : int - result/EBX <- copy 0 - { - var tmp0/EDI : (offset char) - tmp0/EDI <- index result/EBX, %size(char) - var tmp/EDX : (address char) - tmp/EDX <- advance *s, tmp0/EDI - var c/ECX : char - c/ECX <- copy *tmp - compare c/ECX, 0 - break-if-equal - loop - } - return result/EBX -] - -fn exit x : int [ - code/EBX <- copy x - code/EAX <- copy 1/exit - syscall -] |