12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- # This file is part of asmc, a bootstrapping OS with minimal seed
- # Copyright (C) 2018 Giovanni Mascellani <gio@debian.org>
- # https://gitlab.com/giomasce/asmc
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
- const FROM 20
- const TO 0x64
- ifun do_sum 2
- fun main 0 {
- "The sum of numbers from " log ;
- FROM itoa log ;
- " to " log ;
- TO itoa log ;
- " is " log ;
- FROM TO do_sum itoa log ;
- "\n" log ;
- }
- fun do_sum 2 {
- $from
- $to
- @from 1 param = ;
- @to 0 param = ;
- $i
- $sum
- @i from = ;
- @sum 0 = ;
- while i to <= {
- @sum sum i + = ;
- @i i 1 + = ;
- }
- sum ret ;
- }
|