vextoly/cryn

[# exchange on every scalar width: the old cell value leaves, the new
   one lands, and the type rules hold for each width #]
make string "\n" nl
make int8 c8
make uint8 u8
make int16 c16
make uint16 u16
make int32 c32
make uint32 u32
make int64 c64
make uint64 u64
make bool b
make char ch
make float32 f32
make float64 f64

define newline result nothing
  address nl
  output text
  set nothing
  return
end

define main
  [# int8 #]
  set -9
  move c8
  write
  set 47
  move c8
  exchange
  convert int64
  output
  call newline
  move c8
  read
  convert int64
  output
  call newline

  [# uint8 #]
  set 200
  move u8
  write
  set 1
  move u8
  exchange
  convert int64
  output
  call newline
  move u8
  read
  convert int64
  output
  call newline

  [# int16 #]
  set -1000
  move c16
  write
  set 1000
  move c16
  exchange
  convert int64
  output
  call newline

  [# uint16 #]
  set 60000
  move u16
  write
  set 60001
  move u16
  exchange
  convert int64
  output
  call newline

  [# int32 #]
  set -2000000000
  move c32
  write
  set 7
  move c32
  exchange
  convert int64
  output
  call newline

  [# uint32 #]
  set 4000000000
  move u32
  write
  set 8
  move u32
  exchange
  convert int64
  output
  call newline

  [# int64 #]
  set -5000000000
  move c64
  write
  set 5000000000
  move c64
  exchange
  output
  call newline

  [# uint64 #]
  set 18000000000000000000
  move u64
  write
  set 2
  move u64
  exchange
  output
  call newline

  [# bool #]
  set false
  move b
  write
  set true
  move b
  exchange
  output
  call newline
  move b
  read
  output
  call newline

  [# char #]
  set 'Q'
  move ch
  write
  set 'Z'
  move ch
  exchange
  output
  call newline

  [# float32 #]
  set 1.5
  move f32
  write
  set 2.75
  move f32
  exchange
  output
  call newline
  move f32
  read
  output
  call newline

  [# float64 #]
  set 0.125
  move f64
  write
  set 6.5
  move f64
  exchange
  output
  call newline

  set nothing
  return
end