========================== Exercise related to macros [TOC] ========================== Implement the macros described below and test them. For testing figure out some small and simple examples. Some little helpers =================== We want to express some common operations more expressive: - Write a macro `cmp` such that for example `cmp $0, %5` expands to `subq $0, %5, %0`. - Write the macros `inc` and `dec` such that for example `inc %5` and `dec %5` increment and decrement the content of `%5` respectively. Loading and storing a Quad-Word =============================== Assume that `n` denotes some label. Write the macros `ldq` and `stq` that behave as follows: - `ldq n, %5`: Register 5 gets overwritten with the quad-word at the absolute address `n` - `stq %5, n`: the quad-word in register 5 overwrites the quad-word at absolute address `n` Factorial ========= Write an assembly program that computes the factorial based on a for-loop Vector-Sum ========== Write a assembly program that contains in the data segment: - the length of a vector (as a unsigned quad-word integer) - the vector elements (as signed quad-word integers) When the program is finish the vector length should be overwritten with the sum of the elements. :navigate: up -> doc:index back -> doc:session02/page01 next -> doc:session02/page03