about summary refs log tree commit diff stats
path: root/LICENSE
Commit message (Expand)AuthorAgeFilesLines
* fixed Gottox' mail addressanselm@anselm12008-02-221-1/+1
* well typo fixAnselm R Garbe2008-02-221-1/+1
* added Gottox to Copyright holders after all his contributions, applied his la...Anselm R Garbe2008-02-221-2/+3
* changed arrange functions to contain the Monitor as first argumentAnselm R Garbe2008-02-211-1/+1
* proceeded with multihead/Xinerama supportanselm@anselm12007-12-221-0/+1
* Jukka also belongs to Copyright holders after all he has contributed and done...Anselm R. Garbe2007-05-301-0/+1
* added nsz to copyright holders as well, because he did a lot recentlyAnselm R. Garbe2007-05-291-0/+1
* added anydot to Copyright holders, because he contributed a lot recentlyAnselm R. Garbe2007-05-291-0/+1
* I used 2006 in other places as wellAnselm R. Garbe2007-04-131-1/+1
* making Copyright notices more compactAnselm R. Garbe2007-04-131-2/+2
* correctionsarg@mig292007-01-021-2/+2
* next version will contain updated copyright noticearg@mig292007-01-021-2/+2
* added Sander to LICENSE (since he has contributed/revised big portions)Anselm R.Garbe2006-08-141-0/+1
* initial importAnselm R. Garbe2006-07-101-0/+21
: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# parse a decimal int at the commandline
#
# To run:
#   $ ./translate_mu apps/parse-int.mu
#   $ ./a.elf 123
#   $ echo $?
#   123

fn main _args: (addr array addr array byte) -> _/ebx: int {
  # if no args, print a message and exit
  var args/esi: (addr array addr array byte) <- copy _args
  var n/ecx: int <- length args
  compare n, 1
  {
    break-if->
    print-string 0, "usage: parse-int <integer>\n"
    return 1
  }
  # otherwise parse the first arg as an integer
  var in/ecx: (addr addr array byte) <- index args, 1
  var out/eax: int <- parse-int *in
  return out
}

fn parse-int _in: (addr array byte) -> _/eax: int {
  var in/esi: (addr array byte) <- copy _in
  var len/edx: int <- length in
  var i/ecx: int <- copy 0
  var result/edi: int <- copy 0
  {
    compare i, len
    break-if->=
    # result *= 10
    var ten/eax: int <- copy 0xa
    result <- multiply ten
    # c = in[i]
    var tmp/ebx: (addr byte) <- index in, i
    var c/eax: byte <- copy-byte *tmp
    #
    var g/eax: grapheme <- copy c
    var digit/eax: int <- to-decimal-digit g
    result <- add digit
    i <- increment
    loop
  }
  return result
}