EMAC PRIMER Instruction Manual page 27

Table of Contents

Advertisement

LESSON 2 : Running Your First Program
NEW INSTRUCTIONS
IN <byte> op code = DB
Load the A register with the data that is on the input port specified by the byte following the instruction. No
flags are affected.
OUT <byte> op code = D3
Send the data in the A register to the output port specified by the byte following the instruction. No flags
are affected.
JMP <addr> op code = C3
Load the program counter (PC) with the address contained in the two bytes following the instruction. The
first byte following the op code is the least significant byte of the address, the second byte is the most
significant byte of the address. No flags are affected.
Below is an example 8085 program written in assembly language. This program reads the binary value of the DIP switches
and outputs the value to the digital output LEDs and then repeats these instructions indefinitely. The program may be
stopped by pressing the reset button.
ASSEMBLER PROGRAM
leds
equ
dips
equ
org
loop:
in
out
jmp
end
MACHINE LANGUAGE PROGRAM
ADDRESS
FF01
FF02
FF03
FF04
FF05
FF06
FF07
To run this machine language program, turn on the PRIMER Trainer and the program counter address FF01 will be shown
on the left four displays. Load the machine language data from the above table into memory. Once the whole program has
been entered correctly return the program counter address to FF01 by pressing the reset button or loading the PC register
with FF01, then run the program by pressing "Func." and the "Step/Run" key. You should see that as you move the DIP
switches the digital output LEDs will turn off or on accordingly. Now press the reset button and the program will stop, the
digital output LEDs will turn off and the display will show "FF01 db".
The PRIMER allows you to execute a single machine language instruction starting at the address in the PC
register. This procedure is called single stepping. After the instruction is completed, the PC register points to the address
of the next instruction and the PRIMER will be returned to data entry mode. To single step the first instruction, press the
"stp/run" key and the displays will show "FF03 d3" which is the new value for PC and the data pointed to by PC. The IN
instruction was executed and the PC register was returned with the address of the next instruction, the OUT instruction. To
single step the rest of the program, do the following:
1) Single step again and the display will show "FF05 C3". the OUT 11 instruction has been executed and the PC
register was returned with the address of the JMP FF01 instruction.
2) Single step again and the display will show "FF01 db". This display shows FF01 because that is the value that
was loaded into the PC register by the JMP FF01 instruction. You can see that the mnemonic came from the
instructions ability to cause the program counter to "jump" to another location. PC now points to the IN 12
instruction again.
11h
12h
0ff01h
dips
; load A register with
; DIP switch values
leds
; output A register to LEDs
loop
; jump to loop
DATA
INSTRUCTION
DB
IN
12
12
D3
OUT
11
11
C3
JMP FF01
01
FF
27

Advertisement

Table of Contents
loading

Table of Contents