; written 22 Feb 2000 by Wayne Wolf
; contains first if implementation from example 2-4
; in Computers as Components, (c) 2000 Morgan Kaufman

	AREA |hand$$code|, CODE, READONLY
x1 DATA

main
; compute and test the condition
		ADR r4,a ; get address for a
		LDR r0,[r4] ; get value of a
		ADR r4,b ; get address for b
		LDR r1,[r4] ; get value of b
		CMP r0, r1 ; compare a < b
		BGE fblock; if a >= b, take branch
; the true block follows
		MOV r0,#5 ; generate value for x
		ADR r4,x ; get address for x
		STR r0,[r4] ; store value of x
		ADR r4,c ; get address for c
		LDR r0,[r4] ; get value of c
		ADR r4,d ; get address for d
		LDR r1,[r4] ; get value of d
		ADD r0,r0,r1 ; compute a+b
		ADR r4,y ; get address for y
		STR r0,[r4] ; store value of y
		B after ; branch around the false block
; the false block follows
fblock		ADR r4,c ; get address for c
		LDR r0,[r4] ; get value of c
		ADR r4,d ; get address for d
		LDR r1,[r4] ; get value of d
		SUB r0,r0,r1 ; compute a-b
		ADR r4,x ; get address for x
		STR r0,[r4] ; store value of x
after		NOP ; code after the if statement

	AREA d1, DATA

dataseg

a
        DCD      0x00000000

b
        DCD      0x00000001

c
        DCD      0x00000002

d
        DCD      0x00000003

x
        DCD      0x00000004

y
        DCD      0x00000005

        EXPORT main
        EXPORT y
        EXPORT x
        EXPORT d
        EXPORT c
        EXPORT b
        EXPORT a

        END
