1 | ; Project name : Assembly Library |
---|
2 | ; Description : Functions for register operations. |
---|
3 | |
---|
4 | ;-------------------------------------------------------------------- |
---|
5 | ; NORMALIZE_FAR_POINTER |
---|
6 | ; Parameters: |
---|
7 | ; %1:%2: Far pointer to normalize |
---|
8 | ; %3: Scratch register |
---|
9 | ; %4: Scratch register |
---|
10 | ; Returns: |
---|
11 | ; %1:%2: Normalized far pointer |
---|
12 | ; Corrupts registers: |
---|
13 | ; %3, %4 |
---|
14 | ;-------------------------------------------------------------------- |
---|
15 | %macro NORMALIZE_FAR_POINTER 4 |
---|
16 | mov %4, %2 ; Copy offset to scratch reg |
---|
17 | and %2, BYTE 0Fh ; Clear offset bits 15...4 |
---|
18 | eSHR_IM %4, 4 ; Divide offset by 16 |
---|
19 | mov %3, %1 ; Copy segment to scratch reg |
---|
20 | add %3, %4 ; Add shifted offset to segment |
---|
21 | mov %1, %3 ; Set normalized segment |
---|
22 | %endmacro |
---|
23 | |
---|
24 | |
---|
25 | ; Section containing code |
---|
26 | SECTION .text |
---|
27 | |
---|
28 | ;-------------------------------------------------------------------- |
---|
29 | ; Registers_NormalizeDSSI |
---|
30 | ; Registers_NormalizeESDI |
---|
31 | ; Parameters |
---|
32 | ; DS:SI or ES:DI: Ptr to normalize |
---|
33 | ; Returns: |
---|
34 | ; DS:SI or ES:DI: Normalized pointer |
---|
35 | ; Corrupts registers: |
---|
36 | ; Nothing |
---|
37 | ;-------------------------------------------------------------------- |
---|
38 | ALIGN JUMP_ALIGN |
---|
39 | Registers_NormalizeDSSI: |
---|
40 | push dx |
---|
41 | push ax |
---|
42 | NORMALIZE_FAR_POINTER ds, si, ax, dx |
---|
43 | pop ax |
---|
44 | pop dx |
---|
45 | ret |
---|
46 | |
---|
47 | ALIGN JUMP_ALIGN |
---|
48 | Registers_NormalizeESDI: |
---|
49 | push dx |
---|
50 | push ax |
---|
51 | NORMALIZE_FAR_POINTER es, di, ax, dx |
---|
52 | pop ax |
---|
53 | pop dx |
---|
54 | ret |
---|
55 | |
---|
56 | |
---|
57 | ;-------------------------------------------------------------------- |
---|
58 | ; Registers_ExchangeDSSIwithESDI |
---|
59 | ; Parameters |
---|
60 | ; Nothing |
---|
61 | ; Returns: |
---|
62 | ; DS:SI and ES:DI are exchanged. |
---|
63 | ; Corrupts registers: |
---|
64 | ; Nothing |
---|
65 | ;-------------------------------------------------------------------- |
---|
66 | ALIGN JUMP_ALIGN |
---|
67 | Registers_ExchangeDSSIwithESDI: |
---|
68 | push ds |
---|
69 | push es |
---|
70 | pop ds |
---|
71 | pop es |
---|
72 | xchg si, di |
---|
73 | ret |
---|
74 | |
---|
75 | |
---|
76 | ;-------------------------------------------------------------------- |
---|
77 | ; Registers_CopySSBPtoESDI |
---|
78 | ; Registers_CopySSBPtoDSSI |
---|
79 | ; Registers_CopyDSSItoESDI |
---|
80 | ; Registers_CopyESDItoDSSI |
---|
81 | ; Parameters |
---|
82 | ; Nothing |
---|
83 | ; Returns: |
---|
84 | ; Copies farm pointer to different segment/pointer register pair |
---|
85 | ; Corrupts registers: |
---|
86 | ; Nothing |
---|
87 | ;-------------------------------------------------------------------- |
---|
88 | %macro Registers_CopySSBPtoESDI 0 |
---|
89 | push ss |
---|
90 | pop es |
---|
91 | mov di, bp |
---|
92 | %endmacro |
---|
93 | |
---|
94 | %macro Registers_CopySSBPtoDSSI 0 |
---|
95 | push ss |
---|
96 | pop ds |
---|
97 | mov si, bp |
---|
98 | %endmacro |
---|
99 | |
---|
100 | %macro Registers_CopyDSSItoESDI 0 |
---|
101 | push ds |
---|
102 | pop es |
---|
103 | mov di, si |
---|
104 | %endmacro |
---|
105 | |
---|
106 | %macro Registers_CopyESDItoDSSI 0 |
---|
107 | push es |
---|
108 | pop ds |
---|
109 | mov si, di |
---|
110 | %endmacro |
---|
111 | |
---|
112 | |
---|
113 | ;-------------------------------------------------------------------- |
---|
114 | ; Registers_SetZFifNullPointerInDSSI |
---|
115 | ; Parameters |
---|
116 | ; DS:SI: Far pointer |
---|
117 | ; Returns: |
---|
118 | ; ZF: Set if NULL pointer in DS:SI |
---|
119 | ; Corrupts registers: |
---|
120 | ; Nothing |
---|
121 | ;-------------------------------------------------------------------- |
---|
122 | ALIGN JUMP_ALIGN |
---|
123 | Registers_SetZFifNullPointerInDSSI: |
---|
124 | push ax |
---|
125 | mov ax, ds |
---|
126 | or ax, si |
---|
127 | pop ax |
---|
128 | ret |
---|