home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / p4_2bs.seq < prev    next >
Text File  |  1990-04-10  |  917b  |  45 lines

  1. \ Balraj Sidhu   Set: 14D4
  2. \ Comp 462 - Forth
  3. \ Date: April 10, 1990
  4. \ Problem 4.2
  5.  
  6.  
  7. : binary ( -- )
  8.         2 base ! ;
  9.  
  10. : anding ( a b -- )
  11.         and 17 .r ;
  12.  
  13. : oring ( a b -- )
  14.         or 17 .r ;
  15.  
  16. : xoring ( a b -- )
  17.         xor 17 .r ;
  18.  
  19. : noting ( a -- )
  20.         not 17 u.r ;
  21.  
  22. : table ( -- )
  23.         cr
  24.         ."       AND               OR                XOR              NOT "
  25.         cr
  26.         ." ----------------- ---------------- ---------------- ---------------- "
  27.         cr ;
  28.  
  29. : display ( a b -- )
  30.         dup 17 .r dup 17 .r dup 17 .r
  31.         swap cr
  32.         dup 17 .r dup 17 .r dup 17 .r dup 17 .r cr ;
  33.  
  34. : bottomline ( -- )
  35.         ." ----------------- ---------------- ---------------- ---------------- "
  36.         cr ;
  37.  
  38. : ltest ( a b -- )
  39.         binary table display bottomline
  40.         2dup anding 2dup oring 2dup xoring dup noting
  41.         decimal cr ;
  42.  
  43.  
  44.  
  45.