	.text
	.globl	main

hw6_prob2:
	mov	r3, r0
	lsl	r3, r3, #3
	sub	r3, r1, r3

	cmp	r3, #5
	blt	.L1

	cmp	r0, r3
	bge	.L1
	mov	r3, r1
	asr	r3, r3, #2
	sub	r3, r0, r3
	b	exit

.L1:
	sub	r3, r3, r0
	cmp	r3, r1
	bgt	.L1

	and	r3, r3, #7

exit:
	mov	r0, r3
	mov	pc, lr


main:
        push	{ fp, lr }

	ldr	r0, =b
	ldr	r0, [r0]
	ldr	r1, =c
	ldr	r1, [r1]

        bl	hw6_prob2

	mov	r1, r0
        ldr	r0, =prtString
        bl	printf

        pop	{ fp, pc }

.section        .rodata

prtString:
        .asciz "\nresult is %d\n"

.section	.data
a:
	.word	33
b:
	.word	91
c:
	.word	-56

