EMAC PRIMER Instruction Manual page 66

Table of Contents

Advertisement

LESSON 21: Using Monitor Operating System Subroutines
This lesson illustrates the use of one of the Monitor Operating System (MOS) subroutines. These subroutines
(also called services) that are in ROM can be run by loading the C register with the service number and executing a CALL
1000H. You may also do it without writing a program or affecting the PC register, by loading the appropriate registers and
pressing "func." then "2". All registers that are not used as input or output to the service are not affected. Please refer to
appendix D for the description of the MOS services.
An example program using MOS services:
The following example outputs the hex number 1234 to the left four numerical displays.
mos
equ
ledhex
equ
org
mvi
lxi
call
wait:
jmp
end
ADDRESS
FF01
FF02
FF03
FF04
FF05
FF06
FF07
FF08
FF09
FF0A
FF0B
Load the program into memory, press the reset button then run it. You will see "1234" on the "ADDRESS/REGISTER
PAIR" displays and it will continue to display until you press the reset button.
FF06 which is the address of the CALL 1000 instruction. Single step again and you will see that instead of the program
stopping at the instruction at the address of the subroutine being CALLed, as in the previous lesson, the program will stop
at the instruction following the CALL 1000 instruction. The reason for this inconsistency is that the MOS checks to see if
the CALL that is being single stepped is in ROM or RAM, and if it is in ROM it will run the subroutine full speed until it is
finished. This is because the method of single stepping used by the PRIMER requires the instructions being single stepped
to be in RAM. You will also notice that you couldn't see the numbers "1234" when the subroutine was run. The numbers
were actually displayed, but as soon as they were, the MOS returned to data entry mode and they were overwritten. This
occurs any time you single step a service that uses the digital displays. Store a 0 at FF02 so after the first instruction is
executed, the C register will be loaded with 0 instead of 12h. This time when you run the program service 0 will be
executed instead of service 12.
For more examples of programs that use MOS services, see the next two lessons which use the ADCIN and PITCH
services. The last lesson uses the KEYIN and LEDHEX services.
1000h
12h
0ff01h
; program starts at this address
c,ledhex
; ledhex service routine
d,1234h
; load DE with 1234 hex
mos
; call MOS for ledhex service
wait
; loop here till reset is pressed
; so display won't be erased.
; programs terminate with a rst 7
DATA
INSTRUCTION
0E
; MVI C,12
12
11
; LXI D,1234
34
12
CD
; CALL 1000
00
10
C3
; JMP 0FF09
09
FF
Press the reset button and single step to
66
Normally

Advertisement

Table of Contents
loading

Table of Contents