
\ -----------------------------------------------------------------------------
\ Examples
\ -----------------------------------------------------------------------------

42 constant answertoeverything
 0 variable value

: clipto255 ( x -- b )
  movs r0 #$ff
  ands tos r0
;

: checkit ( x -- )
  clipto255 value !

  ldr= r1 value
  ldr r1 r1 #0
  movs r0 #answertoeverything
  cmp r0 r1
  bne +
    ." Value is 42"
l+:
;

see clipto255
see checkit

 42 checkit
 43 checkit

 42 256 + checkit
 43 256 + checkit


\ -----------------------------------------------------------------------------
\ Test cases
\ -----------------------------------------------------------------------------

: pp
  push { r3 r4 pc }
  pop { r0 r2 }
  ldmia r5 { r0 r2 r4 }
  stmia r5 { r0 r2 r4 }
;
see pp

hex
: a
  adcs r4 r5
  ands psp tos
  ands r1 r2
;
decimal
see a

hex
: p beq + b + cr l+: ;
: m l-: cr beq - b - ;
: n bhi p ;
see p
see m
see n
decimal

42 variable antwort

hex
: ls

  ldr r0 r2 #4
  str r4 r5 #8

  ldrh r0 r2 #4
  strh r4 r5 #8

  ldrb r0 r2 #4
  strb r4 r5 #8

  ldr r0 r2 r6
  str r4 r5 r7

  ldrh r0 r2 r6
  strh r4 r5 r7

  ldrb r0 r2 r6
  strb r4 r5 r7

  ldrsb r2 r3 r4
  ldrsh r2 r3 r4

  movs r2 r3
  movs tos #42

  cmp r2 r3
  cmp tos #43

  adds r1 r2 r3
  adds r1 r2 #5
  adds r1 #34

  subs r1 r2 r3
  subs r1 r2 #5
  subs r1 #34

  blx tos
  bl bl

  ldr= r4 $12345678
  ldr= r5 dup
  ldr= r3 antwort

  mov lr pc
  mov tos sp
  mov r13 psp

  add lr pc
  add tos sp
  add r13 psp
;

decimal
see ls

hex
: sh

  lslsr r1 r2
  lsls r1 r2 #3

  lsrsr r1 r2
  lsrs r1 r2 #3

  asrsr r1 r2
  asrs r1 r2 #3

;

decimal
see sh

