*****SRC Assembler***** (SRCTools Version 2.01)
HexLoc MachWord Label Source Code Comments
00000000 00000000
.org 1000H
00001000 80000000
A:
.dc 80000000H
00001004 ffff34e0
.dc -52000
00001008 0000cb20
.dc 52000
0000100c 7fffffff
.dc 7FFFFFFFH
00001010 ffffffff
B:
.dc -1
00001014 ffff34e0
.dc -52000
00001018 0000cb20
.dc 52000
0000101c 00000001
.dc 1
00001020 00000000
Sum: .dw
4
00001030 00000000
Overflow: .dc 0
00001034 00000000
.dc 0
00001038 00000000
.dc 0
0000103c 00000000
.dc 0
00001040 00000000
.org 2000H
;Main program
00002000 2a805000
la r10, Subroutine ;Address of
;Subroutine to R10
00002004 2ac02058
la r11, End
;Go to End when
;finished
00002008 2b002014
la r12, Loop ;Start
of main loop
0000200c 28800004
la r2, 4
;Number of iterations
;left
00002010 28c00000
la r3, 0
;Offset to start of
;arrays
00002014 40162002
Loop: brzr r11,
r2 ;Go to end
when no
;more elements
00002018 08461000
ld r1, A(r3) ;Load
current element
;of A in r1
0000201c 2040001c
str r1, ValA ;Store
A as first
;parameter for
;Subroutine
00002020 08461010
ld r1, B(r3) ;Load
current element
;of B in r1
00002024 20400018
str r1, ValB ;Store
B as second
;parameter
00002028 28461020
la r1, Sum(r3) ;load address
of
;current Sum in r1
0000202c 20400014
str r1, AddrSum ;Store Address of
;current Sum as 3rd
;parameter
00002030 28461030
la r1, Overflow(r3) ;Load addr. of
;current indicator in
;r1
00002034 20400010
str r1, AddrOver ;Store Addr. of
;current overflow
;indicator
00002038 4fd40001
brl r31, r10 ;Branch
to subroutine
0000203c 00000000
ValA: .dw 1
;1st parameter -- A
00002040 00000000
ValB: .dw 1
;2nd parameter -- B
00002044 00000000
AddrSum: .dw 1
;3rd parameter --
;Addr. of Sum
00002048 00000000
AddrOver: .dw 1
;4th parameter --
;Addr. of Overflow
0000204c 6885ffff
addi r2, r2, -1 ;Add -1 to elements
;remaining
00002050 68c60004
addi r3, r3, 4 ;Add 4 to get
offset
;to next array
;element
00002054 40180001
br r12
;Go to start of Loop
00002058 f8000000
End: stop
;Stop when last
;element processed
0000205c 00000000
.org 5000H
;Subroutine
00005000 2d005044
Subroutine: la r20, Minus
;Address when A is
;negative
00005004 2d41ffff
la r21, -1
;Overflow indicator
00005008 093e0000
ld r4, (r31) ;Get
A
0000500c 6ffe0004
addi r31, r31, 4 ;Point to next
;parameter
00005010 097e0000
ld r5, (r31) ;Get
B
00005014 6ffe0004
addi r31, r31, 4 ;Point to next
;parameter
00005018 09be0000
ld r6, (r31) ;Get
Addr of Sum
0000501c 6ffe0004
addi r31, r31, 4 ;Point to next
;parameter
00005020 09fe0000
ld r7, (r31) ;Get
address of
;Overflow
00005024 6ffe0004
addi r31, r31, 4 ;Generate return
;Address
00005028 62085000
add r8, r4, r5 ;Form Sum
0000502c 1a0c0000
st r8, (r6)
;Store Sum
00005030 40284005
brmi r20, r4 ;A
is negative
00005034 403e5005
brmi r31, r5 ;B
is negative -- No
;Overflow
00005038 403e8004
brpl r31, r8 ;Sum
is also positive
;-- No overflow
0000503c 1d4e0000
st r21, (r7) ;Set
Overflow
;indicator
00005040 403e0001
br r31
;Finished with
;positive numbers
00005044 403e5004
Minus: brpl r31, r5
;B is plus -- No
;overflow
00005048 403e8005
brmi r31, r8 ;Sum
is also negative
;-- no overflow
0000504c 1d4e0000
st r21, (r7) ;Set
overfow
;indicator
00005050 403e0001
br r31
;Return to main
;program