1# mach: all 2# output: 3# sim: --environment operating 4 5.include "t-macros.i" 6 7 start 8 9;; The d10v implements negated addition for subtraction 10 11 .macro check_sub s x y r c 12 ;; clear carry 13 ldi r6,#0x8004 14 mvtc r6,cr0 15 ;; subtract 16 ldi r10,#\x 17 ldi r11,#\y 18 sub r10, r11 19 ;; verify result 20 ldi r12, #\r 21 cmpeq r10, r12 22 brf0t 1f 23 ldi r6, 1 24 ldi r2, #\s 25 trap 15 261: 27 ;; verify carry 28 mvfc r6, cr0 29 and3 r6, r6, #1 30 cmpeqi r6, #\c 31 brf0t 1f 32 ldi r6, 1 33 ldi r2, #\s 34 trap 15 351: 36 .endm 37 38check_sub 1 0x0000 0x0000 0x0000 1 39check_sub 2 0x0000 0x0001 0xffff 0 40check_sub 3 0x0001 0x0000 0x0001 1 41check_sub 4 0x0001 0x0001 0x0000 1 42check_sub 5 0x0000 0x8000 0x8000 0 43check_sub 6 0x8000 0x0001 0x7fff 1 44check_sub 7 0x7fff 0x7fff 0x0000 1 45 46 exit0 47