You are on page 1of 9

LAB MANUAL # 03

Implementation of Flag Registers

Example 1:-
MOV DX, 126FH ADD DX, 3465H MOV BX, 0FFFFH ADD BX, 1

Use Single Step and observe changes in flags after executing every single statement. Also, convert the
numbers to binary and prove the results(manually) as observed using emulator.

Carry Flag (CF):1


Auxiliary Flag (AF):1
Zero Flag (ZF): set to 1 when result is
zero.
Parity Flag (PF): this flag is set to 1 when
there is even number of one bits in result.
Example 2:-
MOV BL,+8
MOV DH,+4
ADD BL,DH

Sign Flag (SF): set to 1 when result is


negative.

Parity Flag (PF): this flag is set to 0 when


there is odd number of one bits.
Example 3:-
MOV AL, +66
MOV CL, +69
ADD CL,AL

Zero Flag (ZF): set to 1 when result is zero.

.Parity Flag (PF): this flag is set to 1 when there is


even number of one bits in result.
Example 4:-
MOV AL, -12
MOV BL, +18
ADD BL,AL
Example 5:-
MOV AH, -30
MOV DL, +14
ADD DL, AH

Overflow Flag (OF): An overflow indicates that


the result has exceeded the capacity of the
machine.
Parity Flag (PF): this flag is set to 1 when there
is even number of one bits in result.
Describe briefly:

1. What is Emulator and how it helps a hardware/embedded system designer?


An emulator is a hardware device or software program that enables one computer system (also
known as a host) to imitate the functions of another computer system (known as the guest). It
enables the host system to run software, tools, peripheral devices and other components which are
designed for the guest system.
Emulation is a versatile verification tool with many associated benefits, including hardware/software
co-verification, or the ability to test the integration of hardware and software. Software developers
have taken notice because it is the only verification tool able to ensure that the embedded system
software works properly with the underling hardware.

2. What is the difference between machine code and assembly language?


The main difference between machine code and assembly language is that the machine code is a
language that consists of binaries that can be directly executed by a computer while an assembly
language is a low-level programming language that requires a software called an assembler to
convert it into machine code.

Machine Code Assembly Language

A computer program written in machine There is strong correspondence between the


language instructions that can be executed program’s statement and the architecture’s
directly by a computer’s CPU. machine code.

Consists of binaries, which are zeroes and ones. Follow a syntax similar to English language.

Only understood by the CPU. Understood by the programmer.

Depends on the platform or the operating Consists of a set of standard instructions.


system.

3. Define Purpose of IP register?


Instruction Pointer (IP) is a 16-bit register and it contains the offset within the code segment of the
memory. Since the Instruction Pointer (IP) is 16 bit it means you can only have 64k instructions
(2^16), which wasn't much even in the 80s. So to expand the address space you have a second
register which addresses 64k blocks. You could consider cs:ip together as one 32 bit register which
is then capable of addressing 2^32 bytes...ie 4G which is what you get on a processor which uses
32 bit addresses. The 8086 was using 20 bits of addresses, so you could access 1M of memory.
4. Write down the purpose of AX,BX, CX and DX Registers?
The four general purpose registers are the AX, BX, CX, and DX registers.
AX - accumulator, and preferred for most operations.
BX - base register, typically used to hold the address of a procedure or variable.
CX - count register, typically used for looping.
DX - data register, typically used for multiplication and division.
Lab Tasks

Execute the following tasks CLO [1]

Task 1

What effect on Conditional Flags will happens after the addition of 10110001 and 10101011? (write state
of each of the flag as observed, note values of flags after execution of every single instruction in the
program)
Task 2
Add two numbers in hex, save the result
in AX register and observe the value
of flags.
1000 0000 0000 0000
1100 1000 0000 0000
(write state of each of the flag as
observed, note values of flags
after execution of every single
instruction in the program).

You might also like