008_Lab

advertisement
Laboratory Work No 08
Structures and Records
Objectives:
In this experiment you will learn:
1. Structures. Description of Structure Picture.
2. Determination data with a structure type. Methods of work with structures.
3. Records. Description of Records. Determination of record exemplar.
4. Work with records.
Pre Lab Work
Part I
:
1. Review the material related to Data description (Lecture #8)
Lab Work
Part I
1.Use TASM (or MASM) to examine the using structures:
For example use the next program:
TITLE "Structures in Assembly"
assume CS:CODE, DS:DATA
staff STRUC
nam DB 30 DUP(" ");name,surname,patronymic, concerning some person
sex
DB " "
position DB 20 DUP(" ")
age DB 10 DUP(" ")
standing DB 10 DUP(" ")
salary DB 10 DUP(" ")
birthdat DB 30 DUP(" ")
staff ENDS
CODE segment
BEGIN: mov AX,DATA
mov DS,AX
mov AH,09h
mov DX,offset per1.nam
int 21h
mov AH,09h
mov DX,offset per1.position
int 21h
mov AX, 4C00h
int 21h
CODE ends
DATA segment
per1 staff <"Belikov Zaiyka Morkovich, $",'m',"hunter$",'98','88','10000','01.10.06'>
DATA ends
STK segment stack
db 256 dup (?)
STK ends
end BEGIN
Part II
2.Use TASM (Turbo-Debugger) to examine using Records:
For example use the next program:
assume cs:code,ds:data
person RECORD sex:1, married:1, children:4, school:3, age:7
data segment
f_2 person <0,1,5,2,48>
maskSex
= MASK sex
maskMarried = MASK married
maskChildren = MASK children
;mask_u_Age = MASK u_age
maskAge = MASK age
maskSchool = MASK school
soob db "00000000000000000$"
soob1 db "sex=0,married=1,children= 4,school=2,age= $"
soob2 db "
data ends
stk segment stack
db 256 dup(?)
$"
stk ends
code segment
begin:
mov ax,data
mov ds,ax
;-------------=Outlining and Processing Bit's Fields=-------------------------mov AX,[f_2];
and AX,maskChildren;
mov CL,children;
shr AX,CL;
inc AX
push AX
mov BL,00h
add AL,BL
aaa
xor AH,AH
or AX,3030h
mov byte ptr soob1+26,AL
mov AX,[f_2]
and AX,maskAge
or CL,CL
mov CL,age
jz @@4
shr AX,CL
@@4:
1)to copy the variable in AX
2)to outline a bit's field
to prepare a shift counter
3)a shift of the fielt to the right
aam
or AX,3030h
mov byte ptr soob1+43,AL
mov byte ptr soob1+42,AH
mov AH,09h
mov DX,offset soob1
int 21h
pop AX
;------------=Insert of Bit's Fields=-----------------------------------------mov CL,children;
to send the counter of shifts in CL
shl AX,CL;
1)a shift in the necessary position
and [f_2], NOT maskChildren;
or [f_2],AX;
mov AX,[f_2]
mov ax,4c00h
int 21h
code ends
end begin
2)to prepare place for the insert
3)to insert a new meaning
Download