2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,83 +1,59 @@
|
|||
* Bubble Sort
|
||||
* Bubble Sort 01/11/2014 & 23/06/2016
|
||||
BUBBLE CSECT
|
||||
USING BUBBLE,R13,R12
|
||||
SAVEAREA B STM-SAVEAREA(R15) skip savearea
|
||||
DC 17F'0'
|
||||
DC CL8'BUBBLE'
|
||||
STM STM R14,R12,12(R13) save calling context
|
||||
ST R13,4(R15)
|
||||
ST R15,8(R13)
|
||||
LR R13,R15 set addessability
|
||||
LA R12,4095(R13)
|
||||
LA R12,1(R12)
|
||||
MORE EQU *
|
||||
LA R8,0 R8=no more
|
||||
LA R1,A R1=Addr(A(I))
|
||||
LA R2,2(R1) R2=Addr(A(I+1))
|
||||
LA R4,0 to start at 1
|
||||
LA R6,1 increment
|
||||
L R7,N R7=N
|
||||
BCTR R7,0 R7=N-1
|
||||
LOOP BXH R4,R6,ENDLOOP for R4=1 to N-1
|
||||
LH R3,0(R1) R3=A(I)
|
||||
CH R3,0(R2) A(I)::A(I+1)
|
||||
BNH NOSWAP if A(I)<=A(I+1) then goto NOSWAP
|
||||
LH R9,0(R1) R9=A(I)
|
||||
LH R3,0(R2) R3=A(I+1)
|
||||
STH R3,0(R1) A(I)=R3
|
||||
STH R9,0(R2) A(I+1)=R9
|
||||
LA R8,1 R8=more
|
||||
NOSWAP EQU *
|
||||
LA R1,2(R1) next A(I)
|
||||
LA R2,2(R2) next A(I+1)
|
||||
B LOOP
|
||||
ENDLOOP EQU *
|
||||
LTR R8,R8
|
||||
BNZ MORE
|
||||
LA R3,A R3=Addr(A(I))
|
||||
LA R4,0 to start at 1
|
||||
LA R6,1 increment
|
||||
L R7,N
|
||||
PRNT BXH R4,R6,ENDPRNT for R4=1 to N
|
||||
LH R5,0(R3) R5=A(I)
|
||||
CVD R4,P Store I to packed P
|
||||
UNPK Z,P Z=P
|
||||
MVC C,Z C=Z
|
||||
OI C+L'C-1,X'F0' ZAP SIGN
|
||||
MVC BUFFER(4),C+12
|
||||
CVD R5,P Store A(I) to packed P
|
||||
UNPK Z,P Z=P
|
||||
MVC C,Z C=Z
|
||||
OI C+L'C-1,X'F0' ZAP SIGN
|
||||
MVC BUFFER+10(6),C+10
|
||||
WTO MF=(E,WTOMSG)
|
||||
LA R3,2(R3) next A(I)
|
||||
B PRNT
|
||||
ENDPRNT EQU *
|
||||
CNOP 0,4
|
||||
L R13,4(0,R13)
|
||||
LM R14,R12,12(R13) restore context
|
||||
XR R15,R15 set return code to 0
|
||||
BR R14 return to caller
|
||||
N DC A((AEND-A)/2) number of items in A, so N=F'80'
|
||||
A DC H'223',H'356',H'018',H'820',H'664',H'845',H'927',H'198' 8
|
||||
DC H'261',H'802',H'523',H'982',H'242',H'192',H'913',H'230' 16
|
||||
DC H'353',H'565',H'195',H'174',H'665',H'807',H'050',H'539' 24
|
||||
DC H'436',H'249',H'848',H'010',H'006',H'794',H'100',H'433' 32
|
||||
DC H'782',H'728',H'259',H'358',H'206',H'081',H'701',H'997' 40
|
||||
DC H'880',H'520',H'780',H'293',H'861',H'942',H'735',H'091' 48
|
||||
DC H'503',H'582',H'716',H'836',H'135',H'653',H'856',H'142' 56
|
||||
DC H'919',H'498',H'303',H'894',H'536',H'211',H'539',H'986' 64
|
||||
DC H'356',H'796',H'644',H'552',H'771',H'443',H'035',H'780' 72
|
||||
DC H'474',H'278',H'332',H'949',H'351',H'282',H'558',H'904' 80
|
||||
AEND EQU *
|
||||
P DS PL8 packed
|
||||
Z DS ZL16 zoned
|
||||
C DS CL16 character
|
||||
WTOMSG CNOP 0,4
|
||||
DC H'80' length of WTO buffer
|
||||
DC H'0' must be binary zeroes
|
||||
BUFFER DC 80C' '
|
||||
USING BUBBLE,R13,R12 establish base registers
|
||||
SAVEAREA B STM-SAVEAREA(R15) skip savearea
|
||||
DC 17F'0' my savearea
|
||||
STM STM R14,R12,12(R13) save calling context
|
||||
ST R13,4(R15) link mySA->prevSA
|
||||
ST R15,8(R13) link prevSA->mySA
|
||||
LR R13,R15 set mySA & set 4K addessability
|
||||
LA R12,2048(R13) .
|
||||
LA R12,2048(R12) set 8K addessability
|
||||
L RN,N n
|
||||
BCTR RN,0 n-1
|
||||
DO UNTIL=(LTR,RM,Z,RM) repeat ------------------------+
|
||||
LA RM,0 more=false |
|
||||
LA R1,A @a(i) |
|
||||
LA R2,4(R1) @a(i+1) |
|
||||
LA RI,1 i=1 |
|
||||
DO WHILE=(CR,RI,LE,RN) for i=1 to n-1 ------------+ |
|
||||
L R3,0(R1) a(i) | |
|
||||
IF C,R3,GT,0(R2) if a(i)>a(i+1) then ---+ | |
|
||||
L R9,0(R1) r9=a(i) | | |
|
||||
L R3,0(R2) r3=a(i+1) | | |
|
||||
ST R3,0(R1) a(i)=r3 | | |
|
||||
ST R9,0(R2) a(i+1)=r9 | | |
|
||||
LA RM,1 more=true | | |
|
||||
ENDIF , end if <---------------+ | |
|
||||
LA RI,1(RI) i=i+1 | |
|
||||
LA R1,4(R1) next a(i) | |
|
||||
LA R2,4(R2) next a(i+1) | |
|
||||
ENDDO , end for <------------------+ |
|
||||
ENDDO , until not more <---------------+
|
||||
LA R3,PG pgi=0
|
||||
LA RI,1 i=1
|
||||
DO WHILE=(C,RI,LE,N) do i=1 to n -------+
|
||||
LR R1,RI i |
|
||||
SLA R1,2 . |
|
||||
L R2,A-4(R1) a(i) |
|
||||
XDECO R2,XDEC edit a(i) |
|
||||
MVC 0(4,R3),XDEC+8 output a(i) |
|
||||
LA R3,4(R3) pgi=pgi+4 |
|
||||
LA RI,1(RI) i=i+1 |
|
||||
ENDDO , end do <-----------+
|
||||
XPRNT PG,L'PG print buffer
|
||||
L R13,4(0,R13) restore caller savearea
|
||||
LM R14,R12,12(R13) restore context
|
||||
XR R15,R15 set return code to 0
|
||||
BR R14 return to caller
|
||||
A DC F'4',F'65',F'2',F'-31',F'0',F'99',F'2',F'83',F'782',F'1'
|
||||
DC F'45',F'82',F'69',F'82',F'104',F'58',F'88',F'112',F'89',F'74'
|
||||
N DC A((N-A)/L'A) number of items of a *
|
||||
PG DC CL80' '
|
||||
XDEC DS CL12
|
||||
LTORG
|
||||
YREGS
|
||||
RI EQU 6 i
|
||||
RN EQU 7 n-1
|
||||
RM EQU 8 more
|
||||
END BUBBLE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue