Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- text segment
- assume CS:text, DS:data
- search proc
- mov DI, AX ; copy string for searching
- ;add DI, TokenLenght
- mov Left, DI
- mov CL, String_Lenght
- ;sub CX, AX
- mov BX, AX
- mov AL, ' '
- cld
- repne scasb ; search index, that not equal ' '
- ; DI - index next of last symbol, that
- ; compare
- mov AX, DI
- mov Right, AX
- ret
- search endp
- missspace proc
- mov DI, AX ; offset of string
- mov CL, String_Lenght
- ;sub CX, AX ; cause of offset, loop can't
- ; work more, that why we sub that
- mov BX, AX ; save offset
- mov AL, ' '
- cld
- repe scasb
- mov AX, DI
- sub AX, Right ; index of new word - index of last
- ; word = count of space
- add Spaces_Count, AL ; save count of space
- mov SpaceMiss, AX
- mov AX, DI ; index next of last element, that not
- ; equal ' '
- ret
- missspace endp
- ;--------------------------------start-------------------------------------
- begin:
- mov AX, data
- mov DS, AX
- ; Create file
- mov AH, 3Ch ; func create file
- mov CX, 0 ; without attr
- mov DX, offset fname ; file_name
- int 21h
- mov handle, AX ; save handler file
- ;write to file
- mov AH, 40h ; func to write to file
- mov BX, handle ; file's handler
- mov CX, buflen ; number of byte, that to write
- mov DX, offset bufout ;adress of data
- int 21h
- ;close file
- mov AH, 3Eh ; func close file
- mov BX, handle ; handler
- int 21h
- ; allocate 160 byte
- mov AH, 48h ; func allocate
- mov BX, 10h ; 10 * 16 byte
- int 21h
- mov allocseg, AX ;adress of allocated memory
- mov ES, AX
- xor DI, DI
- ; open file
- mov AH, 3Dh ;func open file
- mov AL, 2 ;for read/write
- mov DX, offset fname ;adress name file
- int 21h
- mov handler, AX ;save handler
- ;read file
- mov AH, 3Fh ;func to read
- mov BX, handler ;handler file
- mov CX, 200 ;how much to read
- mov DX, allocseg ;save there
- int 21h
- mov CX, AX ;how much symbols is read
- mov AH, 40h ;func to show
- mov BX, 1 ;standart handler
- mov DX, allocseg ;show this
- int 21h
- mov AX, data ; init data segment
- mov ES, AX
- xor CX, CX
- mov CL, String_Lenght
- lea SI, DX
- lea DI, String
- cld
- rep movsb;
- lea DI, String ; DI = address String
- mov AX, DI;
- ;find surname:
- call search ; searching index firts element,
- dec AX ; that equal ' ', return index of next
- ; symbol
- mov BP, Right
- sub BP, Left
- dec BP
- mov TokenLenght, BP
- mov CX, BP ; calculate length
- mov Surname_Lenght, CL
- lea SI, bufout
- lea DI, Surname ; copy string to vars Surname
- cld
- rep movsb
- mov AX, Right
- ;find name:
- call missspace ; call func, that count space and miss
- dec AX ; dec cause MissSpace return index of
- ; element, that not equal ' '
- call search ; call func, that searching index
- dec AX ; first element, that equal ' '
- ; with offset AX
- mov BP, Right
- sub BP, Left
- dec BP
- mov TokenLenght, BP
- mov CX, BP ; end_word_Index - start_word_Index =
- ; loop_count && length of word
- mov Name_Lenght, CL
- mov SI, Left ; SI = string[0]
- ; add offset of name,
- ; SI = string[end_word_index]
- lea DI, Name_ ; copy name string
- cld
- rep movsb
- mov AX, Right
- ;find birhday:
- call missspace
- dec AX
- call search
- dec AX
- mov BP, Right
- sub BP, Left
- dec BP
- mov TokenLenght, BP
- mov CX, BP
- mov SI, Left
- mov BirthDate_Lenght, CL
- lea DI, BirthDate
- cld
- rep movsb
- mov AX, Right
- ;find city:
- call missspace
- dec AX
- call search
- dec AX
- mov BP, Right
- sub BP, Left
- dec BP
- mov TokenLenght, BP
- mov CX, BP
- mov SI, Left
- mov City_Lenght, CL
- lea DI, City
- cld
- rep movsb
- mov AX, Right
- ;find group:
- call missspace
- dec AX
- call search
- dec AX
- mov BP, Right
- sub BP, Left
- dec BP
- mov TokenLenght, BP
- mov CX, BP
- mov SI, Left
- mov Group_Lenght, CL
- lea DI, Group
- cld
- rep movsb
- mov DL, 10
- mov AH, 02h
- int 21h
- mov DL, 13
- mov AH, 02h
- int 21h
- xor CX, CX;;
- add CL, Surname_Lenght
- mov AH, 40h ; func to show
- mov BX, 1 ; standart handler
- mov DX, offset Surname ; show this
- int 21h
- mov DL, 10
- mov AH, 02h
- int 21h
- mov DL, 13
- mov AH, 02h
- int 21h
- xor CX, CX;;
- add CL, Name_Lenght
- mov AH, 40h ; func to show
- mov BX, 1 ; standart handler
- mov DX, offset Name_ ; show this
- int 21h
- mov DL, 10
- mov AH, 02h
- int 21h
- mov DL, 13
- mov AH, 02h
- int 21h
- xor CX, CX;;
- add CL, BirthDate_Lenght
- mov AH, 40h ; func to show
- mov BX, 1 ; standart handler
- mov DX, offset BirthDate ; show this
- int 21h
- mov DL, 10
- mov AH, 02h
- int 21h
- mov DL, 13
- mov AH, 02h
- int 21h
- xor CX, CX;;
- add CL, City_Lenght
- mov AH, 40h ; func to show
- mov BX, 1 ; standart handler
- mov DX, offset City ; show this
- int 21h
- mov DL, 10
- mov AH, 02h
- int 21h
- mov DL, 13
- mov AH, 02h
- int 21h
- xor CX, CX;;
- add CL, Group_Lenght
- mov AH, 40h ; func to show
- mov BX, 1 ; standart handler
- mov DX, offset Group ; show this
- int 21h
- ;free memory
- mov AH, 49h ; func to free memory
- int 21h
- mov Ax, 4c00h;
- int 21h
- text ends
- data segment
- bufout db 'Kostiv Ivan 20.01.2000 Lviv PZ-23 $' ;
- buflen=$-bufout
- handle dw 0 ;
- allocseg dw 0 ;
- handler dw 0 ;
- fname db 'File10.txt', 0
- String db 45 dup('$')
- Surname db 23 dup('$')
- Name_ db 23 dup('$')
- BirthDate db 23 dup('$')
- City db 23 dup('$')
- Group db 23 dup('$')
- String_Lenght db 45
- Surname_Lenght db 0
- Name_Lenght db 0
- BirthDate_Lenght db 0
- City_Lenght db 0
- Group_Lenght db 0
- Left dw 0
- Right dw 0
- TokenLenght dw 0
- SpaceMiss dw 0
- Spaces_Count db 0
- data ends ;
- end begin ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement