; cond_br.asm Example 2.3 ; if (X<0) X = -X Cost: .equ 125 ; define Cost=125 .org 200 ; next word will be loaded at 200 base 10 X: .dw 1 ; reserve 1 word for X .org 5000 ; Program will load at location 5000 lar r31, Over ; load address of Over ; addi r2, r0, 6 ; put 6 into r2 (false) addi r2, r0, -6 ; put -6 (true) into r2 st r2, X ; store this number ld r1, X ; r1=M[X] brpl r31, r1 ; Branch to Over if r1 >= 0 neg r1, r1 ; negate value Over: stop ; halt program