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_sub2w s x y r c v 12 13 ;; clear carry 14 ldi r6,#0x8004 15 mvtc r6,cr0 16 17 ;; load opnds 18 ld2w r6, @(1f,r0) 19 ld2w r8, @(2f,r0) 20 .data 211: .long \x 222: .long \y 23 .text 24 25 ;; subtract 26 SUB2W r6, r8 27 28 ;; verify result 29 ld2w r10, @(1f,r0) 30 .data 311: .long \r 32 .text 33 cmpeq r6, r10 34 brf0f 2f 35 cmpeq r7, r11 36 brf0t 3f 372: ldi r4, 1 38 ldi r0, \s 39 trap 15 403: 41 42 ;; verify carry 43 mvfc r6, cr0 44 and3 r6, r6, #1 45 cmpeqi r6, #\c 46 brf0t 1f 47 ldi r4, 1 48 ldi r0, \s 49 trap 15 501: 51 .endm 52 53check_sub2w 1 0x00000000 0x00000000 0x00000000 1 0 54check_sub2w 2 0x00000000 0x00000001 0xffffffff 0 0 55check_sub2w 3 0x00000001 0x00000000 0x00000001 1 0 56check_sub2w 3 0x00000001 0x00000001 0x00000000 1 0 57check_sub2w 5 0x00000000 0x80000000 0x80000000 0 1 58check_sub2w 6 0x80000000 0x00000001 0x7fffffff 1 1 59check_sub2w 7 0x7fffffff 0x7fffffff 0x00000000 1 0 60 61 exit0 62