:

:

̳

ʳ

ASM-86 :

 

" "

 

 


1.

2.

3.

4.

5.


, . . .


1.

. .

2.

. wiev, wpwiev .

3.

. DOS WINDOWS. . , , . WINDOWS NT .

4.

. . ϳ . . ? F1 Alt-H. Alt Q.


. . . .


1.  ..  MS-DOS.  .: , , 1995. 382 .

2. . IBM PC, XT, AT: . . , 1992.  544 .

3.  ..  . : .  : .., 1992. 432 .

4.  ..  . . : .., 1993. 301 .

5. ! Help Flambeaux Software 1.2.  .. .

6. The Norton Guides, Copyright 1987 by Peter Norton Computing Assembly language, .


Bios Segment At 40h

Db 16 Dup (?)

Flag Dw?

Db 56 Dup (?)

Cols Dw?

Db 23 Dup (?)

A6845 Dw?

Bios Ends

Cseg Segment Para Public 'CODE'

Assume CS: Cseg, DS: Cseg, ES: Nothing

Org 100h

List Proc Near

Jmp Start

;

Special Db 1eh;

Normal Db 02h;

Foregrd Db 07h;

Blink Equ 0Fh;

CR Equ 0Dh

LF Equ 0Ah

EOF Equ 1Ah

Eor Equ 1

Nodata Equ 2


Crt_Col Dw 0

Crt_Buf Dw 0

Crt_Prt Dw 0

Index Dw 0

Reclen Dw 0

Row Db 2

Col Db 1

Attr Db 02h

Blknum Db 0

Scroll Dw 0

First Dw 0

Current Dw 0

Last Dw 0

Recaddr Dw 0

Handle Dw 0

Psize Dw 16

Blksize Dw 0

Switch1 Db 0

Switch2 Db 0

Numlf Db 1

Numcr Db 0

char_msk db 0ffh

min_disp db 0

TextMax Db 32

TextLen Db 0

TextBuf Db 32 Dup (0)

Prompt Db 'Command:'

Spaces Db 32 Dup (32)

Db 'Keys: PgUp PgDn Arrows ESC=exit?=Help '

Pr_Len Equ This Byte Prompt

TextMsg Db '*** ***'

EofMsg Db ' *** ***'

EofLen Equ This Byte EofMsg

Work Db 'LIST '

Keyin Db 64

Keyout Db 0

Filenm Db 76 Dup (0)

Askfile Db 13,10,' : $'

Openmsg Db ' Open failed, return code='

Opencod Dw '00'

Db '$'

Code2 Db 'File not found $'

Code3 Db 'Path not found $'

Code4 Db 'Too many files $'

Code5 Db 'Access denied $'

Org offset Work+256

Workx Equ $-Work

What1 Db 13,32,27,81; Cr, Sp, Esc, Q

Db 68,85,63,72 ; D, U,?, H

Db 47,82,76,84 ;/, R, L, T

Db 80,65,78,88 ; P, A, N, X

Db 66 ; B

Num1 Equ $-What1

What2 Db 77,75,73,81 ;->,<-, PgUp, PgDn

Db 71,72,61,80 ; HOME,^, F3, v

Db 59,68,79,119 ; F1, F10, END,^HOME

Db 115,132,118 ;^<-,^PgUp,^PgDn

db 46,31

Num2 Db $-What2

Where1 Dw Offset NxtPage, Offset NxtPage, Offset Close, Offset Close

Dw Offset NxtPage, Offset Back, Offset Got_H, Offset Got_H

Dw Offset Got_S, Offset Right, Offset Left, Offset Top

Dw Offset Up1, Offset Got_Rs, Offset Down1, Offset Close

Dw Offset Bottom

Where2 Dw Offset Right, Offset Left, Offset Back, Offset NxtPage

Dw Offset Top, Offset Up1, Offset Got_Rs, Offset Down1

Dw Offset Got_H, Offset Close, Offset Bottom, Offset Home

Dw Offset Scroll0, Offset Top, Offset Bottom

dw offset ctrl, offset strip

HelpMsg Db CR, 9,' V 1.0 '

Db CR, LF

Db CR, LF, 9,'Commands and keys:'

Db CR, LF

Db CR, LF, 9,'_ or Space ', 9,9,'continue to next page'

Db CR, LF, 9,'ESC, Q, X or F10', 9,' terminate'

Db CR, LF, 9,'HOME, T or Ctl PgUp', 9,' restart from Top of file'

Db CR, LF, 9,'END, B or Ctl PgDn', 9,' skip to Bottom of file'

Db CR, LF, 9,'Ctl Home ', 9,9,' restart from top of block'

Db CR, LF, 9,'PgDn or D ', 9,9,' scroll Down one page'

Db CR, LF, 9,'PgUp or U ', 9,9,' scroll Up one page'

Db CR, LF, 9,'H,? or F1 ', 9,9,' list Help for keys'

Db CR, LF, 9,'_ or L ', 9,9,'scroll Left 20 columns'

Db CR, LF, 9,'-_ or R ', 9,9,'scroll Right 20 columns'

Db CR, LF, 9,'Ctl _ ', 9,9,'reset scroll to column 1'

Db CR, LF, 9,'_ or P ', 9,9,'Previous, up one line'

Db CR, LF, 9,'_ or N ', 9,9,'Next, down one line'

Db CR, LF, 9,'/text ', 9,9,' find text'

Db CR, LF, 9,'A or F3 ', 9,9,' find text Again'

db CR, LF, 9, ALT S, 9,9, do/don't Strip parity bit

db (toggle)

db CR, LF, 9, ALT C, 9,9, do/don't display Control

db chars

db (toggle)

Db '$'

Start: Mov BX, PgmSize

Mov AH, 4Ah;

Int 21h;

Call GetParm

Openit: Call Open

Jz Init

Ret


Close: Mov BX, Handle

Mov AH, 3Eh;

Int 21h

Mov AX, 0600h;

Sub BL, BL

Mov BH, Foregrd

Sub CX, CX

Mov DX, 184Fh

Int 10h

Ret; DOS

;

Init: Mov BX, 1000h

GetMem: Mov AH, 48h

Int 21h

Jc GetMem

Mov RecAddr, AX

Mov AX, BX

Sub AX, 32

Mul Psize

Mov Blksize, AX

Call InitCrt

Call Set1

Call Set25


Read1: Call ReadBlk;

Mov BL, Normal

Mov Attr, BL

Jnz Read2

Jmp AtEnd

Read2: Dec Row

Cmp Numlf, 0

Je GetNext

Inc Row

Mov Col, 1

GetNext:

Mov AX, Index; ?

Cmp AX, Last

Jb GotNext

Jmp AtEnd

GotNext:

Call ListOne;

Mov CX, Reclen

Add Col, CL

Mov DH, Row

Cmp DH, 25

Jne TestEor

Cmp NumLF, 0

Jne KeyRead

TEstEor: Jmp Read2; ?

KeyRead: Mov AH, 0;

Int 16h

Mov SI, Offset Spaces; 25

Call Msg25

;

Cmp AL, 27; ESC

Jne Chk00

Jmp Close

Chk00: Cmp AL, 0; ?

Jne Chk_97; ,

Xchg AL, AH; ,

Mov DI, Offset What2

Mov BP, Offset Where2

Mov CL, Num2

Jmp Short Control

Chk_97: Cmp AL, 97; ?

Jl Upper

Sub AL, 32; ,

Upper: Mov DI, Offset What1

Mov BP, Offset Where1

Mov CL, Num1

Control: Mov SI, DI; /

Mov CH, 0;

Push DS

Pop ES

Repnz Scasb

Jne KeyRead

Dec DI

Sub DI, SI

Shl DI, 1

Mov BX, Word Ptr DS: [DI] [BP]

Jmp BX;

;

Right: Cmp Scroll, 220; key right

Jb Got77

Jmp KeyRead

Got77: Add Scroll, 20

Jmp BackUp

Scroll0: Mov Scroll, 0; key ctrl-left

Jmp BackUp

Left: Cmp Scroll, 0; key left

Jne Got75

Jmp KeyRead

Got75: Sub Scroll, 20

Jmp BackUp

Got_Rs: Call ReScan; F3

Jmp NxtPage

Got_H: Call Help; key F1

Call Back1

Jmp KeyRead

strip: xor char_msk, 080h;  /

call Back1

jmp NxtPage

ctrl: xor min_disp, 020h;  / 031

call Back1

jmp NxtPage

Got_S: Call Scan;

Jmp NxtPage

NxtPage:; key (nextpage)

Mov AX, Index

Cmp AX, Last; end of file?

Jae BWait

Mov Current, AX

Mov DH, 2

Mov Row, DH

Call Clear

Jmp TestEor

Up1: Cmp First, 0; ?

Jne Up12; , scroll up one line

Bwait: Jmp AtEnd; ,

Up12: Call Scroll_Up

Mov AX, Index

Mov Current, AX

Mov AX, First

Mov Index, AX

Call UpOne

Mov Row, 2

Mov Col, 1

Call ListOne

Mov AX, Current

Mov Index, AX

Call UpOne

Jmp KeyRead

Home: Mov Index, 0

Jmp NxtPage

AtEnd: Mov SI, Offset EofMsg; 'End-of-file'

Call Msg25

Jmp KeyRead

Bottom: Mov AX, Last;

Mov Index, AX

Jmp BackUp

Top: Sub CX, CX;

Mov AL, 0

Sub DX, DX

Mov AH, 42h

Mov BX, Handle

Int 21h

Call Clear

Mov Row, 2

Mov Col, 1

Mov First, 0

Mov Blknum, 0

Jmp Read1

Back: Call Back1

BackUp: Call Back1

Jmp Nxtpage

Down1: Mov AX, Index; scroll down one line

Cmp AX, Last; ?

Jb Down2

Jmp AtEnd

Down2: Mov Current, AX

Mov AX, First

Mov Index, AX

Call GetRec

Mov AX, Index

Down3: Call Scroll_Dn

Mov AX, Index

Mov First, AX

Mov AX, Current

Mov Index, AX

Mov Row, 24

Mov Col, 1

Jmp GetNext

; Scroll Up one page

Back1 Proc Near

Mov CX, 23

Back0: Call UpOne

Loop Back0

Mov Col, 1

Ret

Back1 Endp

; Scroll up one line

UpOne Proc Near

Push CX

Mov CX, 2

Cmp Index, 0; ?

Je Up1d; ,

Up1a: Mov ES, Recaddr

Up1b: Mov DI, Index

Cmp ES: Byte Ptr[DI], LF

Je Up1c

Dec Index

Jnz Up1b

Up1e: Mov Index, 0

Jmp Up1d

Up1c: Dec Index

Jz Up1d

Loop Up1b

Inc Index

Up1d: Pop CX

Ret

UpOne Endp


;

Assume CS: Cseg, DS: Cseg, ES: Nothing

Show Proc Near

Push AX

Push BX

Push CX

Push DX

Push DI

Push ES

Push SI

Sub AX, AX

Mov AL, DH

Sub DH, DH

Mov DI, DX

Dec DI

Dec AX

Cmp CX, 0

Jng Dsp9

Cmp CX, 80

Jbe Dsp1

Mov CX, 80

Dsp1: Mul Crt_Col

Add DI, AX

Shl DI, 1

Mov DX, Crt_Prt

Mov ES, Crt_Buf


Mov BH, Attr

Dsp2: Lodsb

dsp2a: Cmp AL, min_disp

Jae Dsp3

Jmp Dsp4

Dsp3: Mov BL, AL

Call Displa

Dsp4: Loop Dsp2

Dsp9: Pop SI

Pop ES

Pop DI

Pop DX

Pop CX

Pop BX

Pop AX

Ret

Displa: In AL, DX

Test AL, 1

Jnz Displa

Cli

Disphi: In AL, DX

Test AL, 1

Jz Disphi

Mov AX, BX

Stosw

Sti

Ret

Show Endp

;

ListOne Proc Near

Cmp Row, 2

Jne List1

Mov AX, Index

Mov First, AX

List1: Call GetRec

Mov CX, Reclen

Sub CL, Numlf

Sub CL, Numcr

Mov Reclen, CX

Or CX, CX

Jz List9

Mov SI, Offset Work

Cmp Row, 2

Jae List2

Mov Row, 2

List2: Mov DH, Row

Mov DL, Col

Add SI, Scroll

Sub CX, Scroll

Call Show

List9: Inc Row

Mov BL, Normal

Mov Attr, BL

Ret

ListOne Endp

; GetRec

GetRec Proc Near

Push ES

Push CX

Push SI

Push DI

GetR: Test Switch1, Eor

Jz GetR0

Mov AX, Last

Mov Index, AX

Call ReadBlk

Jnz GetR0

Jmp GetRd

GetR0: Sub DI, DI

Mov Word Ptr NumLF, DI

And Switch2,0FFh-Nodata

Mov ES, RecAddr

GetR2: Mov SI, Index

Mov AL, ES: [SI]

Cmp AL, Eof

Jne GetR3

Mov Reclen, DI

Or Switch1, Eor

Jmp GetR


GetR3: And AL, char_msk

Cmp AL, 09h

Jne GetR4

Mov CX, DI

Add CX, 8

And CX, 0FFF8h

Sub CX, DI

GetR3b: Mov Work[DI], ' '

Inc DI

Loop GetR3b

Inc Index

Jmp GetR2

GetR4:

Mov Work[DI], AL

Inc DI

Inc Index

Cmp AL, Cr

Jne GetR5

Inc NumCR

cmp ES:byte ptr [SI+1], LF

je GetR6

mov byte ptr work [di-1], LF

dec NumCR

Inc NumLF

Jmp GetR8

GetR5: Cmp AL, ' '

Je GetR7

Cmp AL, Lf

Jne GetR6

Inc NumLF

Jmp GetR8

GetR6: Or Switch2, Nodata

GetR7: Cmp DI, 255

Je GetR8

Jmp GetR2

GetR8: Mov Reclen, DI

Cmp Work, 0Fh

Jne GetR9

Jmp GetR0

GetR9: Test Switch2, Nodata

Jnz GetRd

Jmp GetR0

GetRd: Pop DI

Pop SI

Pop CX

Pop ES

Ret

GetRec Endp

;

ReadBlk Proc Near

Mov Switch1,0

Mov BX, Handle

Mov CX, Blksize

Push DS

Mov DS, RecAddr

Sub DX, DX

Mov AH, 3Fh

Int 21H

Pop DS

Or AX, AX

Jz ReadB2

Mov Last, AX

Mov Index, 0

Mov First, 0

Mov Current, 0

Inc Blknum

Mov DI, Last

Mov ES, RecAddr

Mov Byte Ptr ES: [DI], 1Ah

ReadB2: Ret

Readblk Endp

; '/'

ReScan Proc

Push DI

Push SI

Push DS

Pop ES

Jmp Scan1


Scan: Push DI

Push SI

Push DS

Pop ES

Mov TextMax, 32

Mov DX, Offset TextMax

Mov AH, 0Ah

Int 21h

Scan1: Sub CX, CX

Or CL, TextLen

Jz NoMatch

Mov AX, First

Mov Index, AX

Call GetRec

Scan3: Call GetRec

Test Switch1, Eor

Jnz NoMatch

Mov AX, Index

Cmp AX, Last

Jae NoMatch

Mov CX, RecLen

Sub CL, TextLen

Jle Scan3

Mov AL, TextBuf

Mov DI, Offset Work

Repnz Scasb

Jne Scan3

Cmp TextLen, 1

Je Match

Sub CH, CH

Mov CL, TextLen

Dec CL

Mov SI, Offset TextBuf+1

Repe Cmpsb

Jne Scan3

Or CX, CX

Jnz Scan3

Match: Call Set25

Mov Attr, Blink

Call UpOne

Jmp Scaned

NoMatch: Mov AX, First

Mov Index, AX

Call Set25

Mov SI, Offset TextMsg

Add Special, 128

Call Msg25

Sub Special, 128

Mov Switch1,0

Mov Col, 1

Scaned: Pop SI

Pop DI

Ret

ReScan Endp

;

Clear Proc Near

Push AX

Push BX

Push CX

Push DX

Mov AX, 0600h

Mov BH, Foregrd

Jmp Scroller

Scroll_Dn:

Push AX

Push BX

Push CX

Push DX

Mov AX, 0601h

Mov BH, Foregrd

Jmp Scroller

Scroll_Up:

Push AX

Push BX

Push CX

Push DX

Mov AX, 0701h

Mov BH, Foregrd

Scroller:

Mov CX, 0100h

Mov DX, 174Fh

Int 10h

Pop DX

Pop CX

Pop BX

Pop AX

Ret

Clear Endp

; 0

Set1 Proc Near

Mov AX, 0600h

Sub BL, BL

Mov BH, Foregrd

Sub CX, CX

Mov DX, 184Fh

Int 10h

Mov Word Ptr Work+5,0000h

Mov DH, 1

Mov DL, DH

Mov SI, Offset Work

Mov CX, 80

Mov BL, Special

Mov Attr, BL

Call Show

Ret

Set1 Endp

; 25

Set25 Proc Near

Push DI

Push SI

Mov DH, 25

Mov DL, 1

Mov CX, Pr_Len

Mov BL, Special

Mov Attr, BL

Mov SI, Offset Prompt

Call Show

Mov AH, 2

Mov DX, 1808h

Mov BX, 0

Int 10H

Pop SI

Pop DI

Ret

Set25 Endp

; 25

Msg25 Proc Near; SI

Mov DH, 25

Mov DL, 10

Mov CX, EofLen

Mov BL, Special

Mov Attr, BL

Call Show

Mov BL, Normal

Mov Attr, BL

Ret

Msg25 Endp

;

InitCrt Proc Near

Push ES

Mov AX, Bios

Mov ES, AX

Mov CX, ES: Cols;

Mov Crt_Col, CX

Mov DX, ES:A6845;

Add DX, 6

Mov Crt_Prt, DX

Mov Crt_Buf, 0B800h; (color)

Mov BX, ES: Flag

And BX, 30h

Cmp BX, 30h

Jne CrtSet

Mov Crt_Buf, 0B000h; (mono)

CrtSet: Pop ES

Ret

InitCrt Endp

; HELP

Help Proc Near

Call Clear

Mov DX, 0200h

Mov AH, 2

Sub BH, BH

Mov BL, Foregrd

Int 10h

Mov DX, Offset HelpMsg

Mov AH, 9

Int 21h

Mov AH, 2

Mov DX, 1808h

Sub BX, BX

Int 10H

Ret

Help Endp

;

GetParm Proc Near

Xor AX, AX

Xor CX, CX

Mov AL, Byte Ptr DS: [80h]

Or CX, AX

Jz GetFile

Mov DI, Offset Filenm

Mov SI, 81h

Blanks: Lodsb

Cmp AL, ' '

Je Skipit

Stosb

Skipit: Loop Blanks

Ret

GetFile:

Mov DX, Offset AskFile

Mov AH, 9

Int 21H

Mov AH, 0AH

Mov DX, Offset Keyin

Int 21h

Sub BL, BL

Or BL, Keyout

Jz GetFile

Mov Filenm[BX], 0

Ret

GetParm Endp

;

Open Proc Near

Mov OpenCod, 0

Mov DX, Offset Filenm

Mov AL, 0

Mov AH, 3DH

Int 21H

Mov Handle, AX

Jnc Opened

Mov OpenCod, AX

Cmp AL, 2

Jl Error

Cmp AL, 5

Ja Error

Sub BX, BX

Mov BL, AL

Mov CL, 4

Shl BX, CL

Lea DX, Code232 [BX]

Jmp Error2

Error: Aam

Xchg AL, AH

Or OpenCod, AX

Mov DX, Offset OpenMsg

Error2: Mov AH, 9

Int 21H

Opened: Cmp OpenCod, 0

Ret

Open Endp

List Endp

PgmSize Equ ($-Cseg+16)/16;

Cseg Ends

End List





2010