zettacode.files/arithmetic.integer/360_assembly.txt in zettacode-0.1.0 vs zettacode.files/arithmetic.integer/360_assembly.txt in zettacode-0.1.1

- old
+ new

@@ -1,55 +1,55 @@ -F c f : O 32 b . -N qu '-c f. -b'''Muc:'''b -T uc f u ( c ) uc -( f ) c uc. B u -uc 32-b . T uc 64-b - ccu . -b'''D:'''b -T (f ) b (c ) - c b qu . T 64-b - ccu f . -A 32-b 32-b qu c - -ub -ub , c. -T f qu b u f b. -T . -* AmcI 04092015 +From the principles of operation: Operands are signed and 32 bits long. +Negative quantities are held in two's-complement form. +<br>'''Multiplication:'''<br> +The product of the multiplier (the second operand) and the multiplicand +(the first operand) replaces the multiplicand. Both multiplier and +multiplicand are 32-bit signed integers. The product is always a 64-bit +signed integer and occupies an even/odd register pair. +<br>'''Division:'''<br> +The dividend (first operand) is divided by the divisor (second operand) +and replaced by the quotient and remainder. The dividend is a 64-bit +signed integer and occupies the even/odd pair of registers. +A 32-bit signed remainder and a 32-bit signed quotient replace the dividend +in the even-numbered and odd-numbered registers, respectively. +The sign of the quotient is determined by the rules of algebra. +The remainder has the same sign as the dividend. +* Arithmetic/Integer 04/09/2015 ARITHINT CSECT USING ARITHINT,R12 LR R12,R15 ADD L R1,A - A R1,B 1=+b + A R1,B r1=a+b XDECO R1,BUF MVI BUF,C'+' XPRNT BUF,12 SUB L R1,A - S R1,B 1=-b + S R1,B r1=a-b XDECO R1,BUF MVI BUF,C'-' XPRNT BUF,12 MUL L R1,A - M R0,B 01=*b - XDECO R1,BUF 1 + M R0,B r0r1=a*b + XDECO R1,BUF so r1 has the lower part MVI BUF,C'*' XPRNT BUF,12 DIV L R0,A - SRDA R0,32 f - D R0,B 1=b 0 - XDECO R1,BUF 1 qu - MVI BUF,C'' + SRDA R0,32 to shift the sign + D R0,B r1=a/b and r0 has the remainder + XDECO R1,BUF so r1 has quotient + MVI BUF,C'/' XPRNT BUF,12 MOD L R0,A - SRDA R0,32 f - D R0,B 1=b 0 - XDECO R0,BUF 0 + SRDA R0,32 to shift the sign + D R0,B r1=a/b and r0 has the remainder + XDECO R0,BUF so r0 has the remainder MVI BUF,C'R' XPRNT BUF,12 RETURN XR R15,R15 BR R14 CNOP 0,4 A DC F'53' B DC F'11' BUF DC CL12' ' YREGS END ARITHINT -Iu c: =53, b=11 +Inputs are in the code: a=53, b=11 \ No newline at end of file