Presentation for a research paper work for an Elevator control with microprocessor Intel 8085A.
Subject: Microprocessors and microcontrollers.
Sashko Krstevski 161
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Implementaion of an elevator control with two cabins, by using Intel's 8085A microprocessor
1. МИКРОПРОЦЕСОРИ И
МИКРОКОНТРОЛЕРИ
Контрола на лифт со две кабини со користење
ннаа ммииккррооппррооццеессоорр
Intel 8085
Презентацијата претставува истражување кое може да се применува исклучиво за образовни цели.
За поширока примена, потребни се дополнителни истражувања, дополнувања, измени и тестови.
Кандидат:
Сашко Крстевски 161
Ментор:
Проф. д-р Цветко Митровски
Битола, 2014
3. БЛОК ДИЈАГРАМ
IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците
4. БЛОК ДИЈАГРАМ
IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците
CPU картица – извршување на главната програма
5. БЛОК ДИЈАГРАМ
IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците
CPU картица – извршување на главната програма
ECC картица – контрола на електричните мотори
6. БЛОК ДИЈАГРАМ
IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците
CPU картица – извршување на главната програма
ECC картица – контрола на електричните мотори
EIF картица – обработка на сигналите од катовите (копчиња) и приказ за корисникот (дисплеи)
7. БЛОК ДИЈАГРАМ
IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците
CPU картица – извршување на главната програма
ECC картица – контрола на електричните мотори
EIF картица – обработка на сигналите од катовите (копчиња) и приказ за корисникот (дисплеи)
FIF картица – обработка на сигнали од кабината и потврдување на состојбата на копчињата
8. КОМУНИКАЦИЈА
00000 Command Data CRC
Header
Req/Res
Cabin Number
or
Node address
8b 8b 8b 8b
40b
r
sp
2b 1b 5b
8b
Поле Значење
Header Почеток на порака
Request/Response Барање или одговор
N/A 00000 - неискористени
Cabine_number/Node_address Број на кабина и/или адреса на јазол (256)
Command Наредба
Data Податок (за наредбата)
CRC Checksum
9. КОМУНИКАЦИЈА
Наредба Код Податок Значење Насока
start_motor 0x40 Cab. number Да започне моторот со работа CPUECC
slow_down_motor 0x41 Cab. number Моторот да ја намали брзината CPUECC
speed_up_motor 0x42 Cab. number Моторот да ја зголеми брзината CPUECC
stop_motor 0x43 Cab. number Да запре моторот со работа CPUECC
find_cabine 0x44 Level На кој кат ссее ннааооѓѓаа ккааббииннааттаа bbootthh
Комуникација CPU-ECC
Наредба Код Податок Значење Насока
calc_closest_cabine 0x10 Level Која кабина да стигне до корисникот IFCPU
stop_sys_err 0x11 Да се запре системот, настаната е грешка both
cpu_error 0x12 Грешка во CPU картицата CPUIF
start_sys 0x13 Да започне системот со работа CPUIF
stop_sys 0x14 Да запре системот со работа CPUIF
closest_cabine 0x15 1 or 2 Одговор на пораката calc_closest_cabine CPUIF
ping_if 0x16 Проверка на IF картицата CPUIF
test_equ 0x17 Тест на опремата CPUIF
check_srvc_days 0x18 Проверка кога треба да се изврши сервис CPUIF
Комуникација CPU-IF и IF-CPU
10. ПРЕСМЕТКА
кадешто:
cbn – closest cabin number (број на кабината која ќе стигне најбрзо до одредиштето)
Формирањето и пресметката на одговорот
nl – next level (кат кон кој моментално се движи кабината)
cl – current level (кат на кој моментално се наоѓа кабината)
rl – requested level (кат – одредиште)
12. ЕЛЕКТРОНСКА ШЕМА
Сигналите/Линиите во микропроцесорот 8085:
•Сигнали за напојување и фреквенции
•Податочни и адресни магистрали
•Управувачка/контролна магистрала
•Сигнали за прекини
•Сериски I/O сигнали
•DMA сигнали (меморија со директен пристап)
•Сигнали за ресет
13. ЕЛЕКТРОНСКА ШЕМА
Функционални блокови:
•Регистри
•Аритемтичко-логичка едница (ALU)
•Адресен бафер
•Леч коло за инкрементирање/декрементирање на адреса
•Контрола на прекини
•Контрола/управување на сериски I/O порти
•Електронски кола за контрола и тајминзи
•Декодер на инструкции и енкодер на машинските циклуси
14. ЕЛЕКТРОНСКА ШЕМА
Статична меморија: RАМ Intel 8155 – 2kb Меморија за чување на параметри: EPROM Intel 8775 – 16kb
20. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
21. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
22. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
23. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
read_8755:
DI ; disable interrupts
LXI H, 4000h
MOV L, C ; the address to read from ROM
MOV A, M ; load the data into reg. A
ret
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
write_8155:
DI ; disable interrupts
LXI H, 2000h
MOV L, C ; the address to write to RAM
MOV M, A ; write data to memory location
ret
24. 1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
PC
АЛГОРИТАМ НА ИЗВРШУВАЊЕ
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
25. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
PC
Формрање на адреса за читате од EPROM:
read_8755:
Поставување на адресните пинови (адресирање на 8755)
DI ; disable interrupts
LXI H, 4000h
MOV L, C ; the address to read from ROM
MOV A, M ; load the data into reg. A
ret
26. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
PC
Формрање на адреса за читате од EPROM:
read_8755:
Поставување на адресните пинови (адресирање на 8755)
Поставување на адреса на мемориска локација за читање
DI ; disable interrupts
LXI H, 4000h
MOV L, C ; the address to read from ROM
MOV A, M ; load the data into reg. A
ret
27. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
PC
Формрање на адреса за читате од EPROM:
read_8755:
Поставување на адресните пинови (адресирање на 8755)
Поставување на адреса на мемориска локација за читање
DI ; disable interrupts
LXI H, 4000h
MOV L, C ; the address to read from ROM
MOV A, M ; load the data into reg. A
ret
28. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Формрање на адреса за читате од EPROM:
Поставување на адресните пинови (адресирање на 8755)
Поставување на адреса на мемориска локација за читање
29. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Формрање на адреса за читате од EPROM:
Читање на податок од мемориска локација
30. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
PC
Формрање на адреса за читате од EPROM:
read_8755:
Читање на податок од EPROM (8755)
DI ; disable interrupts
LXI H, 4000h
MOV L, C ; the address to read from ROM
MOV A, M ; load the data into reg. A
ret
31. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
PC
Формрање на адреса за запишување во RAM:
write_8155:
Поставување на адресните пинови (адресирање на 8155)
DI ; disable interrupts
LXI H, 2000h
MOV L, C ; the address to write to RAM
MOV M, A ; write data to memory location
ret
32. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
PC
Формрање на адреса за запишување во RAM:
write_8155:
Поставување на адресните пинови (адресирање на 8155)
Поставување на адреса на мемориска локација за запишување
DI ; disable interrupts
LXI H, 2000h
MOV L, C ; the address to write to RAM
MOV M, A ; write data to memory location
ret
33. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
PC
Формрање на адреса за запишување во RAM:
write_8155:
Поставување на адресните пинови (адресирање на 8155)
Поставување на адреса на мемориска локација за запишување
DI ; disable interrupts
LXI H, 2000h
MOV L, C ; the address to write to RAM
MOV M, A ; write data to memory location
ret
34. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Формрање на адреса за запишување во RAM:
Поставување на адресните пинови (адресирање на 8155)
Поставување на адреса на мемориска локација за запишување
35. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Формрање на адреса за запишување во RAM:
Запишување на податок во мемориска локација
36. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
PC
Формрање на адреса за запишување во RAM:
write_8155:
Запишување на податoк во RAM
DI ; disable interrupts
LXI H, 2000h
MOV L, C ; the address to write to RAM
MOV M, A ; write data to memory location
ret
37. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment PC
the command counter
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
38. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
PC
39. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
PC
40. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
PC
41. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
PC
42. 1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
PC
АЛГОРИТАМ НА ИЗВРШУВАЊЕ
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
43. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
PC
44. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
read_cmds_EPROM2RAM:
DI ; disable interrupts
MVI B, 60h ; load 96 commands constant
MVI C, 00h ; init 96 commands counter
read_rom_to_ram:
call read_8755
call write_8155
INR C ; increment the command counter
MOV A, B ; copy the data from B to A
CMP C ; compare if all cmd locations are copied
JNZ read_rom_to_ram
EI ; enable interrupts
ret
PC
45. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Намена на регистри:
A – податокот од важност
B – константа, број на податоци за читање
C – бројач за прочитани податоци (наредби)
46. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
47. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
PC
init_8251: DI ; disable interrupts
LXI H, 06800h ; address for the 8251: CS = 0 and C/D = 1 (Control)
MVI A, 00h
MOV M, A ; write 00 to memory location 6800 (to set the address lines to 6800, only)
OUT 068h
OUT 068h ; dummy mode word
OUT 068h
MVI A, 40h ; reset command word
OUT 068h ; reset 8251
MVI A, 4Ah ; mode word initialization (1 stop bit, no parity, char length 7, baud rate x 16)
OUT 068h ; send the mode word
MVI A, 15h ; word to enable the transmitter and the receiver of the 8251
OUT 068h
check_RxRDY: IN 068h ; get 8251 status register value - check if RxRDY = 1
ANI 02h ; check the value of the RxRDY (reg A AND 02H)
JZ check_RxRDY ; jump to check_RxRDY if the receiver is not ready
check_TxRDY: IN 0FFh ; get 8251 status register value - check if TxRDY = 1
ANI 01h ; check if the transmitter is ready
JZ check_TxRDY ; jump to check_TxRDY if the transmitter is not ready
; set 8251 to transmit mode
LXI H, 07000h ; address for the 8251: CS = 0 and C/D = 0 (Data - Transmitter)
MVI A, 00h
MOV M, A ; write 00 to memory location 7000 (to set the address lines to 7000, only)
EI ; enable interrupts
ret
48. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Формрање на адреса за запишување во контролниот регистар:
Поставување на адресни линии
PC
init_8251: DI ; disable interrupts
LXI H, 06800h ; address for the 8251: CS = 0 and C/D = 1 (Control)
MVI A, 00h
MOV M, A ; write 00 to memory location 6800 (to set the address lines to 6800, only)
...
49. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Формрање на адреса за запишување во контролниот регистар:
Поставување на адресни линии
51. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
PC
Запишување во контролниот регистар:
Ресетирање на ИК (Internal Reset)
…
MVI A, 40h ; reset command word
OUT 068h ; reset 8251
…
52. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Запишување во контролниот регистар:
Ресетирање на ИК (Internal Reset)
53.
54. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
PC
Запиушвање во Mode регистарот:
Поставување на мод на работа
...
MVI A, 4Ah ; mode word initialization (1 stop bit, no parity, char length 7, baud rate x 16)
OUT 068h ; send the mode word
...
55. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Запиушвање во Mode регистарот:
Поставување на мод на работа
56.
57. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
PC
Запишување во контролниот регистар:
Овозможување на работа како примо-предавател
...
MVI A, 15h ; word to enable the transmitter and the receiver of the 8251
OUT 068h
...
58. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Запишување во контролниот регистар:
Овозможување на работа како примо-предавател
59.
60. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
PC
Читање на статусниот регистар:
Проверка на статусот на примникот
...
check_RxRDY: IN 068h ; get 8251 status register value - check if RxRDY = 1
ANI 02h ; check the value of the RxRDY (reg A AND 02H)
JZ check_RxRDY ; jump to check_RxRDY if the receiver is not ready
...
PC+2
61. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Читање на статусниот регистар:
Проверка на статусот на примникот
62.
63. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Читање на статусниот регистар:
...
Проверка на статусот на предавателот
check_TxRDY: IN 0FFh ; get 8251 status register value - check if TxRDY = 1
ANI 01h ; check if the transmitter is ready
JZ check_TxRDY ; jump to check_TxRDY if the transmitter is not ready
...
PC
PC+2
64. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Читање на статусниот регистар:
Проверка на статусот на предавателот
65.
66. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Формрање на адреса за поставување на ИК 8251 како предавател:
...
; set 8251 to transmit mode
LXI H, 07000h ; address for the 8251: CS = 0 and C/D = 0 (Data - Transmitter)
MVI A, 00h
MOV M, A ; write 00 to memory location 7000 (to set the address lines to 7000, only)
EI ; enable interrupts
ret
Поставување на адресни линии
PC
PC+3
PC+2
PC+1
67. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Формрање на адреса за поставување на ИК 8251 како предавател:
Поставување на адресни линии
68.
69. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
init_8251: DI ; disable interrupts
LXI H, 06800h ; address for the 8251: CS = 0 and C/D = 1 (Control)
MVI A, 00h
MOV M, A ; write 00 to memory location 6800 (to set the address lines to 6800, only)
OUT 068h
OUT 068h ; dummy mode word
OUT 068h
MVI A, 40h ; reset command word
OUT 068h ; reset 8251
MVI A, 4Ah ; mode word initialization (1 stop bit, no parity, char length 7, baud rate x 16)
OUT 068h ; send the mode word
MVI A, 15h ; word to enable the transmitter and the receiver of the 8251
OUT 068h
check_RxRDY: IN 068h ; get 8251 status register value - check if RxRDY = 1
ANI 02h ; check the value of the RxRDY (reg A AND 02H)
JZ check_RxRDY ; jump to check_RxRDY if the receiver is not ready
check_TxRDY: IN 0FFh ; get 8251 status register value - check if TxRDY = 1
ANI 01h ; check if the transmitter is ready
JZ check_TxRDY ; jump to check_TxRDY if the transmitter is not ready
; set 8251 to transmit mode
LXI H, 07000h ; address for the 8251: CS = 0 and C/D = 0 (Data - Transmitter)
MVI A, 00h
MOV M, A ; write 00 to memory location 7000 (to set the address lines to 7000, only)
EI ; enable interrupts
ret
70. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
71. 1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
init_system_vars:
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
ret
Запишување на почетна вредност (reset) на покажувачот кон
мемориската локација на првиот бајт на новата порака:
Поставување на адресни линии
PC
PC+3
АЛГОРИТАМ НА ИЗВРШУВАЊЕ
72. 1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
init_system_vars:
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
ret
Запишување на почетна вредност (reset) на покажувачот кон
мемориската локација на првиот бајт на новата порака:
Поставување на адресни линии
PC
PC+3
АЛГОРИТАМ НА ИЗВРШУВАЊЕ
73. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Запишување на почетна вредност (reset) на покажувачот кон
мемориската локација на првиот бајт на новата порака:
Поставување на адресни линии
74. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
Запишување на почетна вредност (reset) на покажувачот кон
мемориската локација на првиот бајт на новата порака:
Поставување на адресни линии
75. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
init_system_vars:
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
ret
Запишување на почетна вредност (reset) на покажувачот кон
мемориската локација на првиот бајт на новата порака:
Поставување на адресни линии
76. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
1. Иницијализација на системот:
-Копирање на податоци од ROM во RAM
-RS-232
-Иницијализација на променливи
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
77. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-Бесконечна јамка (чекање на прекин)
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
78. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-Бесконечна јамка (чекање на прекин)
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
PC
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
79. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-Бесконечна јамка (чекање на прекин)
msg_start_sys:
; header
MVI A, hdr ; copy header data into reg. A
ORI req ; set it as Request message
MVI C, rtx_hdr_msg_adr ; set the address for the header
call write_8155 ; write the message into RAM
EI ; enable interrupts
; address
MVI A, addr_if_card ; copy address of the IF card
MVI C, rtx_cabin_node_msg_adr ; set the address for the cabin/node address
call write_8155 ; write the message into RAM
EI ; enable interrupts
PC
; command
MVI A, cmd_start_sys ; copy the command
MVI C, rtx_command_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
; data (irrelevant)
MVI A, 0FFh ; copy data for the command
MVI C, rtx_data_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
; CRC (irrelevant)
MVI A, 0FFh ; copy data for the command
MVI C, rtx_crc_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
ret
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
80. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
msg_start_sys:
; header
MVI A, hdr ; copy header data into reg. A
ORI req ; set it as Request message
MVI C, rtx_hdr_msg_adr ; set the address for the header
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (HEADER)
-Бесконечна јамка (чекање на прекин)
81. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
msg_start_sys:
; header
MVI A, hdr ; copy header data into reg. A
ORI req ; set it as Request message
MVI C, rtx_hdr_msg_adr ; set the address for the header
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (HEADER)
-Бесконечна јамка (чекање на прекин)
82. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
msg_start_sys:
; header
MVI A, hdr ; copy header data into reg. A
ORI req ; set it as Request message
MVI C, rtx_hdr_msg_adr ; set the address for the header
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (HEADER)
-Бесконечна јамка (чекање на прекин)
83. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
msg_start_sys:
; header
MVI A, hdr ; copy header data into reg. A
ORI req ; set it as Request message
MVI C, rtx_hdr_msg_adr ; set the address for the header
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (HEADER)
-Бесконечна јамка (чекање на прекин)
84. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
; address
MVI A, addr_if_card ; copy address of the IF card
MVI C, rtx_cabin_node_msg_adr ;set the address for the cabin/node address
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (IF CARD ADDRESS)
-Бесконечна јамка (чекање на прекин)
85. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (IF CARD ADDRESS)
-Бесконечна јамка (чекање на прекин)
…
; address
MVI A, addr_if_card ; copy address of the IF card
MVI C, rtx_cabin_node_msg_adr ;set the address for the cabin/node address
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
86. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (IF CARD ADDRESS)
-Бесконечна јамка (чекање на прекин)
…
; address
MVI A, addr_if_card ; copy address of the IF card
MVI C, rtx_cabin_node_msg_adr ;set the address for the cabin/node address
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
87. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
; command
MVI A, cmd_start_sys ; copy the command
MVI C, rtx_command_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (COMMAND)
-Бесконечна јамка (чекање на прекин)
88. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-(COMMAND)
-Бесконечна јамка (чекање на прекин)
PC
…
; command
MVI A, cmd_start_sys ; copy the command
MVI C, rtx_command_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
89. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (COMMAND)
-Бесконечна јамка (чекање на прекин)
PC
…
; command
MVI A, cmd_start_sys ; copy the command
MVI C, rtx_command_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
90. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
; data (irrelevant)
MVI A, 0FFh ; copy data for the command
MVI C, rtx_data_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (DATA – IRRELEVANT NOW)
-Бесконечна јамка (чекање на прекин)
91. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (DATA – IRRELEVANT NOW)
-Бесконечна јамка (чекање на прекин)
PC
…
; data (irrelevant)
MVI A, 0FFh ; copy data for the command
MVI C, rtx_data_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
92. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (DATA – IRRELEVANT NOW)
-Бесконечна јамка (чекање на прекин)
PC
…
; data (irrelevant)
MVI A, 0FFh ; copy data for the command
MVI C, rtx_data_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
93. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
; CRC (irrelevant)
MVI A, 0FFh ; copy data for the command
MVI C, rtx_crc_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
ret
PC
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (CRC – IRRELEVANT NOW)
-Бесконечна јамка (чекање на прекин)
94. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (CRC – IRRELEVANT NOW)
-Бесконечна јамка (чекање на прекин)
PC
…
; CRC (irrelevant)
MVI A, 0FFh ; copy data for the command
MVI C, rtx_crc_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
ret
95. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
Намена на регистри:
A – податокот од важност
C – адреса во RAM за бајт од пораката
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
- (CRC – IRRELEVANT NOW)
-Бесконечна јамка (чекање на прекин)
PC
…
; CRC (irrelevant)
MVI A, 0FFh ; copy data for the command
MVI C, rtx_crc_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
ret
96. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-Бесконечна јамка (чекање на прекин)
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
97. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-Бесконечна јамка (чекање на прекин)
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
98. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-Бесконечна јамка (чекање на прекин)
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
99. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-Бесконечна јамка (чекање на прекин)
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
PC+1
PC+1
PC+1
100. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
2. Почеток на работа на системот
-Формирање и испраќање на порака за стартување на системот
-Бесконечна јамка (чекање на прекин)
start: nop
; read parameters form the EPROM memory
; - read available messages
; *** initialize the system ***
call read_cmds_EPROM2RAM
call init_8251
call init_system_vars
call msg_start_sys
call transmit_8251 ; send over RS-485
endless_loop: nop
nop
nop
JMP endless_loop
hlt
PC
PC+1
PC+1
PC+1
101. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
102. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
cabin current level next level requested level
1 8 5 2
2 5 5 2
103. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
1. Оневозможување на прекини (DI)
2. Зачувување на содржината на регистрите на Stack
3. Обработка на прекинот (Interrupt Service Routine – ISR)
4. Враќање не содржината на регистрите од Stack
5. Овозможување на прекини (EI)
104. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
105. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
ISR_low_003CH: DI
PUSH B
PUSH D
PUSH H
call ISR_high_003CH ; process the interrupt
POP B
POP D
POP H
PC
PC+1
PC+1
PC+1
EI
ret
106. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
- Обработка на примена порака
-Примен е Прв бајт на порака
- Составување и испраќање на одговор
107. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
PC
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
...
...
new_message:
LXI H, rx_msg_counter_16b ; point to the ccoouunntteerr iinn RRAAMM mmeemm..
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
MOV A, B ; return the value to the acc A
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
ret
108. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
PC
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
...
...
new_message:
LXI H, rx_msg_counter_16b ; point to the ccoouunntteerr iinn RRAAMM mmeemm..
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
MOV A, B ; return the value to the acc A
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
ret
109. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
PC
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
...
...
new_message:
LXI H, rx_msg_counter_16b ; point to the ccoouunntteerr iinn RRAAMM mmeemm..
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
MOV A, B ; return the value to the acc A
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
ret
110. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
PC
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
...
...
new_message:
LXI H, rx_msg_counter_16b ; point to the ccoouunntteerr iinn RRAAMM mmeemm..
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
MOV A, B ; return the value to the acc A
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
ret
111. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
PC
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
...
...
new_message:
LXI H, rx_msg_counter_16b ; point to the PC+78
ccoouunntteerr iinn RRAAMM mmeemm..
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
MOV A, B ; return the value to the acc A
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
ret
112. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
PC
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
...
...
new_message:
LXI H, rx_msg_counter_16b ; point to the ccoouunntteerr iinn RRAAMM mmeemm..
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
MOV A, B ; return the value to the acc A
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
ret
PC
…
113. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
...
...
new_message:
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
PC
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
MOV A, B ; return the value to the acc A
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
ret
…
PC
114. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
...
...
new_message:
LXI H, rx_msg_counter_16b ; point to the ccoouunntteerr iinn RRAAMM mmeemm..
MVI A, 60h ; set acc. A to 60h - the location of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
MOV A, B ; return the value to the acc A
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
ret
PC
115. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
MOV A, B ; return the value to the acc A
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
INR M ; increment the counter
PC
…
PC
PC0x422C
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
; check if it was the last byte of a message
MVI C, rx_msg_counter ; set address for the counter
call read_8155 ; move the counter value into the acc. A
CPI 65h ; compare the counter with value 65h
; (last mem. location, addr. of the last byte of a message)
JZ message_received
; if not, ret and wait for another byte to complete it
ret
116. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
MOV A, B ; return the value to the acc A
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
INR M ; increment the counter
PC
…
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
; check if it was the last byte of a message
MVI C, rx_msg_counter ; set address for the counter
call read_8155 ; move the counter value into the acc. A
CPI 65h ; compare the counter with value 65h
; (last mem. location, addr. of the last byte of a message)
JZ message_received
; if not, ret and wait for another byte to complete it
ret
PC
117. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
MOV A, B ; return the value to the acc A
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
INR M ; increment tthhee ccoouunntteerr
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
; check if it was the last byte of a message
MVI C, rx_msg_counter ; set address for the counter
call read_8155 ; move the counter value into the acc. A
CPI 65h ; compare the counter with value 65h
; (last mem. location, addr. of the last byte of a message)
JZ message_received
; if not, ret and wait for another byte to complete it
ret
PC
…
PC
PC0x423F
118. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
ISR_high_003CH:
call receive_8251
MOV B, A ; make a copy
ANI hdr ; logical AND to get the (Start of Frame - SOF) bits, only
CPI hdr ; compare if the value in A is 0Ch (SOF)
JZ new_message
MOV A, B ; return the value to the acc A
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
INR M ; increment tthhee ccoouunntteerr
MOV C, M ; copy the counter value into reg. C (form the mem. address)
call write_8155 ; copy the received data into the RAM recv. buffer
; check if it was the last byte of a message
MVI C, rx_msg_counter ; set address for the counter
call read_8155 ; move the counter value into the acc. A
CPI 65h ; compare the counter with value 65h
; (last mem. location, addr. of the last byte of a message)
JZ message_received
; if not, ret and wait for another byte to complete it
ret
; if it is then a msg is received: process the message and set the counter to zero
message_received:
PC
…
PC
PC0x4240
119. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
120. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
; if it is then a msg is received: process the message and set the counter to zero
message_received:
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
MVI A, 60h ; set acc. A to 60h - the locatin of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
; processing of a message
; check if the msg. is for the CPU card
MVI C, rtx_cabin_node_msg_adr ; set the pointer to 61h
; address/receiver specified in the msg.
call read_8155
PC
…
PC
; read the address
CPI addr_cpu_card ; compare the address recv. with the address of the CPU card
JZ message_for_cpu
; if not CPU add - ret.
ret
121. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
; if it is then a msg is received: process the message and set the counter to zero
message_received:
LXI H, rx_msg_counter_16b ; point to the counter in RAM mem.
MVI A, 60h ; set acc. A to 60h - the locatin of the first recv. byte of a msg.
MOV M, A ; reset the counter to 60h (prepare it for a new message)
; processing of a message
; check if the msg. is for the CPU card
MVI C, rtx_cabin_node_msg_adr ; set the pointer to 61h
; address/receiver specified in the msg.
call read_8155
PC
…
; read the address
CPI addr_cpu_card ; compare the address recv. with the address of the CPU card
JZ message_for_cpu
; if not CPU add - ret.
ret
message_for_cpu:
PC
PC0x4251
122. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
123. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
message_for_cpu:
; check if it is a request message
MVI C, rtx_hdr_msg_adr ; set the pointer to the SOF/header
call read_8155 ; read the address
PC
…
ANI req ; acc. A AND 0001 0000 (if it is a request)
JNZ message_is_req
; if not req. then ret
ret
message_is_req:
PC
PC0x425D
#2060h: D0h = 1101 0000b
req = 10h = 0001 0000b
1101 0000b
AND 0001 0000b
------------------------
0001 0000b = 10h
124. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
125. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
message_is_req:
; check if the command is known for this system
; skip this step, the command exists, check if it is calc_closest_cabin msg
MVI C, rtx_command_msg_adr ; set the pointer to the command field
; of the recv. msg
call read_8155 ; read the address
CPI cmd_calc_closest_cabin ; check if it is the cmd_calc_closest_cabin msg/req
JZ check_data_of_the_msg ; if it is the msg. then jump to...
call send_msg_err_cmd ; if it is an unknown command then send err msg.
; OR NOT calc_closest_cabin send err. msg
PC
…
PC
check_data_of_the_msg:
; check the data of the command/packet
; it must be a cmd_calc_closest_cabin, so transfer the data into
; reg. B (as req. by the subroutines)
MVI C, rtx_data_msg_adr ; load address of the data field of the recv. msg
call read_8155 ; read the data
MOV B, A ; move it to reg. B, as requested by the subroutines
call find_cabins ; do not modify reg. B. find the cabines and
; calc. the closest to send. and send it
ret
PC0x426B
126. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
message_is_req:
; check if the command is known for this system
; skip this step, the command exists, check if it is calc_closest_cabin msg
MVI C, rtx_command_msg_adr ; set the pointer to the command field
; of the recv. msg
call read_8155 ; read the address
CPI cmd_calc_closest_cabin ; check if it is the cmd_calc_closest_cabin msg/req
JZ check_data_of_the_msg ; if it is the msg. then jump to...
call send_msg_err_cmd ; if it is an unknown command then send err msg.
; OR NOT calc_closest_ccaabbiinn sseenndd eerrrr.. mmssgg
check_data_of_the_msg:
; check the data of the command/packet
; it must be (for this example) a cmd_calc_closest_cabin, so transfer the data into
; reg. B (as req. by the subroutines)
MVI C, rtx_data_msg_adr ; load address of the data field of the recv. msg
call read_8155 ; read the data
MOV B, A ; move it to reg. B, as requested by the subroutines
call find_cabins ; do not modify reg. B. find the cabines and
; calc. the closest to send. and send it
ret
PC
…
PC
127. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
find_cabins:
MVI A, 01h ; parameter for find_cabin (first cabin)
call find_cabin ; prepare and send msg
MVI A, 02h ; parameter for find_cabin (second cabin)
call find_cabin ; prepare and send msg
;if msgs for cab_01/02 were received, then calc the closest cabin
call msg_calc_closest_cabin
call transmit_8251
ret
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
PC
PC+2
find_cabin:
call msg_find_cabin
call transmit_8251
ret
PC
симулација
128. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
msg_find_cabin:
MOV D, A ; make a copy
; header
MVI A, hdr ; copy header data into reg. A
ORI req ; set it as Request message
MVI C, rtx_hdr_msg_adr ; set the address for the header
call write_8155 ; write the message into RAM
EI ; enable interrupts
; address
MVI A, addr_ecc_card ; ECC address
MVI C, rtx_cabin_node_msg_adr ; set the address for the cabin/node address
call write_8155 ; write the message into RAM
EI ; enable interrupts
; command
MVI A, cmd_find_cabin ; copy the command
MVI C, rtx_command_msg_adr; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
; data (from reg. A)
MOV D, A ; return the copy
MVI C, rtx_data_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
; CRC (irrelevant)
MVI A, 055h ; copy data for the command
MVI C, rtx_crc_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
ret
Намена на регистри:
A – податокот од важност
B – кат - одредиште
C – адреса во RAM за бајт од пораката
129. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
msg_find_cabin:
MOV D, A ; make a copy
; header
MVI A, hdr ; copy header data into reg. A
ORI req ; set it as Request message
MVI C, rtx_hdr_msg_adr ; set the address for the header
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
…
PC
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (HEADER)
Намена на регистри:
A – податокот од важност
B – кат - одредиште
C – адреса во RAM за бајт од пораката
130. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (ADDRESS)
…
; address
MVI A, addr_ecc_card ; ECC address
MVI C, rtx_cabin_node_msg_adr ; set the address for the cabin/node address
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
…
PC
Намена на регистри:
A – податокот од важност
B – кат - одредиште
C – адреса во RAM за бајт од пораката
131. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (COMMAND)
…
; command
MVI A, cmd_find_cabin ; copy the command
MVI C, rtx_command_msg_adr; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
…
PC
Намена на регистри:
A – податокот од важност
B – кат - одредиште
C – адреса во RAM за бајт од пораката
132. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (DATA)
…
; data (from reg. A)
MOV D, A ; return the copy
MVI C, rtx_data_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
…
PC
Намена на регистри:
A – податокот од важност
B – кат - одредиште
C – адреса во RAM за бајт од пораката
133. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
; CRC (irrelevant)
MVI A, 055h ; copy data for the command
MVI C, rtx_crc_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
ret
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (CRC - irrelevant)
PC
…
PC
Намена на регистри:
A – податокот од важност
B – кат - одредиште
C – адреса во RAM за бајт од пораката
134. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Примен е одговор)
Намена на регистри:
A – податокот од важност
B – кат - одредиште
C – адреса во RAM за бајт од пораката
2080h Локација кон која се движи кабина 1 r_cabin_01
2081h Локација кон која се движи кабина 2 r_cabin_02
2082h Број на катови од кабина 1 до бараниот кат r_diff_cabin_01
2083h Број на катови од кабина 2 до бараниот кат r_diff_cabin_02
2084h Кат на кој се наоѓа кабина 1 (моментално) r_curr_cabin_01
2085h Кат на кој се наоѓа кабина 2 (моментално) r_curr_cabin_02
135. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
find_cabins:
MVI A, 01h ; parameter for find_cabin (first cabin)
call find_cabin ; prepare and send msg
MVI A, 02h ; parameter for find_cabin (second cabin)
call find_cabin ; prepare and send msg
;if msgs for cab_01/02 were received, then calc the closest cabin
call msg_calc_closest_cabin
call transmit_8251
ret
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
PC
PC+2
find_cabin:
call msg_find_cabin
call transmit_8251
ret
PC
симулација
136. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Примен е одговор)
Намена на регистри:
A – податокот од важност
B – кат - одредиште
C – адреса во RAM за бајт од пораката
2080h Локација кон која се движи кабина 1 r_cabin_01
2081h Локација кон која се движи кабина 2 r_cabin_02
2082h Број на катови од кабина 1 до бараниот кат r_diff_cabin_01
2083h Број на катови од кабина 2 до бараниот кат r_diff_cabin_02
2084h Кат на кој се наоѓа кабина 1 (моментално) r_curr_cabin_01
2085h Кат на кој се наоѓа кабина 2 (моментално) r_curr_cabin_02
137. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
msg_calc_closest_cabin:
; header
MVI A, hdr ; copy header data into reg. A
ORI res ; set it as Response message
MVI C, rtx_hdr_msg_adr ; set the address for the header
call write_8155 ; write the message into RAM
EI ; enable interrupts
; address
MVI A, addr_if_card ; broadcast address
MVI C, rtx_cabin_node_msg_adr ; set the address for the cabin/node address
PC
…
call write_8155 ; write the message into RAM
EI ; enable interrupts
; command
MVI A, cmd_closest_cabin ; copy the command
MVI C, rtx_command_msg_adr ; set the address for the command
call write_8155 ; write the message into RAM
EI ; enable interrupts
…
PC
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 /
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
A: C0h = 1100 0000b
res = 20h = 0010 0000b
1100 0000b
OR 0010 0000b
------------------------
1110 0000b = E0h
138. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
…
; enable interrupts
; calc the closest cabin
; - the location of the second cabin is in 2086h
MVI C, r_curr_cabin_01 ; get the current location
call read_8155 ; get the data from predefined memory location in RAM
LXI H, r_cabin_01_16b ; (next) setup the mem. location of the next location of cabin 01
SUBM ; substract (next - current), ignore the sign
JP not_negative_01 ; jump to the next instruction if not negative
CMA ; first complement (it is negative number)
PC
PC+2
ADI 01h ; add 1 to get the actual result (absolute value)
not_negative_01:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 /
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
139. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
; enable interrupts
; calc the closest cabin
; - the location of the second cabin is in 2086h
MVI C, r_curr_cabin_01 ; get the current location
call read_8155 ; get the data from predefined memory location in RAM
LXI H, r_cabin_01_16b ; (next) setup the mem. location of the next location of cabin 01
SUBM ; substract (next - current), ignore the sign
JP not_negative_01 ; jump to the next instruction if not negative
CMA ; first complement (it is negative number)
PC
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
ADI 01h ; add 1 to get the actual result (absolute value)
not_negative_01:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 /
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
140. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
; enable interrupts
; calc the closest cabin
; - the location of the second cabin is in 2086h
MVI C, r_curr_cabin_01 ; get the current location
call read_8155 ; get the data from predefined memory location in RAM
LXI H, r_cabin_01_16b ; (next) setup the mem. location of the next location of cabin 01
SUBM ; substract (next - current), ignore the sign
JP not_negative_01 ; jump to the next instruction if not negative
CMA ; first complement (it is negative number)
PC
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
ADI 01h ; add 1 to get the actual result (absolute value)
not_negative_01:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 /
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
141. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
; enable interrupts
; calc the closest cabin
; - the location of the second cabin is in 2086h
MVI C, r_curr_cabin_01 ; get the current location
call read_8155 ; get the data from predefined memory location in RAM
LXI H, r_cabin_01_16b ; (next) setup the mem. location of the next location of cabin 01
SUBM ; substract (next - current), ignore the sign
JP not_negative_01 ; jump to the next instruction if not negative
CMA ; first complement (it is negative number)
PC
…
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
ADI 01h ; add 1 to get the actual result (absolute value)
not_negative_01:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 /
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
PC
142. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
not_negative_01:
MVI C, r_diff_cabin_01 ; store diff_01 (temp)
call write_8155
LXI H, r_cabin_01_16b ; (next) setup the mem. location of the next location of cabin 01
MOV A, M ; copy next msg_calc_closest_cabin level to reg. A
SUB B ; sub. A-B (next - requested) and store in reg. A
JP not_negative_02 ; jump to the next instruction if not negative
CMA
; first complement (it is negative number)
PC
PC+2
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
ADI 01h ; add 1 to get the actual result (absolute value)
not_negative_02:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 3
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
143. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
not_negative_01:
MVI C, r_diff_cabin_01 ; store diff_01 (temp)
call write_8155
LXI H, r_cabin_01_16b ; (next) setup the mem. location of the next location of cabin 01
MOV A, M ; copy next msg_calc_closest_cabin level to reg. A
SUB B ; sub. A-B (next - requested) and store in reg. A
JP not_negative_02 ; jump to the next instruction if not negative
CMA
; first complement (it is negative number)
PC
PC+3
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
ADI 01h ; add 1 to get the actual result (absolute value)
not_negative_02:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 3
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
144. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
not_negative_01:
MVI C, r_diff_cabin_01 ; store diff_01 (temp)
call write_8155
LXI H, r_cabin_01_16b ; (next) setup the mem. location of the next location of cabin 01
MOV A, M ; copy next msg_calc_closest_cabin level to reg. A
SUB B ; sub. A-B (next - requested) and store in reg. A
JP not_negative_02 ; jump to the next instruction if not negative
CMA
; first complement (it is negative number)
PC
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
ADI 01h ; add 1 to get the actual result (absolute value)
not_negative_02:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 3
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
145. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
…
not_negative_01:
MVI C, r_diff_cabin_01 ; store diff_01 (temp)
call write_8155
LXI H, r_cabin_01_16b ; (next) setup the mem. location of the next location of cabin 01
MOV A, M ; copy next msg_calc_closest_cabin level to reg. A
SUB B ; sub. A-B (next - requested) and store in reg. A
JP not_negative_02 ; jump to the next instruction if not negative
CMA
; first complement (it is negative number)
PC
…
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
ADI 01h ; add 1 to get the actual result (absolute value)
not_negative_02:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 3
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
PC
146. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
not_negative_02:
LXI H, r_diff_cabin_01_16b ; point to the diff_01
ADDM ; add (next - current) + (next - requested)
call write_8155 ; store the difference into RAM
; add 1 to get the actual result (absolute value)
…
PC
…
PC
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина I)
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 6
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
147. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина II)
…
; calc the closest cabin
; - the location of the second cabin is in 2085h
MVI C, r_curr_cabin_02 ; get the current location
call read_8155 ; get the data from predefined memory location in RAM
LXI H, r_cabin_02_16b ; setup the mem. location of the next location of cabin 01
SUBM ; substract (next - current), ignore the sign
JP not_negative_03 ; jump to the next instruction if not negative
CMA ; first complement (it is negative number)
ADI 01h ; add 1 to get the actual result (absolute value)
PC
PC+2
not_negative_03:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 6
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
148. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина II)
…
; calc the closest cabin
; - the location of the second cabin is in 2085h
MVI C, r_curr_cabin_02 ; get the current location
call read_8155 ; get the data from predefined memory location in RAM
LXI H, r_cabin_02_16b ; setup the mem. location of the next location of cabin 01
SUBM ; substract (next - current), ignore the sign
JP not_negative_03 ; jump to the next instruction if not negative
CMA ; first complement (it is negative number)
ADI 01h ; add 1 to get the actual result (absolute value)
PC
not_negative_03:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 6
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5
149. АЛГОРИТАМ НА ИЗВРШУВАЊЕ
3. Обработка на прекин
-Обработка на примена порака
-Составување и испраќање на одговор
- (Кабина II)
…
; calc the closest cabin
; - the location of the second cabin is in 2085h
MVI C, r_curr_cabin_02 ; get the current location
call read_8155 ; get the data from predefined memory location in RAM
LXI H, r_cabin_02_16b ; setup the mem. location of the next location of cabin 01
SUBM ; substract (next - current), ignore the sign
JP not_negative_03 ; jump to the next instruction if not negative
CMA ; first complement (it is negative number)
ADI 01h ; add 1 to get the actual result (absolute value)
PC
not_negative_03:
…
2080h r_cabin_01 5
2081h r_cabin_02 5
2082h r_diff_cabin_01 6
2083h r_diff_cabin_02 /
2084h r_curr_cabin_01 8
2085h r_curr_cabin_02 5