CPSC 355 Lecture Notes - Lecture 7: Assembly Language, Elementary Arithmetic, Printf Format String

54 views3 pages

Document Summary

Cpsc 355 - lecture 7 - sept 26th. Multiply-add: form (32-bit): madd wd, wn, wm, wa. Calculates: wd = wa + (wn * wm: eg: madd w20, w21, w22, w23, 64-bit form is similar. Multiply-subtract: form (32-bit): msub wd, wn, wm, wa. Calculates: wd = wa (wn * wm) Multiply-negate: form (32-bit): mneg wd, wn, wm. Calculates: wd = - (wn * wm) Division: uses 1 destination and 2 source registers, no immediates allowed, signed form (32-bit): sdiv wd, wn, wm. Eg: sdiv w0, w1, w2: 64-bit form is similar. The udiv variants use unsigned integer operands: eg: udiv w0, w1, w2, eg: udiv x21, x22, x23. These instructions do integer division: the calculated quotient is an integer, and any remainder is discarded. Eg: 14/3 is 4, with the remainder of 2: the remainder (or modulus) can be calculates using: numerator (quotient * denominator) The msub instruction is useful here: dividing by 0 does not generate an exception (a trap)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers