============================ ULM Generator: ALU Interface ============================ ---- VIDEO ------------------------------ https://www.youtube.com/embed/o9I-gVrVqsA ----------------------------------------- ---- SHELL (path=session07/,hide) ---------------------------------------------- rm -rf ulm-generator/ git clone https://github.com/michael-lehn/ulm-generator.git -------------------------------------------------------------------------------- ALU Interface ============= :import: session07/ulm-generator/ulm0/hdw_alu.h Register Content ---------------- ---- CODE (type=c) ------------------------------------------------------------- uint64_t ulm_regVal(ulm_Reg reg); -------------------------------------------------------------------------------- For a given pattern $\text{reg}$ returns $\%\text{reg}$. Register Initialization ----------------------- ---- CODE (type=c) ------------------------------------------------------------- void ulm_setReg(uint64_t val, ulm_Reg reg); -------------------------------------------------------------------------------- Initializes register: $u(\text{val}) \to u(\%\text{reg})$ Integer Addition ---------------- ---- CODE (type=c) ------------------------------------------------------------- void ulm_add64(uint64_t a, uint64_t b, ulm_Reg dest); -------------------------------------------------------------------------------- Computes $\left(u(\text{a}) + u(\text{b})\right) \bmod 2^{64} \to \%\text{dest}$ and updates the status registers: +-----------+-------------------------------------------------------------------+ | Flag | Condition | +-----------+-------------------------------------------------------------------+ | ZF | $\left(u(\text{a}) + u(\text{b})\right) \bmod 2^{64} = 0$ | +-----------+-------------------------------------------------------------------+ | CF | $u(\text{a}) + u(\text{b}) \geq 2^{64}$ | +-----------+-------------------------------------------------------------------+ | OF | $s(\text{a}) + s(\text{b}) \notin \{-2^{63},\dots,2^{63}-1\}$ | +-----------+-------------------------------------------------------------------+ | SF | $s(\text{a}) + s(\text{b}) < 0$ | +-----------+-------------------------------------------------------------------+ Integer Subtraction ------------------- ---- CODE (type=c) ------------------------------------------------------------- void ulm_sub64(uint64_t a, uint64_t b, ulm_Reg dest); -------------------------------------------------------------------------------- Computes $\left(-u(\text{a}) + u(\text{b})\right) \bmod 2^{64} \to \%\text{dest}$ (read as _subtract a from b_) and updates the status registers: +-----------+-------------------------------------------------------------------+ | Flag | Condition | +-----------+-------------------------------------------------------------------+ | ZF | $\left(-u(\text{a}) + u(\text{b})\right) \bmod 2^{64} = 0$ | +-----------+-------------------------------------------------------------------+ | CF | $u(-\text{a}) + u(\text{b}) \geq 2^{64}$ | +-----------+-------------------------------------------------------------------+ | OF | $s(-\text{a}) + s(\text{b}) \notin \{-2^{63},\dots,2^{63}-1\}$ | +-----------+-------------------------------------------------------------------+ | SF | $-s(\text{a}) + s(\text{b}) < 0$ | +-----------+-------------------------------------------------------------------+ (Signed) Integer Multiplication ------------------------------- ---- CODE (type=c) ------------------------------------------------------------- void ulm_mul64(uint64_t a, uint64_t b, ulm_Reg dest); -------------------------------------------------------------------------------- Computes $\left(u(\text{a}) \cdot u(\text{b})\right) \bmod 2^{64} \to \%\text{dest}$ (read as _subtract a from b_) and updates the following status registers: +-----------+-------------------------------------------------------------------+ | Flag | Condition | +-----------+-------------------------------------------------------------------+ | CF | $\left(u(\text{a}) \cdot u(\text{b})\right) \bmod 2^{64} | | | \neq u(\text{a}) \cdot u(\text{b})$ | +-----------+-------------------------------------------------------------------+ | OF | $\left(s(\text{a}) \cdot s(\text{b})\right) \bmod 2^{64} | | | \neq s(\text{a}) \cdot s(\text{b})$ | +-----------+-------------------------------------------------------------------+ Exercise ======== The following program is supposed to compute $(42-1) \cdot 13$ and then terminate with the result as exit code: ---- CODE(txt) ----------------------------------------------------------------- 03 00 2A 01 03 00 01 02 06 02 01 02 03 00 0D 01 07 01 02 01 01 01 12 34 -------------------------------------------------------------------------------- Use the ULM Generator to build a computer where this program actually does that. Submit your description `isa.txt` of the instruction set with `submit hpc quiz06 isa.txt`.