* Find the lowest positive integer whose square ends in 269696 * The logic of the assembler program is simple : * loop for i=524 step 2 * if (i*i modulo 1000000)=269696 then leave loop * next i * output 'Solution is: i=' i ' (i*i=' i*i ')' BABBAGE CSECT beginning of the control section USING BABBAGE,13 define the base register B 72(15) skip savearea (72=18*4) DC 17F'0' savearea (18 full words (17+1)) STM 14,12,12(13) prolog: save the caller registers ST 13,4(15) prolog: link backwards ST 15,8(13) prolog: link forwards LR 13,15 prolog: establish addressability LA 6,524 let register6 be i and load 524 LOOP LR 5,6 load register5 with i MR 4,6 multiply register5 with i LR 7,5 load register7 with the result i*i D 4,=F'1000000' divide register5 with 1000000 C 4,=F'269696' compare the reminder with 269696 BE ENDLOOP if equal branch to ENDLOOP LA 6,2(6) load register6 (i) with value i+2 B LOOP branch to LOOP ENDLOOP XDECO 6,BUFFER+15 edit registrer6 (i) XDECO 7,BUFFER+34 edit registrer7 (i squared) XPRNT BUFFER,L'BUFFER print buffer L 13,4(0,13) epilog: restore the caller savearea LM 14,12,12(13) epilog: restore the caller registers XR 15,15 epilog: set return code to 0 BR 14 epilog: branch to caller BUFFER DC CL80'Solution is: i=............ (i*i=............)' END BABBAGE end of the control section