Vous êtes sur la page 1sur 6

Program With Loop

Abstract
In microprocessor 8085, a process repeated on a same register will extend long
computation program when not using looping .Loop also can saves memory space
for the program. Each iteration requires a limit to the process program with input
from the user itself. With the loop, the program becomes shorter without loosing
the meaning of the program.
Keyword : loop, microprocessor 8085
Introduction
One of the advantages of microprocessor is able to perform the same task
repeatedly for processing many task. Int the loop, a program must have the ability
to return to the main program or previous instruction.
In Microprocessor programming, the way to make program with loop is
using the branching instruction. With the branching instruction, the normal
program execution sequence (from top to bottom) will change. In general, the
instructions are used to create a loop is JUMP, CALL, RETURN, and RESTART.
Microprocessor 8085 provides 29 branchings instruction that can be used
by the user. The 29 instructions are divided into many groups of conditional
branching instruction and unconditionally.

Theory
The 29 instructions are divided into many groups of conditional branching
instruction and unconditionally.

1. JMP instruction conditional and unconditional


Unconditional branching instructions in JMP instruction takes three bytes memory
of program. The first byte instructions is instruction operation code and the second
and third bytes of address.
JNZ L1
Operation
code

address

Memory usage
Opertion code
Jump
Address byte
(low)
Nature byte
(high)

Process looping
Instruction 1
Instruction 2
Instruction 3
Instruction 4
Instruction 5
Instruction 6
Instruction 7

Loop
Loop 1
1
Loop 2

If the JMP instruction is executed, the address contained in byte two and three will
be transferred to the program counter (PC register) to counting how many
instructions was executed. JMP instruction can be used to create advanced loop
(loop1) or backward (loop2). Loop instruction can also be used to run programs
continuously in a continuous loop conditional jump instructions consists of:
JZ (jump if zero)
JZN (jumpif zero flag is not set)
JNC (jump if carry flag is 0)
JC (jump if carry flag is 1)
JPO (jump if the parity of the bytes in the accumulator is odd)
JP (jump if the sign bit 0, showing the contents of the accumulator is positive)
JM (jump if the sign bit is 1, to indicate that the accumulator contains negative
numbers)

2.

Instruction CALL, Return


Instructions CALL address used to call a subprogra. For example, multiplying
between two numbers repeatedly in a program, it can be written once in a
memory as subroutines, and can be called each time when needed. When the
CALL instruction is executed, the contents of the program counter will be
replaced with the starting address of the subroutine called in memory. To restore
the microprocessor into the main program (after completing subroutines),
RETURN instruction as couples CALL instruction.
-

CALL sub 1
-

CALL sub 2
-

Memory usage
Operation code
CALL
start subroutines

(low)
Byte start address subroutines

(high)

Instructions CALL on condition that:


CNZ (call if the zero flag is not cell)
CZ (Call if zero)
CNC (call if the carry flag is 0)
CC (call if the carry flag is 1)
CPO (call if the parity is odd)

CPE (call if parity is even)


CP (call if positive)
CM (call if minus)
When the MPU counter CALL instruction, the MPU will store the return address
(address of the next instruction after the subroutine is finished) on a read-write
memory section (RAM) that certain called stack. The return address is loaded into
the stack pointer register using the instruction LXI SP at the start of the program.
To return the microprocessor to the main program, the RET instruction in INTEL
8085 have conditional and unconditional there RET included :
RET instruction is conditional.
RZ (return if zero)
RNC (return if not carry)
RC (return if carry)
RPO (return if odd parity)
RPE (return if parity even)
RP (returns if a plus)
RM (return if minus)

Start

Procedure
Program to retrieve data from memory location.Make flowchart and the program
HL
to take 10 data contained
in 0A000h
the address A000h to A009h, and storing the data in
DE

0D000h
sequential memory locations (address D000h to D009h). write a program start at
C 0Ah
address B000h.

A HL
0D000h A
HL HL + 1
DE DE + 1
CC1

Flowchart
C=0?

Stop

Program

Input value before execute the program

Breakpoint Manager informated the memory usage

Output value after executed

Analysis

Vous aimerez peut-être aussi