Cheatography

# Assembler Final Cheat Sheet (DRAFT) by joshfedo94

This is a draft cheat sheet. It is a work in progress and is not finished yet.

### maths

 IMUL Multiply ax by what ever is specified (for 32 bit store in DX:AX) DIV (16 bit) takes the operand and divides it by AX and stores it in AL with remainder in AH. for 32 bit it used DX:AX pair and leaves awn is AX and remainder in DX MUL Multiply ax by what ever is specified (all unsigned) CWD convers the word in AX to a double word in DX:AX

### Convert num to bytes

 ASCII 1 byte per char unsigned 2 bytes for 5 chars bcd 2 bytes for 5 chars

### code examples

 ``````Write code that would find the sum 6+12+18...+300 and store it in var tot MOV TOT, 0; MOV AX,6; LOOP: ADD TOT, AX; ADD AX, 6 CMP AX,300; JLE LOOP write code that is assembler equiv: if(x

### binary

 signed magnitude Very left bit is 0 for + num and 1 for -num twos compliment flip the bits and add 1 27 excises add the num to 128 then convert to binary ones compliment flip all bits unsigned all bits count but its a positive num

### Bit shifting

 RCR rotate right last bite gets stored in carry and carry gets pushed to the first bite SHL Shift left into cf TEST The TEST operation sets the flags CF and OF to zero. The SF is set to the most signif­icant bit of the result of the AND. If the result is 0, the ZF is set to 1, otherwise set to 0. The parity flag is set to the bitwise XNOR of the least signif­icant byte of the result, 1 if the number of ones in that byte is even, 0 otherwise. The value of AF is undefined. SAR shift right into carry but keep the signed bit the same CMC invert CF ROL roatate left into the last bit and the carry flag CLC CF = 0 STC CF = 1