display_arith.scm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. ;;; GNU Mes --- Maxwell Equations of Software
  2. ;;; Copyright © 2016,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Mes.
  5. ;;;
  6. ;;; GNU Mes is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Mes is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>
  18. ;; Setup output file
  19. (set-current-output-port (open-output-file "test/results/test007.answer"))
  20. ;; Test -
  21. (display "Test -\n")
  22. (display (- 4 1))
  23. (display #\newline)
  24. (display (- 1 4))
  25. (display #\newline)
  26. (display (- 4 4))
  27. (display #\newline)
  28. ;; Test -
  29. (display "Test +\n")
  30. (display (+ 4 1))
  31. (display #\newline)
  32. (display (+ 1 -4))
  33. (display #\newline)
  34. (display (+ 4 4))
  35. (display #\newline)
  36. ;; Test quotient
  37. (display "Test quotient\n")
  38. (display (quotient 4 1))
  39. (display #\newline)
  40. (display (quotient 1 4))
  41. (display #\newline)
  42. (display (quotient 4 -1))
  43. (display #\newline)
  44. ;; Test Remainder
  45. (display "Test remainder\n")
  46. (display (remainder 13 4))
  47. (display #\newline)
  48. (display (remainder -13 4))
  49. (display #\newline)
  50. ;; Test modulo
  51. (display "Test modulo\n")
  52. (display (modulo 13 4))
  53. (display #\newline)
  54. (display (modulo -13 4))
  55. (display #\newline)
  56. (display (modulo 13 -4))
  57. (display #\newline)
  58. (display (modulo -13 -4))
  59. (display #\newline)
  60. ;; Test *
  61. (display "Test *\n")
  62. (display (* 2 2 2 2))
  63. (display #\newline)
  64. (display (* 1 4))
  65. (display #\newline)
  66. (display (* 4 -1))
  67. (display #\newline)
  68. ;; Test logand
  69. (display "Test logand\nUsing:")
  70. (display #x123456)
  71. (display #\newline)
  72. (display (logand #x123456 #xFF000000))
  73. (display #\newline)
  74. (display (logand #x123456 #xFF0000))
  75. (display #\newline)
  76. (display (logand #x123456 #xFF00))
  77. (display #\newline)
  78. (display (logand #x123456 #xFF))
  79. (display #\newline)
  80. (display (logand #x123456 -1))
  81. (display #\newline)
  82. ;; Test logior
  83. (display "Test logior\n")
  84. (display (logior #x0 #x0))
  85. (display #\newline)
  86. (display (logior #x0 #xFF))
  87. (display #\newline)
  88. (display (logior #xFF #x0))
  89. (display #\newline)
  90. (display (logior #xFF #xFF))
  91. (display #\newline)
  92. (display (logior #xFF00 -1))
  93. (display #\newline)
  94. ;; Test not
  95. (display "Test lognot\n")
  96. (display (lognot 1))
  97. (display #\newline)
  98. (display (lognot -1))
  99. (display #\newline)
  100. ;; Test logxor
  101. (display "Test logxor\n")
  102. (display (logxor #xFF00FF #xFF00))
  103. (display #\newline)
  104. (display (logxor #xFF00FF #xF00F0))
  105. (display #\newline)
  106. (display (logxor #xF0F0F0 #xFF00FF))
  107. (display #\newline)
  108. ;; Test ash
  109. (display "Test ash\n")
  110. (display (ash 4 1))
  111. (display #\newline)
  112. (display (ash 1 4))
  113. (display #\newline)
  114. (display (ash 4 -1))
  115. (display #\newline)
  116. (display (ash #xFF00 -8))
  117. (display #\newline)
  118. (exit 0)