[NTVDM]
[reactos.git] / reactos / subsystems / ntvdm / registers.c
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: registers.c
5 * PURPOSE: Exported functions for manipulating registers
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #define NDEBUG
12
13 #include "emulator.h"
14 #include "cpu/cpu.h"
15
16 /* PUBLIC FUNCTIONS ***********************************************************/
17
18 VOID EmulatorSetStack(WORD Segment, DWORD Offset)
19 {
20 Fast486SetStack(&EmulatorContext, Segment, Offset);
21 }
22
23
24
25 PVOID
26 WINAPI
27 getIntelRegistersPointer(VOID)
28 {
29 UNIMPLEMENTED;
30 return NULL;
31 }
32
33 ULONG
34 WINAPI
35 getEAX(VOID)
36 {
37 return EmulatorContext.GeneralRegs[FAST486_REG_EAX].Long;
38 }
39
40 VOID
41 WINAPI
42 setEAX(ULONG Value)
43 {
44 EmulatorContext.GeneralRegs[FAST486_REG_EAX].Long = Value;
45 }
46
47 USHORT
48 WINAPI
49 getAX(VOID)
50 {
51 return EmulatorContext.GeneralRegs[FAST486_REG_EAX].LowWord;
52 }
53
54 VOID
55 WINAPI
56 setAX(USHORT Value)
57 {
58 EmulatorContext.GeneralRegs[FAST486_REG_EAX].LowWord = Value;
59 }
60
61 UCHAR
62 WINAPI
63 getAH(VOID)
64 {
65 return EmulatorContext.GeneralRegs[FAST486_REG_EAX].HighByte;
66 }
67
68 VOID
69 WINAPI
70 setAH(UCHAR Value)
71 {
72 EmulatorContext.GeneralRegs[FAST486_REG_EAX].HighByte = Value;
73 }
74
75 UCHAR
76 WINAPI
77 getAL(VOID)
78 {
79 return EmulatorContext.GeneralRegs[FAST486_REG_EAX].LowByte;
80 }
81
82 VOID
83 WINAPI
84 setAL(UCHAR Value)
85 {
86 EmulatorContext.GeneralRegs[FAST486_REG_EAX].LowByte = Value;
87 }
88
89 ULONG
90 WINAPI
91 getEBX(VOID)
92 {
93 return EmulatorContext.GeneralRegs[FAST486_REG_EBX].Long;
94 }
95
96 VOID
97 WINAPI
98 setEBX(ULONG Value)
99 {
100 EmulatorContext.GeneralRegs[FAST486_REG_EBX].Long = Value;
101 }
102
103 USHORT
104 WINAPI
105 getBX(VOID)
106 {
107 return EmulatorContext.GeneralRegs[FAST486_REG_EBX].LowWord;
108 }
109
110 VOID
111 WINAPI
112 setBX(USHORT Value)
113 {
114 EmulatorContext.GeneralRegs[FAST486_REG_EBX].LowWord = Value;
115 }
116
117 UCHAR
118 WINAPI
119 getBH(VOID)
120 {
121 return EmulatorContext.GeneralRegs[FAST486_REG_EBX].HighByte;
122 }
123
124 VOID
125 WINAPI
126 setBH(UCHAR Value)
127 {
128 EmulatorContext.GeneralRegs[FAST486_REG_EBX].HighByte = Value;
129 }
130
131 UCHAR
132 WINAPI
133 getBL(VOID)
134 {
135 return EmulatorContext.GeneralRegs[FAST486_REG_EBX].LowByte;
136 }
137
138 VOID
139 WINAPI
140 setBL(UCHAR Value)
141 {
142 EmulatorContext.GeneralRegs[FAST486_REG_EBX].LowByte = Value;
143 }
144
145
146
147 ULONG
148 WINAPI
149 getECX(VOID)
150 {
151 return EmulatorContext.GeneralRegs[FAST486_REG_ECX].Long;
152 }
153
154 VOID
155 WINAPI
156 setECX(ULONG Value)
157 {
158 EmulatorContext.GeneralRegs[FAST486_REG_ECX].Long = Value;
159 }
160
161 USHORT
162 WINAPI
163 getCX(VOID)
164 {
165 return EmulatorContext.GeneralRegs[FAST486_REG_ECX].LowWord;
166 }
167
168 VOID
169 WINAPI
170 setCX(USHORT Value)
171 {
172 EmulatorContext.GeneralRegs[FAST486_REG_ECX].LowWord = Value;
173 }
174
175 UCHAR
176 WINAPI
177 getCH(VOID)
178 {
179 return EmulatorContext.GeneralRegs[FAST486_REG_ECX].HighByte;
180 }
181
182 VOID
183 WINAPI
184 setCH(UCHAR Value)
185 {
186 EmulatorContext.GeneralRegs[FAST486_REG_ECX].HighByte = Value;
187 }
188
189 UCHAR
190 WINAPI
191 getCL(VOID)
192 {
193 return EmulatorContext.GeneralRegs[FAST486_REG_ECX].LowByte;
194 }
195
196 VOID
197 WINAPI
198 setCL(UCHAR Value)
199 {
200 EmulatorContext.GeneralRegs[FAST486_REG_ECX].LowByte = Value;
201 }
202
203
204
205 ULONG
206 WINAPI
207 getEDX(VOID)
208 {
209 return EmulatorContext.GeneralRegs[FAST486_REG_EDX].Long;
210 }
211
212 VOID
213 WINAPI
214 setEDX(ULONG Value)
215 {
216 EmulatorContext.GeneralRegs[FAST486_REG_EDX].Long = Value;
217 }
218
219 USHORT
220 WINAPI
221 getDX(VOID)
222 {
223 return EmulatorContext.GeneralRegs[FAST486_REG_EDX].LowWord;
224 }
225
226 VOID
227 WINAPI
228 setDX(USHORT Value)
229 {
230 EmulatorContext.GeneralRegs[FAST486_REG_EDX].LowWord = Value;
231 }
232
233 UCHAR
234 WINAPI
235 getDH(VOID)
236 {
237 return EmulatorContext.GeneralRegs[FAST486_REG_EDX].HighByte;
238 }
239
240 VOID
241 WINAPI
242 setDH(UCHAR Value)
243 {
244 EmulatorContext.GeneralRegs[FAST486_REG_EDX].HighByte = Value;
245 }
246
247 UCHAR
248 WINAPI
249 getDL(VOID)
250 {
251 return EmulatorContext.GeneralRegs[FAST486_REG_EDX].LowByte;
252 }
253
254 VOID
255 WINAPI
256 setDL(UCHAR Value)
257 {
258 EmulatorContext.GeneralRegs[FAST486_REG_EDX].LowByte = Value;
259 }
260
261
262
263 ULONG
264 WINAPI
265 getESP(VOID)
266 {
267 return EmulatorContext.GeneralRegs[FAST486_REG_ESP].Long;
268 }
269
270 VOID
271 WINAPI
272 setESP(ULONG Value)
273 {
274 EmulatorSetStack(getSS(), Value);
275 }
276
277 USHORT
278 WINAPI
279 getSP(VOID)
280 {
281 return EmulatorContext.GeneralRegs[FAST486_REG_ESP].LowWord;
282 }
283
284 VOID
285 WINAPI
286 setSP(USHORT Value)
287 {
288 EmulatorSetStack(getSS(), Value);
289 }
290
291
292
293 ULONG
294 WINAPI
295 getEBP(VOID)
296 {
297 return EmulatorContext.GeneralRegs[FAST486_REG_EBP].Long;
298 }
299
300 VOID
301 WINAPI
302 setEBP(ULONG Value)
303 {
304 EmulatorContext.GeneralRegs[FAST486_REG_EBP].Long = Value;
305 }
306
307 USHORT
308 WINAPI
309 getBP(VOID)
310 {
311 return EmulatorContext.GeneralRegs[FAST486_REG_EBP].LowWord;
312 }
313
314 VOID
315 WINAPI
316 setBP(USHORT Value)
317 {
318 EmulatorContext.GeneralRegs[FAST486_REG_EBP].LowWord = Value;
319 }
320
321
322
323 ULONG
324 WINAPI
325 getESI(VOID)
326 {
327 return EmulatorContext.GeneralRegs[FAST486_REG_ESI].Long;
328 }
329
330 VOID
331 WINAPI
332 setESI(ULONG Value)
333 {
334 EmulatorContext.GeneralRegs[FAST486_REG_ESI].Long = Value;
335 }
336
337 USHORT
338 WINAPI
339 getSI(VOID)
340 {
341 return EmulatorContext.GeneralRegs[FAST486_REG_ESI].LowWord;
342 }
343
344 VOID
345 WINAPI
346 setSI(USHORT Value)
347 {
348 EmulatorContext.GeneralRegs[FAST486_REG_ESI].LowWord = Value;
349 }
350
351
352
353 ULONG
354 WINAPI
355 getEDI(VOID)
356 {
357 return EmulatorContext.GeneralRegs[FAST486_REG_EDI].Long;
358 }
359
360 VOID
361 WINAPI
362 setEDI(ULONG Value)
363 {
364 EmulatorContext.GeneralRegs[FAST486_REG_EDI].Long = Value;
365 }
366
367 USHORT
368 WINAPI
369 getDI(VOID)
370 {
371 return EmulatorContext.GeneralRegs[FAST486_REG_EDI].LowWord;
372 }
373
374 VOID
375 WINAPI
376 setDI(USHORT Value)
377 {
378 EmulatorContext.GeneralRegs[FAST486_REG_EDI].LowWord = Value;
379 }
380
381
382
383 ULONG
384 WINAPI
385 getEIP(VOID)
386 {
387 return EmulatorContext.InstPtr.Long;
388 }
389
390 VOID
391 WINAPI
392 setEIP(ULONG Value)
393 {
394 CpuExecute(getCS(), Value);
395 }
396
397 USHORT
398 WINAPI
399 getIP(VOID)
400 {
401 return EmulatorContext.InstPtr.LowWord;
402 }
403
404 VOID
405 WINAPI
406 setIP(USHORT Value)
407 {
408 CpuExecute(getCS(), Value);
409 }
410
411
412
413 USHORT
414 WINAPI
415 getCS(VOID)
416 {
417 return EmulatorContext.SegmentRegs[FAST486_REG_CS].Selector;
418 }
419
420 VOID
421 WINAPI
422 setCS(USHORT Value)
423 {
424 Fast486SetSegment(&EmulatorContext, FAST486_REG_CS, Value);
425 }
426
427 USHORT
428 WINAPI
429 getSS(VOID)
430 {
431 return EmulatorContext.SegmentRegs[FAST486_REG_SS].Selector;
432 }
433
434 VOID
435 WINAPI
436 setSS(USHORT Value)
437 {
438 Fast486SetSegment(&EmulatorContext, FAST486_REG_SS, Value);
439 }
440
441 USHORT
442 WINAPI
443 getDS(VOID)
444 {
445 return EmulatorContext.SegmentRegs[FAST486_REG_DS].Selector;
446 }
447
448 VOID
449 WINAPI
450 setDS(USHORT Value)
451 {
452 Fast486SetSegment(&EmulatorContext, FAST486_REG_DS, Value);
453 }
454
455 USHORT
456 WINAPI
457 getES(VOID)
458 {
459 return EmulatorContext.SegmentRegs[FAST486_REG_ES].Selector;
460 }
461
462 VOID
463 WINAPI
464 setES(USHORT Value)
465 {
466 Fast486SetSegment(&EmulatorContext, FAST486_REG_ES, Value);
467 }
468
469 USHORT
470 WINAPI
471 getFS(VOID)
472 {
473 return EmulatorContext.SegmentRegs[FAST486_REG_FS].Selector;
474 }
475
476 VOID
477 WINAPI
478 setFS(USHORT Value)
479 {
480 Fast486SetSegment(&EmulatorContext, FAST486_REG_FS, Value);
481 }
482
483 USHORT
484 WINAPI
485 getGS(VOID)
486 {
487 return EmulatorContext.SegmentRegs[FAST486_REG_GS].Selector;
488 }
489
490 VOID
491 WINAPI
492 setGS(USHORT Value)
493 {
494 Fast486SetSegment(&EmulatorContext, FAST486_REG_GS, Value);
495 }
496
497
498
499 ULONG
500 WINAPI
501 getCF(VOID)
502 {
503 return EmulatorContext.Flags.Cf;
504 }
505
506 VOID
507 WINAPI
508 setCF(ULONG Flag)
509 {
510 EmulatorContext.Flags.Cf = !!(Flag & 1);
511 }
512
513 ULONG
514 WINAPI
515 getPF(VOID)
516 {
517 return EmulatorContext.Flags.Pf;
518 }
519
520 VOID
521 WINAPI
522 setPF(ULONG Flag)
523 {
524 EmulatorContext.Flags.Pf = !!(Flag & 1);
525 }
526
527 ULONG
528 WINAPI
529 getAF(VOID)
530 {
531 return EmulatorContext.Flags.Af;
532 }
533
534 VOID
535 WINAPI
536 setAF(ULONG Flag)
537 {
538 EmulatorContext.Flags.Af = !!(Flag & 1);
539 }
540
541 ULONG
542 WINAPI
543 getZF(VOID)
544 {
545 return EmulatorContext.Flags.Zf;
546 }
547
548 VOID
549 WINAPI
550 setZF(ULONG Flag)
551 {
552 EmulatorContext.Flags.Zf = !!(Flag & 1);
553 }
554
555 ULONG
556 WINAPI
557 getSF(VOID)
558 {
559 return EmulatorContext.Flags.Sf;
560 }
561
562 VOID
563 WINAPI
564 setSF(ULONG Flag)
565 {
566 EmulatorContext.Flags.Sf = !!(Flag & 1);
567 }
568
569 ULONG
570 WINAPI
571 getIF(VOID)
572 {
573 return EmulatorContext.Flags.If;
574 }
575
576 VOID
577 WINAPI
578 setIF(ULONG Flag)
579 {
580 EmulatorContext.Flags.If = !!(Flag & 1);
581 }
582
583 ULONG
584 WINAPI
585 getDF(VOID)
586 {
587 return EmulatorContext.Flags.Df;
588 }
589
590 VOID
591 WINAPI
592 setDF(ULONG Flag)
593 {
594 EmulatorContext.Flags.Df = !!(Flag & 1);
595 }
596
597 ULONG
598 WINAPI
599 getOF(VOID)
600 {
601 return EmulatorContext.Flags.Of;
602 }
603
604 VOID
605 WINAPI
606 setOF(ULONG Flag)
607 {
608 EmulatorContext.Flags.Of = !!(Flag & 1);
609 }
610
611
612
613 ULONG
614 WINAPI
615 getEFLAGS(VOID)
616 {
617 return EmulatorContext.Flags.Long;
618 }
619
620 VOID
621 WINAPI
622 setEFLAGS(ULONG Flags)
623 {
624 EmulatorContext.Flags.Long = Flags;
625 }
626
627
628
629 USHORT
630 WINAPI
631 getMSW(VOID)
632 {
633 return LOWORD(EmulatorContext.ControlRegisters[FAST486_REG_CR0]);
634 }
635
636 VOID
637 WINAPI
638 setMSW(USHORT Value)
639 {
640 /* Set the lower 16 bits (Machine Status Word) of CR0 */
641 EmulatorContext.ControlRegisters[FAST486_REG_CR0] &= 0xFFFF0000;
642 EmulatorContext.ControlRegisters[FAST486_REG_CR0] |= Value & 0xFFFF;
643 }
644
645 /* EOF */