How to resolve the algorithm Loops/While step by step in the 360 Assembly programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Loops/While step by step in the 360 Assembly programming language

Table of Contents

Problem Statement

Start an integer value at   1024. Loop while it is greater than zero. Print the value (with a newline) and divide it by two each time through the loop.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Loops/While step by step in the 360 Assembly programming language

Source code in the 360 programming language

*        While                     27/06/2016
WHILELOO CSECT                     program's control section 
         USING WHILELOO,12         set base register
         LR    12,15               load base register
         LA    6,1024              v=1024
LOOP     LTR   6,6                 while v>0 
         BNP   ENDLOOP             .
         CVD   6,PACKED              convert v to packed decimal
         OI    PACKED+7,X'0F'        prepare unpack
         UNPK  WTOTXT,PACKED         packed decimal to zoned printable
         WTO   MF=(E,WTOMSG)         display v
         SRA   6,1                   v=v/2   by right shift 
         B     LOOP                end while
ENDLOOP  BR    14                  return to caller
PACKED   DS    PL8                 packed decimal
WTOMSG   DS    0F                  full word alignment for wto
WTOLEN   DC    AL2(8),H'0'         length of wto buffer (4+1)
WTOTXT   DC    CL4' '              wto text
         END   WHILELOO

*        While                     27/06/2016
WHILELOO CSECT
         USING WHILELOO,12         set base register
         LR    12,15               load base register
         LA    6,1024              v=1024
         DO WHILE=(LTR,6,P,6)      do while v>0 
         CVD   6,PACKED              convert v to packed decimal
         OI    PACKED+7,X'0F'        prepare unpack
         UNPK  WTOTXT,PACKED         packed decimal to zoned printable
         WTO   MF=(E,WTOMSG)         display
         SRA   6,1                   v=v/2   by right shift
         ENDDO ,                   end while
         BR    14                  return to caller
PACKED   DS    PL8                 packed decimal 
WTOMSG   DS    0F                  full word alignment for wto
WTOLEN   DC    AL2(8),H'0'         length of wto buffer (4+1)
WTOTXT   DC    CL4' '              wto text
         END   WHILELOO

  

You may also check:How to resolve the algorithm Safe addition step by step in the Go programming language
You may also check:How to resolve the algorithm Letter frequency step by step in the Pike programming language
You may also check:How to resolve the algorithm Long primes step by step in the Prolog programming language
You may also check:How to resolve the algorithm Stair-climbing puzzle step by step in the Elixir programming language
You may also check:How to resolve the algorithm Walk a directory/Non-recursively step by step in the Standard ML programming language