Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACCPET] Tokun lab5 #164

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tokun/lab5/Tokun_GS_1303_report.docx
Binary file not shown.
Binary file added tokun/lab5/Tokun_GS_1303_report.pdf
Binary file not shown.
90 changes: 90 additions & 0 deletions tokun/lab5/lab5.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
STACK SEGMENT STACK
DW 512 DUP(0)
STACK ENDS

DATA SEGMENT
KEEP_CS DW 0
KEEP_IP DW 0
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA, SS:STACK
SUBR_INT PROC FAR
push ax
push dx
push bx

mov al, 10110110b
out 43h, al

mov ax, 4400
out 42h, al
mov al, ah
out 42h, al

in al, 61h
or al, 00000011b
out 61h, al

mov ah, 0
int 1ah
mov bx, dx
add bx, 45
delay_loop:
int 1ah
cmp dx, bx
jne delay_loop

in al, 61h
and al, 11111100b
out 61h, al

pop bx
pop dx
pop ax
mov al, 20h
out 20h, al
iret
SUBR_INT ENDP

MAIN PROC FAR
push DS
sub AX, AX
push AX
mov AX, DATA
mov DS, AX

mov AX, 3523h
int 21h
mov KEEP_CS, es
mov KEEP_IP, bx

push ds
mov dx, offset SUBR_INT
mov ax, seg SUBR_INT
mov ds, ax
mov ax, 2523h
int 21h
pop ds

mov ah, 01h
int 21h

;int 23h

CLI
mov dx, KEEP_IP
mov ax, KEEP_CS
mov ds, ax
mov ax, 2523h
int 21h
pop ds
STI

mov AH, 4ch
int 21h
MAIN ENDP

CODE ENDS

END MAIN
79 changes: 79 additions & 0 deletions tokun/lab5/task/lab5.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
AStack SEGMENT STACK
DB 1024 DUP(?)
AStack ENDS

DATA SEGMENT
KEEP_CS DW 0 ; для хранения сегмента вектора прерывания
KEEP_IP DW 0 ; для смещения вектора прерывания
MESSAGE DB 'Hello world', 0dh, 0ah, '$'
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA, SS:AStack

WriteMsg PROC NEAR
push ax
mov AH, 9
int 21h
pop ax
ret
WriteMsg ENDP

FUNC PROC FAR
push dx

mov dx, OFFSET MESSAGE
call WriteMsg

pop dx

mov al, 20h
out 20h, al
iret
FUNC ENDP

MAIN PROC FAR
push ds
mov ax, DATA
mov ds, ax

mov ah, 35h ; функция получения вектора
mov al, 08h ; номер вектора
int 21h
mov KEEP_IP, bx ; запоминание смещения
mov KEEP_CS, es ; и сегмента вектора прерывания

push ds
mov dx, OFFSET FUNC ; смещение для процедуры в DX
mov ax, SEG FUNC ; сегмент процедуры
mov ds, ax ; помещаем в DS
mov ah, 25h ; функция установки вектора
mov al, 08h ; номер вектора
int 21h ; меняем прерывание
pop ds

mov cx, 1000
loop_1:
push cx
mov cx, 1000
loop_2:
nop
loop loop_2
pop cx
loop loop_1

cli
push ds
mov dx, KEEP_IP
mov ax, KEEP_CS
mov ds, ax
mov ah, 25h
mov al, 08h
int 21h ; восстанавливаем старый вектор прерывания
pop ds
sti
mov ah, 4ch
int 21h
MAIN ENDP
CODE ENDS
END MAIN