Arithmetic/Integer: Difference between revisions

No edit summary
Line 36:
a ^^ b = 510
</pre>
 
=={{header|360 Assembly}}==
From the principles of operation: Operands are signed and 32 bits long.
Negative quantities are held in two's-complement form.
====Multiplication====
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.
====Division====
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.
<lang 360asm>
* Arithmetic/Integer 04/09/2015
ARITHINT CSECT
USING ARITHINT,R12
LR R12,R15
ADD L R1,A
A R1,B r1=a+b
XDECO R1,BUF
MVI BUF,C'+'
XPRNT BUF,12
SUB L R1,A
S R1,B r1=a-b
XDECO R1,BUF
MVI BUF,C'-'
XPRNT BUF,12
MUL L R1,A
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 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 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
</lang>
{{out}}
<pre>
+ 64
- 42
* 583
/ 4
R 9
</pre>
 
 
 
=={{header|6502 Assembly}}==
1,392

edits