Implementaion of an elevator control with two cabins, by using Intel's 8085A microprocessor

Post on 10-Jul-2015

72 views 3 download

transcript

МИКРОПРОЦЕСОРИ И

МИКРОКОНТРОЛЕРИ

Контрола на лифт со две кабини со користење

на микропроцесорна микропроцесор

Intel 8085

Кандидат:Сашко Крстевски 161

Ментор:

Проф. д-р Цветко Митровски

Битола, 2014

Презентацијата претставува истражување кое може да се применува исклучиво за образовни цели.За поширока примена, потребни се дополнителни истражувања, дополнувања, измени и тестови.

БЛОК ДИЈАГРАМ

БЛОК ДИЈАГРАМ

IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците

БЛОК ДИЈАГРАМ

IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците

CPU картица – извршување на главната програма

БЛОК ДИЈАГРАМ

IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците

CPU картица – извршување на главната програма

ECC картица – контрола на електричните мотори

БЛОК ДИЈАГРАМ

IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците

CPU картица – извршување на главната програма

ECC картица – контрола на електричните мотори

EIF картица – обработка на сигналите од катовите (копчиња) и приказ за корисникот (дисплеи)

БЛОК ДИЈАГРАМ

IF картица – централна картица која креира одвоен интерфејс кон FIF и EIF картиците

CPU картица – извршување на главната програма

ECC картица – контрола на електричните мотори

EIF картица – обработка на сигналите од катовите (копчиња) и приказ за корисникот (дисплеи)

FIF картица – обработка на сигнали од кабината и потврдување на состојбата на копчињата

00000 C om m and D ata C R C

Header

Req/R

es

C ab in N um beror

N ode address

КОМУНИКАЦИЈА

8b 8b 8b 8b40b

r sp N ode address

8b1b 5b2b

Поле Значење

Header Почеток на порака

Request/Response Барање или одговор

N/A 00000 - неискористени

Cabine_number/Node_address Број на кабина и/или адреса на јазол (256)

Command Наредба

Data Податок (за наредбата)

CRC Checksum

КОМУНИКАЦИЈА

Наредба Код Податок Значење Насока

start_motor 0x40 Cab. number Да започне моторот со работа CPU � ECC

slow_down_motor 0x41 Cab. number Моторот да ја намали брзината CPU � ECC

speed_up_motor 0x42 Cab. number Моторот да ја зголеми брзината CPU � ECC

stop_motor 0x43 Cab. number Да запре моторот со работа CPU � ECC

find_cabine 0x44 Level На кој кат се наоѓа кабината bothfind_cabine 0x44 Level На кој кат се наоѓа кабината both

Наредба Код Податок Значење Насока

calc_closest_cabine 0x10 Level Која кабина да стигне до корисникот IF � CPU

stop_sys_err 0x11 Да се запре системот, настаната е грешка both

cpu_error 0x12 Грешка во CPU картицата CPU � IF

start_sys 0x13 Да започне системот со работа CPU � IF

stop_sys 0x14 Да запре системот со работа CPU � IF

closest_cabine 0x15 1 or 2 Одговор на пораката calc_closest_cabine CPU � IF

ping_if 0x16 Проверка на IF картицата CPU � IF

test_equ 0x17 Тест на опремата CPU � IF

check_srvc_days 0x18 Проверка кога треба да се изврши сервис CPU � IF

Комуникација CPU-ECC

Комуникација CPU-IF и IF-CPU

ПРЕСМЕТКА

кадешто:

cbn – closest cabin number (број на кабината која ќе стигне најбрзо до одредиштето)

Формирањето и пресметката на одговорот

cbn – closest cabin number (број на кабината која ќе стигне најбрзо до одредиштето)

nl – next level (кат кон кој моментално се движи кабината)

cl – current level (кат на кој моментално се наоѓа кабината)

rl – requested level (кат – одредиште)

}

}}

CPU

8085A

RAM

8155

Decoder

ЕЛЕКТРОНСКА ШЕМА

}

}

}EPROM

8755

RS-485

USART (RS-232)

Сигналите/Линиите во микропроцесорот 8085:

•Сигнали за напојување и фреквенции

•Податочни и адресни магистрали

•Управувачка/контролна магистрала

ЕЛЕКТРОНСКА ШЕМА

•Управувачка/контролна магистрала

•Сигнали за прекини

•Сериски I/O сигнали

•DMA сигнали (меморија со директен пристап)

•Сигнали за ресет

Функционални блокови:

•Регистри

•Аритемтичко-логичка едница (ALU)

•Адресен бафер

•Леч коло за инкрементирање/декрементирање на адреса

•Контрола на прекини

ЕЛЕКТРОНСКА ШЕМА

•Контрола на прекини

•Контрола/управување на сериски I/O порти

•Електронски кола за контрола и тајминзи

•Декодер на инструкции и енкодер на машинските циклуси

ЕЛЕКТРОНСКА ШЕМА

Статична меморија: RАМ Intel 8155 – 2kb Меморија за чување на параметри: EPROM Intel 8775 – 16kb

ЕЛЕКТРОНСКА ШЕМА

RS-232 примопредавател RS-485 конвертoр

ЕЛЕКТРОНСКА ШЕМА

� EPROM (8755)

hex 0 1 2 3 4 5 6 7 8 9 A B C D E F

4000 10 11 12 13 14 15 16 17 18 00 00 00 00 00 00 00

4010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

4020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

4030 40 41 42 43 00 00 00 00 00 00 00 00 00 00 00 00

4040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

4050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

4060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

4070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

ОРГАНИЗАЦИЈА НА МЕМОРИЈАТА

4070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

4080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

4090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

40A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

40B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

40C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

40D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

40E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

40F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Мемориски опсег Искористено за Променлива

4000h – 402Fh Наредби за работа со IF картицата /

4030h – 405Fh Наредби за работа со ECC картицата /

� RAM (8155)

hex 0 1 2 3 4 5 6 7 8 9 A B C D E F

2000 10 11 12 13 14 15 16 17 18 00 00 00 00 00 00 00

2010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

2020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

2030 40 41 42 43 00 00 00 00 00 00 00 00 00 00 00 00

2040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

2050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

2060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Мемориски опсег Искористено за Променлива

2000h – 202Fh Наредби за работа со IF картицата /

2030h – 205Fh Наредби за работа со ECC картицата /

2060h – 2064h Формирање на порака /

2070h – 2074h Примање на порака /

2080h Локација кон која се движи кабина 1 r_cabin_01

ОРГАНИЗАЦИЈА НА МЕМОРИЈАТА

2070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

2080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

2090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

20A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

20B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

20C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

20D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

20E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

20F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

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

2090h Код На CPU грешка (грешка во CPU картица) r_cpu_err_adr

2091h Код на системска грешка r_sys_err_adr

20A0h Бројач за примена порака rx_msg_counter

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

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:

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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 – бројач за прочитани податоци (наредби)

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

PC

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

Формрање на адреса за читате од EPROM:

Поставување на адресните пинови (адресирање на 8755)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

MOV A, M ; load the data into reg. A

ret

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

PC

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

Формрање на адреса за читате од EPROM:

Поставување на адресните пинови (адресирање на 8755)

Поставување на адреса на мемориска локација за читање

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

MOV A, M ; load the data into reg. A

ret

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

PC

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

Формрање на адреса за читате од EPROM:

Поставување на адресните пинови (адресирање на 8755)

Поставување на адреса на мемориска локација за читање

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

PC MOV A, M ; load the data into reg. A

ret

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Формрање на адреса за читате од EPROM:

Поставување на адресните пинови (адресирање на 8755)

Поставување на адреса на мемориска локација за читање

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Формрање на адреса за читате од EPROM:

Читање на податок од мемориска локација

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

PC

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

Формрање на адреса за читате од EPROM:

Читање на податок од EPROM (8755)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

PC MOV A, M ; load the data into reg. A

ret

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

PC

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

Формрање на адреса за запишување во RAM:

Поставување на адресните пинови (адресирање на 8155)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

MOV M, A ; write data to memory location

ret

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

PC

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

Формрање на адреса за запишување во RAM:

Поставување на адресните пинови (адресирање на 8155)

Поставување на адреса на мемориска локација за запишување

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

MOV M, A ; write data to memory location

ret

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

PC

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

Формрање на адреса за запишување во RAM:

Поставување на адресните пинови (адресирање на 8155)

Поставување на адреса на мемориска локација за запишување

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

PC MOV M, A ; write data to memory location

ret

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Формрање на адреса за запишување во RAM:

Поставување на адресните пинови (адресирање на 8155)

Поставување на адреса на мемориска локација за запишување

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Формрање на адреса за запишување во RAM:

Запишување на податок во мемориска локација

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

PC

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

Формрање на адреса за запишување во RAM:

Запишување на податoк во RAM

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

PC MOV M, A ; write data to memory location

ret

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 counterPC

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Намена на регистри:

A – податокот од важност

B – константа, број на податоци за читање

C – бројач за прочитани податоци (наредби)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

PCinit_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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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)

...

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Формрање на адреса за запишување во контролниот регистар:

Поставување на адресни линии

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

PC

MVI A, 40h ; reset command word

OUT 068h ; reset 8251

Запишување во контролниот регистар:

Ресетирање на ИК (Internal Reset)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Запишување во контролниот регистар:

Ресетирање на ИК (Internal Reset)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

PC

...

MVI A, 4Ah ; mode word initialization (1 stop bit, no parity, char length 7, baud rate x 16)

OUT 068h ; send the mode word

...

Запиушвање во Mode регистарот:

Поставување на мод на работа

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Запиушвање во Mode регистарот:

Поставување на мод на работа

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

PC

...

MVI A, 15h ; word to enable the transmitter and the receiver of the 8251

OUT 068h

...

Запишување во контролниот регистар:

Овозможување на работа како примо-предавател

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Запишување во контролниот регистар:

Овозможување на работа како примо-предавател

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Читање на статусниот регистар:

Проверка на статусот на примникот

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Читање на статусниот регистар:

Проверка на статусот на предавателот

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

...

; 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

Формрање на адреса за поставување на ИК 8251 како предавател:

Поставување на адресни линии

PCPC+3PC+2PC+1

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Формрање на адреса за поставување на ИК 8251 како предавател:

Поставување на адресни линии

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

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) на покажувачот кон

мемориската локација на првиот бајт на новата порака:

Поставување на адресни линии

PCPC+3

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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) на покажувачот кон

мемориската локација на првиот бајт на новата порака:

Поставување на адресни линии

PCPC+3

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Запишување на почетна вредност (reset) на покажувачот кон

мемориската локација на првиот бајт на новата порака:

Поставување на адресни линии

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

1. Иницијализација на системот:

-Копирање на податоци од ROM во RAM

-RS-232

-Иницијализација на променливи

Запишување на почетна вредност (reset) на покажувачот кон

мемориската локација на првиот бајт на новата порака:

Поставување на адресни линии

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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) на покажувачот кон

мемориската локација на првиот бајт на новата порака:

Поставување на адресни линии

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

2. Почеток на работа на системот

-Формирање и испраќање на порака за стартување на системот

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

call msg_start_sys

call transmit_8251 ; send over RS-485

endless_loop: nop

nop

nop

JMP endless_loop

hlt

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_sysPC

2. Почеток на работа на системот

-Формирање и испраќање на порака за стартување на системот

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

call msg_start_sys

call transmit_8251 ; send over RS-485

endless_loop: nop

nop

nop

JMP endless_loop

hlt

PC

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

2. Почеток на работа на системот

-Формирање и испраќање на порака за стартување на системот

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

EI ; enable interrupts

; 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 за бајт од пораката

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)

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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)

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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)

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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)

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

; 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)

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

Намена на регистри:

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

Намена на регистри:

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

; 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)

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

Намена на регистри:

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

Намена на регистри:

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

; 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)

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

Намена на регистри:

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

Намена на регистри:

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

; 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)

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

Намена на регистри:

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

Намена на регистри:

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

2. Почеток на работа на системот

-Формирање и испраќање на порака за стартување на системот

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

call msg_start_sys

call transmit_8251 ; send over RS-485

endless_loop: nop

nop

nop

JMP endless_loop

hlt

PC

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

2. Почеток на работа на системот

-Формирање и испраќање на порака за стартување на системот

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

call msg_start_sys

call transmit_8251 ; send over RS-485

endless_loop: nop

nop

nop

JMP endless_loop

hlt

PC

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

2. Почеток на работа на системот

-Формирање и испраќање на порака за стартување на системот

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

call msg_start_sys

call transmit_8251 ; send over RS-485

endless_loop: nop

nop

nop

JMP endless_loop

hlt

PC

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

2. Почеток на работа на системот

-Формирање и испраќање на порака за стартување на системот

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

call msg_start_sys

call transmit_8251 ; send over RS-485

endless_loop: nop

nop

nop

JMP endless_loop

hlt

PCPC+1PC+1PC+1

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

2. Почеток на работа на системот

-Формирање и испраќање на порака за стартување на системот

-Бесконечна јамка (чекање на прекин)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

call msg_start_sys

call transmit_8251 ; send over RS-485

endless_loop: nop

nop

nop

JMP endless_loop

hlt

PCPC+1PC+1PC+1

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

cabin current level next level requested level

1 8 5 2

2 5 5 2

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

1. Оневозможување на прекини (DI)

2. Зачувување на содржината на регистрите на Stack

3. Обработка на прекинот (Interrupt Service Routine – ISR)

4. Враќање не содржината на регистрите од Stack

5. Овозможување на прекини (EI)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

ISR_low_003CH: DI

PUSH B

PUSH D

PUSH H

call ISR_high_003CH ; process the interrupt

POP B

POP D

POP H

PCPC+1PC+1

PC+1

POP H

EI

ret

АЛГОРИТАМ НА ИЗВРШУВАЊЕ3. Обработка на прекин

- Обработка на примена порака

-Примен е Прв бајт на порака

- Составување и испраќање на одговор

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

PCISR_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.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)

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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 counter in RAM mem.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)

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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 counter in RAM mem.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)

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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 counter in RAM mem.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)

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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 counter in RAM mem.PC+78 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)

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+78

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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 counter in RAM mem.PC 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)

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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)

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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.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)

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

INR M ; increment the counter

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

… INR M ; increment the counter

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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 counterINR M ; increment the counter

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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 counterINR M ; increment the counter

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

call read_8155 ; 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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

… call read_8155 ; 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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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… call read_8155 ; read the address

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

; � OR NOT calc_closest_cabin send err. msg

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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; � OR NOT calc_closest_cabin send err. msg

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

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. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

PCPC+2

find_cabin:

call msg_find_cabin

call transmit_8251

ret

PC

симулација

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

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 за бајт од пораката

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 за бајт од пораката

; 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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (ADDRESS)

PC…

PC

Намена на регистри:

A – податокот од важност

B – кат - одредиште

C – адреса во RAM за бајт од пораката

; 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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (COMMAND)

PC…

PC

Намена на регистри:

A – податокот од важност

B – кат - одредиште

C – адреса во RAM за бајт од пораката

; 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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (DATA)

PC…

PC

Намена на регистри:

A – податокот од важност

B – кат - одредиште

C – адреса во RAM за бајт од пораката

; 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 за бајт од пораката

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

PCPC+2

find_cabin:

call msg_find_cabin

call transmit_8251

ret

PC

симулација

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

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

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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

PC

… 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_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

PC2080h 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

…; 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

SUB M ; 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)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина I)

PCPC+2

CMA ; first complement (it is negative number)

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

…; 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

SUB M ; 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)

CMA ; first complement (it is negative number)

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

…; 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

SUB M ; 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)

CMA ; first complement (it is negative number)

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

…; 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

SUB M ; 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)

CMA ; first complement (it is negative number)

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

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)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

PCPC+2

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина I)

CMA

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

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)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

PCPC+3

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина I)

CMA

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

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)

CMA

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

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)

CMA

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

not_negative_02:

LXI H, r_diff_cabin_01_16b ; point to the diff_01

ADD M ; 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

…; 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

SUB M ; 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)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PCPC+2

ADI 01h ; add 1 to get the actual result (absolute value)

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

…; 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

SUB M ; 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)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PC

ADI 01h ; add 1 to get the actual result (absolute value)

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

…; 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

SUB M ; 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)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PC

ADI 01h ; add 1 to get the actual result (absolute value)

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

…; 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

SUB M ; 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)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PC

… ADI 01h ; add 1 to get the actual result (absolute value)

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

PC

not_negative_03:

MVI C, r_diff_cabin_02 ; store diff_02 (temp)

call write_8155

LXI H, r_cabin_02_16b ; (next) setup the mem. location of the next location of cabin 02

MOV A, M ; copy next level to reg. A

SUB B ; sub. A-B (next - requested) and store in reg. A

JP not_negative_04 ; jump to the next instruction if not negative

CMA ; first complement (it is negative number)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PCPC+2

CMA

ADI 01h ; add 1 to get the actual result (absolute value)

not_negative_04:

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 0

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

not_negative_03:

MVI C, r_diff_cabin_02 ; store diff_02 (temp)

call write_8155

LXI H, r_cabin_02_16b ; (next) setup the mem. location of the next location of cabin 02

MOV A, M ; copy next level to reg. A

SUB B ; sub. A-B (next - requested) and store in reg. A

JP not_negative_04 ; jump to the next instruction if not negative

CMA ; first complement (it is negative number)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PCPC+3

CMA

ADI 01h ; add 1 to get the actual result (absolute value)

not_negative_04:

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 0

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

not_negative_03:

MVI C, r_diff_cabin_02 ; store diff_02 (temp)

call write_8155

LXI H, r_cabin_02_16b ; (next) setup the mem. location of the next location of cabin 02

MOV A, M ; copy next level to reg. A

SUB B ; sub. A-B (next - requested) and store in reg. A

JP not_negative_04 ; jump to the next instruction if not negative

CMA ; first complement (it is negative number)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PC

CMA

ADI 01h ; add 1 to get the actual result (absolute value)

not_negative_04:

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 0

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

not_negative_03:

MVI C, r_diff_cabin_02 ; store diff_02 (temp)

call write_8155

LXI H, r_cabin_02_16b ; (next) setup the mem. location of the next location of cabin 02

MOV A, M ; copy next level to reg. A

SUB B ; sub. A-B (next - requested) and store in reg. A

JP not_negative_04 ; jump to the next instruction if not negative

CMA ; first complement (it is negative number)

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PC

…CMA

ADI 01h ; add 1 to get the actual result (absolute value)

not_negative_04:

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 0

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

PC

not_negative_04:

LXI H, r_diff_cabin_02_16b ; point to the diff_02

ADD M ; add (next - current) + (next - requested)

call write_8155 ; store the difference into

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Кабина II)

PC…

PC

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 3

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

…; both difference are available now (first is stored in RAM, second in reg. A)

LXI H, r_diff_cabin_01_16b ; setup mem. addr. for the diff. of the first cabin

SUB M ; substract it with the diff. of the second cabin, stored in reg. A

JМ use_the_second_cabin

MVI A, 01h ; use the first cabin

JMP continue_with_msg

use_the_second_cabin:

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Пресметка која кабина да биде испратена)

PC

use_the_second_cabin:

MVI A, 02h ; use the second cabin

continue_with_msg:

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 3

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

…; both difference are available now (first is stored in RAM, second in reg. A)

LXI H, r_diff_cabin_01_16b ; setup mem. addr. for the diff. of the first cabin

SUB M ; substract it with the diff. of the second cabin, stored in reg. A

JМ use_the_second_cabin

MVI A, 01h ; use the first cabin

JMP continue_with_msg

use_the_second_cabin:

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Пресметка која кабина да биде испратена)

PC

use_the_second_cabin:

MVI A, 02h ; use the second cabin

continue_with_msg:

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 3

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

…; both difference are available now (first is stored in RAM, second in reg. A)

LXI H, r_diff_cabin_01_16b ; setup mem. addr. for the diff. of the first cabin

SUB M ; substract it with the diff. of the second cabin, stored in reg. A

JМ use_the_second_cabin

MVI A, 01h ; use the first cabin

JMP continue_with_msg

use_the_second_cabin:

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Пресметка која кабина да биде испратена)

PC

PC use_the_second_cabin:

MVI A, 02h ; use the second cabin

continue_with_msg:

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 3

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

PC

…; both difference are available now (first is stored in RAM, second in reg. A)

LXI H, r_diff_cabin_01_16b ; setup mem. addr. for the diff. of the first cabin

SUB M ; substract it with the diff. of the second cabin, stored in reg. A

JМ use_the_second_cabin

MVI A, 01h ; use the first cabin

JMP continue_with_msg

use_the_second_cabin:

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор- (Пресметка која кабина да биде испратена)

use_the_second_cabin:

MVI A, 02h ; use the second cabin

continue_with_msg:

PC

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 3

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

continue_with_msg:

; data (set to mem. loc. (80)64h)

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, 55h ; 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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

PC…

PC

call write_8155 ; write the message into RAM

EI ; enable interrupts

Ret

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 3

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

continue_with_msg:

; data (set to mem. loc. (80)64h)

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, 55h ; 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

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

PC

…call write_8155 ; write the message into RAM

EI ; enable interrupts

ret

PC

2080h r_cabin_01 5

2081h r_cabin_02 5

2082h r_diff_cabin_01 6

2083h r_diff_cabin_02 3

2084h r_curr_cabin_01 8

2085h r_curr_cabin_02 5

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

АЛГОРИТАМ НА ИЗВРШУВАЊЕ

3. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

PC

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. Обработка на прекин

-Обработка на примена порака

-Составување и испраќање на одговор

cabin current level next level requested level closest cabin number

1 8 5 2 6

2 5 5 2 3

БЛАГОДАРАМ НА ВНИМАНИЕТО