Information on various assembly language instructions including and, or, xor, not, neg, test, shift and rotate. It includes examples of how to use these instructions for converting ascii to numeric, reversing bits, and performing arithmetic operations.
Download Assembly Language Instructions: AND, OR, XOR, NOT, NEG, TEST, Shift and Rotate and more Slides Assembly Language Programming in PDF only on Docsity!
Lab
AND
AND reg, reg
AND reg, mem
AND reg, immed
AND mem, reg
AND mem, immed
AND
Convert to uppercase?
Prog1.asm
Upper case โ 41H - 5AH
Lower case โ 61H- 7AH
OR instruction
OR reg, reg
OR reg, mem
OR reg, immed
OR mem, reg
OR mem, immed
XOR
XOR reg, reg
XOR reg, mem
XOR reg, immed
XOR mem, reg
XOR mem, immed
XOR
Mov al, 10110100b
Xor al, 10000110b
AL =?
NOT
Reverses all bits
Mov al, 11110000b
Not al
Which complement?
NEG
NEG reverses the sign of a number by converting it to its twoโs complement
NEG reg
NEG mem
Mov al, +
Neg al
Test
Performs an implied AND without changing any operands โ used just to set the flags
00100101 โ input
00001001 test value
ANDing both โ ZF = 0
Examples
Encryption
Write a program for encrypting and decrypting array elements.
Checking for alphabetic input
Use CMP to check if valid alphanumeric string is entered
Shift and Rotate instructions
SHL shifts each bit in a destination operand to the left, filling lowest bit with 0.
Shifted bit in CF
Multiplication by 2
SHL destination, 1
SHL dest, CL
SHR
Shift right, divides by 2
SAR
ROR
Programs
Print a number in binary (Prog2.asm)
Input a binary number (prog2.asm)
Multiple digit input and converting them to binary (prog3.asm)