Differences

This shows you the differences between two versions of the page.

Link to this comparison view

instructions:div [2008/05/13 07:22] (current)
Line 1: Line 1:
 +====== Divide (DIV)/OP=06 ======
  
 +==== Format ====
 +
 +^  OP  ^  AF  ^  BF  ^  A Syllable  ^  B Syllable  ^  C Syllable  ^
 +
 +''OP = 06''
 +
 +**AF** is the length of the //A Syllable// field.  **AF** may be indirect or may indicate the //A Syllable// is a literal.  A value of __00__ is equal to a length of 100 units.\\
 +**BF** is the length of the //B Syllable// field.  **BF** may be indirect.  A value of __00__ is equal to a length of 100 units.
 +
 +The //A Syllable// is the address of the __divisor__ field.   Address may be indexed, indirect or extended.  The final address controller data type may be **UN**, **SN** or **UA**.\\
 +The //B Syllable// is the address of the __dividend__ and __remainder__ fields.   Address may be indexed, indirect or extended.  The final address controller data type may be **UN**, **SN** or **UA**.\\
 +The //C Syllable// is the address of the __quotient__ field.   Address may be indexed, indirect or extended.  The final address controller data type may be **UN**, **SN** or **UA**.
 +
 +==== Function ====
 +
 +The Divide instruction divides the contents of one memory location **B** by the contents of a second memory location **A**
 +storing the remainder in the **B** data field and storing
 +the quotient in a third memory location **C**.
 +
 +The length of the __dividend__ field must be greater than the length of the
 +__divisor__ field (**BF** greater than **AF**).  The length of the
 +__quotient__ field is the difference in length of the **A** and **B** fields
 +(**BF** - **AF**).   If the result is too large to fit into the __quotient__
 +field or if **BF** is not greater than **AF**, the division is not performed, the
 +contents of **B** and **C** are unchanged, the
 +[[processor_state:comparison_flags|Comparison Flags]] are unchanged and the
 +[[processor_state:overflow_flag|Overflow Flag]] is set.
 +
 +If the absolute value of the __divisor__ is not greater than the absolute
 +value of the equivalent number of leading digits of the __dividend__, the
 +division is not performed and the [[processor_state:overflow_flag|Overflow Flag]] is set with the
 +[[processor_state:comparison_flags|Comparison Flags]] remaining unchanged.
 +Note that a __divisor__ which is zero will fail this test and the
 +[[processor_state:overflow_flag|Overflow Flag]] will be set.
 +
 +Store the absolute value of the quotient when the __quotient__ field data type is unsigned (**UN** or **UA**).  Store the standard **EBCDIC** form of the result sign as the first digit of the result when the __quotient__ field data type is **SN**.  Fill the zone digit with the **EBCDIC** numeric subset code (**F**) when the __quotient__ field data type is alphanumeric (**UA**).
 +
 +Store the absolute value of the remainder when the __remainder__ field data type is unsigned (**UN** or **UA**).
 +Fill the zone digit with the **EBCDIC** numeric subset code (**F**) when the __remainder__ field data type is alphanumeric (**UA**).
 +When the __remainder__ field data type is signed numeric (**SN**), then the
 +absolute value of the remainder is stored after the __remainder__ sign digit,
 +leaving the __remainder__ sign digit with the original contents of the
 +__dividend__ sign digit.
 +
 +Only the numeric digits of an alphanumeric field enter into the operation.
 +
 +Unsigned (**UN** or **UA**) operands are assumed to be positive.
 +
 +The sign of a __quotient__ is positive if the sign of the __divisor__ and the
 +__dividend__ are the same or the __quotient__ is zero, otherwise the sign is
 +negative.
 +
 +If the __dividend__ data type is **SN**, the sign of the __dividend__ will be
 +left unchanged in memory and will thus become the sign of the __remainder__.
 +Therefore this final __remainder__ sign could be other than *C* or *D* and a
 +__remainder__ of zero magnitude could have a negative sign.
 +
 +
 +If the operand data contains undigits other than in the sign digit, cause an //Invalid Arithmetic Data// fault.  See [[compatibility_notes:a.16|Compatibility Notes A.16]].
 +
 +==== Comparison Flags ====
 +
 +In all cases except overflow, set the [[processor_state:comparison_flags|Comparison Flags]] to indicate whether the sum is greater than (**HIGH**), equal to (**EQUAL**) or less than (**LOW**) zero.
 +
 +==== Overlap ====
 +
 +Partial overlap of the __dividend__ field (**B**) and either of the other operands
 +may produce inconsistent results.
 +
 +If the address of the __dividend__ field is the same as the address of the
 +__quotient__ field (**B** = **C**) and the respective address controllers are
 +equal (**BC** = **CC**), a result will be produced that consists of the
 +quotient followed by the least significant **AF** units of the remainder.  In
 +the case of **SN** data, the sign of the quotient will be stored in the first
 +digit of the result followed by the quotient and the least significant **AF**
 +digits of the remainder.
 +
 +==== Examples ====
 +
 +=== Example (1) Divide two signed numbers ===
 +
 +^  OP  ^  AF  ^  BF  ^  A Syllable  ^  B Syllable  ^  C Syllable  ^
 +|  06  |  01  |  04  |  A field **SN**  |  B field **SN**  |  C Field **SN**  |
 +
 +                      BEFORE         AFTER
 +    A FIELD              +9        unchanged
 +    B FIELD           +0101           C0002  Remainder
 +    C FIELD            nnnn           C011   Quotient
 +    COMPARISON          nn            HIGH
 +    OVERFLOW            nn         unchanged
 +
 +=== Example (2) Divide two signed fields, negative numbers ===
 +
 +^  OP  ^  AF  ^  BF  ^  A Syllable  ^  B Syllable  ^  C Syllable  ^
 +|  06  |  02  |  05  |  A field **SN**  |  B field **SN**  |  C Field **SN**  |
 +
 +                      BEFORE         AFTER
 +    A FIELD             D12        unchanged
 +    B FIELD          D00187         D00007
 +    C FIELD            nnnn           C015
 +    COMPARISON          nn            HIGH
 +    OVERFLOW            nn         unchanged
 +
 +=== Example (3) Divide producing overflow (Length problem) ===
 +
 +^  OP  ^  AF  ^  BF  ^  A Syllable  ^  B Syllable  ^  C Syllable  ^
 +|  06  |  04  |  03  |  A field **SN**  |  B field **SN**  |  C Field **SN**  |
 +
 +                      BEFORE         AFTER
 +    A FIELD           D1014        unchanged
 +    B FIELD            D123        unchanged
 +    C FIELD            nnnn        unchanged
 +    COMPARISON          nn         unchanged
 +    OVERFLOW            nn            ON
 +
 +=== Example (4) Divide producing overflow (Data problem) ===
 +
 +^  OP  ^  AF  ^  BF  ^  A Syllable  ^  B Syllable  ^  C Syllable  ^
 +|  06  |  02  |  03  |  A field **SN**  |  B field **SN**  |  C Field **SN**  |
 +
 +                      BEFORE         AFTER
 +    A FIELD             D11        unchanged
 +    B FIELD            D125        unchanged
 +    C FIELD            nnnn        unchanged
 +    COMPARISON          nn         unchanged
 +    OVERFLOW            nn            ON
 +
 +=== Example (5) Divide by zero ===
 +
 +^  OP  ^  AF  ^  BF  ^  A Syllable  ^  B Syllable  ^  C Syllable  ^
 +|  06  |  02  |  03  |  A field **SN**  |  B field **SN**  |  C Field **SN**  |
 +
 +                      BEFORE         AFTER
 +    A FIELD             +00        unchanged
 +    B FIELD            D125        unchanged
 +    C FIELD            nnnn        unchanged
 +    COMPARISON          nn         unchanged
 +    OVERFLOW            nn            ON
 +
 +=== Example (5) Total overlap of B and C ===
 +
 +^  OP  ^  AF  ^  BF  ^  A Syllable  ^  B Syllable  ^  C Syllable  ^
 +|  06  |  02  |  04  |  A field **UN**  |  B field **UN**  |  C Field **UN**  |
 +
 +                      BEFORE         AFTER
 +    A FIELD              13        unchanged
 +    B FIELD            1127           8609
 +    COMPARISON          nn            HIGH
 +    OVERFLOW            nn         unchanged
instructions/div.txt ยท Last modified: 2008/05/13 07:22 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki