source: xtideuniversalbios/trunk/Assembly_Library/Src/Util/Registers.asm@ 72

Last change on this file since 72 was 66, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

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