0% found this document useful (0 votes)
53 views20 pages

Bit Manipulation Commands: Diploma in Computing and IT: Level - 1

The document discusses bit manipulation commands in assembly language including AND, OR, XOR, SHL, SHR, ROL, and ROR. It provides examples of how each command works and the decimal and binary representations. The uses and effects of each command are explained.

Uploaded by

HksBatcvb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views20 pages

Bit Manipulation Commands: Diploma in Computing and IT: Level - 1

The document discusses bit manipulation commands in assembly language including AND, OR, XOR, SHL, SHR, ROL, and ROR. It provides examples of how each command works and the decimal and binary representations. The uses and effects of each command are explained.

Uploaded by

HksBatcvb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

Computer Systems Architecture

AICT001-3-2

Bit manipulation commands


Diploma in Computing and IT: Level - 1

Prepared by: TPM First Prepared on: 03-06-08 Last Modified on: 20--06-08
Quality checked by: KNT
Copyright 2008 Asia Pacific Institute of Information Technology
Topic & Structure of the lesson
Assembly Language

• Bit manipulation commands.

Computer Systems Architecture Slide 2 of 19


Learning Outcomes
Assembly Language

• At the end of this session, you should be able


to:-
– Understand how bit manipulation commands work
in assembly language programs.
– Use assembly language bit manipulation
commands.

Computer Systems Architecture Slide 3 of 19


Key Terms you must be able to use
Assembly Language
• If you have mastered this topic, you should be
able to use the following terms correctly in your
assignments and exams:-
– AND
– OR
– XOR
– SHL
– SHR
– ROL
– ROR
Computer Systems Architecture Slide 4 of 19
Bit Manipulation
Assembly Language
In assembly language, data within a register is
normally operated on bitwise (in terms of bits).
Some examples of bitwise instructions are as
follows:-
AND
OR
XOR
SHL
SHR
ROL
ROR
Computer Systems Architecture Slide 5 of 19
AND
Assembly Language
Decimal Binary
198 11000110
AND 117 01110101
68 01000100

Example:-

MOV AH,198
AND AH,117

Computer Systems Architecture Slide 6 of 19


OR
Assembly Language
Decimal Binary
198 11000110
OR 117 01110101
247 11110111

Example:-

MOV AH,198
OR AH,117

Computer Systems Architecture Slide 7 of 19


XOR
Assembly Language
Decimal Binary
198 11000110
XOR 117 01110101
179 10110011
Example:-

MOV AH,198
XOR AH,117

Computer Systems Architecture Slide 8 of 19


How useful are the AND/OR?
Assembly Language

• The AND/OR commands are widely used for


masking bit values.
• What is masking?
– It is the task of switching on/off certain bits within a
byte (or word) storage.

Computer Systems Architecture Slide 9 of 19


What about the XOR?
Assembly Language

• Quite widely used as a command to initialise a


register.
• For example:-
xor ah,ah
• The reason why it is used to initialise is due to
the fact that it runs faster than a similar mov
instruction.

Computer Systems Architecture Slide 10 of 19


SHL
Assembly Language

Example:-

MOV AH,198
SHL AH,2

Computer Systems Architecture Slide 11 of 19


SHL
Assembly Language
Shift (AH contents) by two bits to the left

11000110
High order bits
are lost Low order bits
(discarded) (zeros) are
added
1100011000

Shift Direction

Computer Systems Architecture Slide 12 of 19


SHR
Assembly Language

Example:-

MOV AH,198
SHR AH,2

Computer Systems Architecture Slide 13 of 19


SHR
Assembly Language
Shift (AH contents) by two bits to the right

11000110 Low order bits


High order bits are lost
(zeros) are (discarded)
added

0011000110

Shift Direction

Computer Systems Architecture Slide 14 of 19


ROL
Assembly Language

Example:-

MOV AH,198
ROL AH,2

Computer Systems Architecture Slide 15 of 19


ROL
Assembly Language
Rotates (AH contents) by two bits to the left

Extra high 11000110


order bits are
sent to the low
order position

1100011011

Rotate Direction

Computer Systems Architecture Slide 16 of 19


ROR
Assembly Language

Example:-

MOV AH,198
ROR AH,2

Computer Systems Architecture Slide 17 of 19


ROR
Assembly Language
Rotates (AH contents) by two bits to the right
Extra low
11000110 order bits are
sent to the
high order
position

1011000110

Rotate Direction

Computer Systems Architecture Slide 18 of 19


Assembly Language

THANKS

Computer Systems Architecture


Next Session
Assembly Language

• Flow Control.

Computer Systems Architecture Slide 20 of 19

You might also like