EMAC PRIMER Instruction Manual page 67

Table of Contents

Advertisement

LESSON 22: Using PITCH (service 10)
NEW INSTRUCTIONS
RRC
Shift the bits in the A register to the right and put the value shifted out of bit 0 in the carry flag and bit 7.
Only the carry flag is affected.
This program translates the value of the DIP switch to a 14 bit value that is stored in the DE register pair. The value is
passed to service 10 which produces a speaker frequency inversely proportional to the value of DE.
dips
equ
mos
equ
org
loop:
in
rrc
rrc
mov
ani
mov
mov
ani
mov
mvi
call
jmp
end
ADDRESS
FF01
FF02
FF03
FF04
FF05
FF06
FF07
FF08
FF09
FF0A
FF0B
FF0C
FF0D
FF0E
FF0F
FF10
FF11
FF12
FF13
FF14
1) Switch the 4 DIP switches on the left "on" and the 4 on the right, "off". When this is done, the data that is input
through the DIP switches will be 0F hex.
2) Press reset and load the program into memory and verify that it was loaded correctly.
3) Single step once and examine the A register to make sure it is 0F, if it isn't, do step 1 again.
In order for the DIP switches to give the broadest range of frequencies the 8 bit value of the DIP switches must be made
the most significant 8 bits of the 14 bit value required to generate the frequency. The chart below shows how this is done.
This chart shows the op codes that are used to convert the DIP switch value to a value stored in the DE register pair. To
the right of the op codes are the binary values that the A, D and E registers would be after the op code is executed. In the
chart, the "X"s tell you that the value has not been defined yet and that they are unknown values.
op code = 0F
12h
; port to read DIP switches
1000h
; address of MOS services
0ff01
dips
; get the DIP switch value
; rotate the A register right
; 2 times since top two bits aren't used
e,a
; store in E temporarily
00111111b
; mask 2 top bits to 0
d,a
; save in D
a,e
; get E again
11000000b
; mask the lower 6 bits to 0
e,a
; save in E
c,10h
; service 10
mos
; generate a pitch according to DE
loop
; do it again
DATA
INSTRUCTION
DB
IN
12
12
0F
RRC
0F
RRC
5F
MOV
E,A
E6
ANI
3FH
3F
57
MOV
D,A
7B
MOV
A,E
E6
ANI
0C0H
C0
5F
MOV
E,A
0E
MVI
C,10H
10
CD
CALL 1000H
00
10
C3
JMP
FF01
01
FF
67

Advertisement

Table of Contents
loading

Table of Contents