* Sync up to trunk head (r60691).
[reactos.git] / 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
15 /* PUBLIC FUNCTIONS ***********************************************************/
16
17 ULONG
18 CDECL
19 getEAX(VOID)
20 {
21 #ifndef NEW_EMULATOR
22 return EmulatorContext.state->general_reg[EMULATOR_REG_AX].val;
23 #else
24 return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].Long;
25 #endif
26 }
27
28 VOID
29 CDECL
30 setEAX(ULONG Value)
31 {
32 #ifndef NEW_EMULATOR
33 EmulatorContext.state->general_reg[EMULATOR_REG_AX].val = Value;
34 #else
35 EmulatorContext.GeneralRegs[EMULATOR_REG_AX].Long = Value;
36 #endif
37 }
38
39 USHORT
40 CDECL
41 getAX(VOID)
42 {
43 #ifndef NEW_EMULATOR
44 return EmulatorContext.state->general_reg[EMULATOR_REG_AX].w.lo;
45 #else
46 return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowWord;
47 #endif
48 }
49
50 VOID
51 CDECL
52 setAX(USHORT Value)
53 {
54 #ifndef NEW_EMULATOR
55 EmulatorContext.state->general_reg[EMULATOR_REG_AX].w.lo = Value;
56 #else
57 EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowWord = Value;
58 #endif
59 }
60
61 UCHAR
62 CDECL
63 getAH(VOID)
64 {
65 #ifndef NEW_EMULATOR
66 return EmulatorContext.state->general_reg[EMULATOR_REG_AX].b.hi;
67 #else
68 return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].HighByte;
69 #endif
70 }
71
72 VOID
73 CDECL
74 setAH(UCHAR Value)
75 {
76 #ifndef NEW_EMULATOR
77 EmulatorContext.state->general_reg[EMULATOR_REG_AX].b.hi = Value;
78 #else
79 EmulatorContext.GeneralRegs[EMULATOR_REG_AX].HighByte = Value;
80 #endif
81 }
82
83 UCHAR
84 CDECL
85 getAL(VOID)
86 {
87 #ifndef NEW_EMULATOR
88 return EmulatorContext.state->general_reg[EMULATOR_REG_AX].b.lo;
89 #else
90 return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowByte;
91 #endif
92 }
93
94 VOID
95 CDECL
96 setAL(UCHAR Value)
97 {
98 #ifndef NEW_EMULATOR
99 EmulatorContext.state->general_reg[EMULATOR_REG_AX].b.lo = Value;
100 #else
101 EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowByte = Value;
102 #endif
103 }
104
105 ULONG
106 CDECL
107 getEBX(VOID)
108 {
109 #ifndef NEW_EMULATOR
110 return EmulatorContext.state->general_reg[EMULATOR_REG_BX].val;
111 #else
112 return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].Long;
113 #endif
114 }
115
116 VOID
117 CDECL
118 setEBX(ULONG Value)
119 {
120 #ifndef NEW_EMULATOR
121 EmulatorContext.state->general_reg[EMULATOR_REG_BX].val = Value;
122 #else
123 EmulatorContext.GeneralRegs[EMULATOR_REG_BX].Long = Value;
124 #endif
125 }
126
127 USHORT
128 CDECL
129 getBX(VOID)
130 {
131 #ifndef NEW_EMULATOR
132 return EmulatorContext.state->general_reg[EMULATOR_REG_BX].w.lo;
133 #else
134 return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowWord;
135 #endif
136 }
137
138 VOID
139 CDECL
140 setBX(USHORT Value)
141 {
142 #ifndef NEW_EMULATOR
143 EmulatorContext.state->general_reg[EMULATOR_REG_BX].w.lo = Value;
144 #else
145 EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowWord = Value;
146 #endif
147 }
148
149 UCHAR
150 CDECL
151 getBH(VOID)
152 {
153 #ifndef NEW_EMULATOR
154 return EmulatorContext.state->general_reg[EMULATOR_REG_BX].b.hi;
155 #else
156 return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].HighByte;
157 #endif
158 }
159
160 VOID
161 CDECL
162 setBH(UCHAR Value)
163 {
164 #ifndef NEW_EMULATOR
165 EmulatorContext.state->general_reg[EMULATOR_REG_BX].b.hi = Value;
166 #else
167 EmulatorContext.GeneralRegs[EMULATOR_REG_BX].HighByte = Value;
168 #endif
169 }
170
171 UCHAR
172 CDECL
173 getBL(VOID)
174 {
175 #ifndef NEW_EMULATOR
176 return EmulatorContext.state->general_reg[EMULATOR_REG_BX].b.lo;
177 #else
178 return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowByte;
179 #endif
180 }
181
182 VOID
183 CDECL
184 setBL(UCHAR Value)
185 {
186 #ifndef NEW_EMULATOR
187 EmulatorContext.state->general_reg[EMULATOR_REG_BX].b.lo = Value;
188 #else
189 EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowByte = Value;
190 #endif
191 }
192
193
194
195 ULONG
196 CDECL
197 getECX(VOID)
198 {
199 #ifndef NEW_EMULATOR
200 return EmulatorContext.state->general_reg[EMULATOR_REG_CX].val;
201 #else
202 return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].Long;
203 #endif
204 }
205
206 VOID
207 CDECL
208 setECX(ULONG Value)
209 {
210 #ifndef NEW_EMULATOR
211 EmulatorContext.state->general_reg[EMULATOR_REG_CX].val = Value;
212 #else
213 EmulatorContext.GeneralRegs[EMULATOR_REG_CX].Long = Value;
214 #endif
215 }
216
217 USHORT
218 CDECL
219 getCX(VOID)
220 {
221 #ifndef NEW_EMULATOR
222 return EmulatorContext.state->general_reg[EMULATOR_REG_CX].w.lo;
223 #else
224 return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowWord;
225 #endif
226 }
227
228 VOID
229 CDECL
230 setCX(USHORT Value)
231 {
232 #ifndef NEW_EMULATOR
233 EmulatorContext.state->general_reg[EMULATOR_REG_CX].w.lo = Value;
234 #else
235 EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowWord = Value;
236 #endif
237 }
238
239 UCHAR
240 CDECL
241 getCH(VOID)
242 {
243 #ifndef NEW_EMULATOR
244 return EmulatorContext.state->general_reg[EMULATOR_REG_CX].b.hi;
245 #else
246 return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].HighByte;
247 #endif
248 }
249
250 VOID
251 CDECL
252 setCH(UCHAR Value)
253 {
254 #ifndef NEW_EMULATOR
255 EmulatorContext.state->general_reg[EMULATOR_REG_CX].b.hi = Value;
256 #else
257 EmulatorContext.GeneralRegs[EMULATOR_REG_CX].HighByte = Value;
258 #endif
259 }
260
261 UCHAR
262 CDECL
263 getCL(VOID)
264 {
265 #ifndef NEW_EMULATOR
266 return EmulatorContext.state->general_reg[EMULATOR_REG_CX].b.lo;
267 #else
268 return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowByte;
269 #endif
270 }
271
272 VOID
273 CDECL
274 setCL(UCHAR Value)
275 {
276 #ifndef NEW_EMULATOR
277 EmulatorContext.state->general_reg[EMULATOR_REG_CX].b.lo = Value;
278 #else
279 EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowByte = Value;
280 #endif
281 }
282
283
284
285 ULONG
286 CDECL
287 getEDX(VOID)
288 {
289 #ifndef NEW_EMULATOR
290 return EmulatorContext.state->general_reg[EMULATOR_REG_DX].val;
291 #else
292 return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].Long;
293 #endif
294 }
295
296 VOID
297 CDECL
298 setEDX(ULONG Value)
299 {
300 #ifndef NEW_EMULATOR
301 EmulatorContext.state->general_reg[EMULATOR_REG_DX].val = Value;
302 #else
303 EmulatorContext.GeneralRegs[EMULATOR_REG_DX].Long = Value;
304 #endif
305 }
306
307 USHORT
308 CDECL
309 getDX(VOID)
310 {
311 #ifndef NEW_EMULATOR
312 return EmulatorContext.state->general_reg[EMULATOR_REG_DX].w.lo;
313 #else
314 return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowWord;
315 #endif
316 }
317
318 VOID
319 CDECL
320 setDX(USHORT Value)
321 {
322 #ifndef NEW_EMULATOR
323 EmulatorContext.state->general_reg[EMULATOR_REG_DX].w.lo = Value;
324 #else
325 EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowWord = Value;
326 #endif
327 }
328
329 UCHAR
330 CDECL
331 getDH(VOID)
332 {
333 #ifndef NEW_EMULATOR
334 return EmulatorContext.state->general_reg[EMULATOR_REG_DX].b.hi;
335 #else
336 return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].HighByte;
337 #endif
338 }
339
340 VOID
341 CDECL
342 setDH(UCHAR Value)
343 {
344 #ifndef NEW_EMULATOR
345 EmulatorContext.state->general_reg[EMULATOR_REG_DX].b.hi = Value;
346 #else
347 EmulatorContext.GeneralRegs[EMULATOR_REG_DX].HighByte = Value;
348 #endif
349 }
350
351 UCHAR
352 CDECL
353 getDL(VOID)
354 {
355 #ifndef NEW_EMULATOR
356 return EmulatorContext.state->general_reg[EMULATOR_REG_DX].b.lo;
357 #else
358 return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowByte;
359 #endif
360 }
361
362 VOID
363 CDECL
364 setDL(UCHAR Value)
365 {
366 #ifndef NEW_EMULATOR
367 EmulatorContext.state->general_reg[EMULATOR_REG_DX].b.lo = Value;
368 #else
369 EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowByte = Value;
370 #endif
371 }
372
373
374
375 ULONG
376 CDECL
377 getESP(VOID)
378 {
379 return EmulatorGetRegister(EMULATOR_REG_SP);
380 }
381
382 VOID
383 CDECL
384 setESP(ULONG Value)
385 {
386 EmulatorSetStack(EmulatorGetRegister(EMULATOR_REG_SS), Value);
387 }
388
389 USHORT
390 CDECL
391 getSP(VOID)
392 {
393 return LOWORD(EmulatorGetRegister(EMULATOR_REG_SP));
394 }
395
396 VOID
397 CDECL
398 setSP(USHORT Value)
399 {
400 EmulatorSetStack(EmulatorGetRegister(EMULATOR_REG_SS), Value);
401 }
402
403
404
405 ULONG
406 CDECL
407 getEBP(VOID)
408 {
409 #ifndef NEW_EMULATOR
410 return EmulatorContext.state->general_reg[EMULATOR_REG_BP].val;
411 #else
412 return EmulatorContext.GeneralRegs[EMULATOR_REG_BP].Long;
413 #endif
414 }
415
416 VOID
417 CDECL
418 setEBP(ULONG Value)
419 {
420 #ifndef NEW_EMULATOR
421 EmulatorContext.state->general_reg[EMULATOR_REG_BP].val = Value;
422 #else
423 EmulatorContext.GeneralRegs[EMULATOR_REG_BP].Long = Value;
424 #endif
425 }
426
427 USHORT
428 CDECL
429 getBP(VOID)
430 {
431 #ifndef NEW_EMULATOR
432 return EmulatorContext.state->general_reg[EMULATOR_REG_BP].w.lo;
433 #else
434 return EmulatorContext.GeneralRegs[EMULATOR_REG_BP].LowWord;
435 #endif
436 }
437
438 VOID
439 CDECL
440 setBP(USHORT Value)
441 {
442 #ifndef NEW_EMULATOR
443 EmulatorContext.state->general_reg[EMULATOR_REG_BP].w.lo = Value;
444 #else
445 EmulatorContext.GeneralRegs[EMULATOR_REG_BP].LowWord = Value;
446 #endif
447 }
448
449
450
451 ULONG
452 CDECL
453 getESI(VOID)
454 {
455 #ifndef NEW_EMULATOR
456 return EmulatorContext.state->general_reg[EMULATOR_REG_SI].val;
457 #else
458 return EmulatorContext.GeneralRegs[EMULATOR_REG_SI].Long;
459 #endif
460 }
461
462 VOID
463 CDECL
464 setESI(ULONG Value)
465 {
466 #ifndef NEW_EMULATOR
467 EmulatorContext.state->general_reg[EMULATOR_REG_SI].val = Value;
468 #else
469 EmulatorContext.GeneralRegs[EMULATOR_REG_SI].Long = Value;
470 #endif
471 }
472
473 USHORT
474 CDECL
475 getSI(VOID)
476 {
477 #ifndef NEW_EMULATOR
478 return EmulatorContext.state->general_reg[EMULATOR_REG_SI].w.lo;
479 #else
480 return EmulatorContext.GeneralRegs[EMULATOR_REG_SI].LowWord;
481 #endif
482 }
483
484 VOID
485 CDECL
486 setSI(USHORT Value)
487 {
488 #ifndef NEW_EMULATOR
489 EmulatorContext.state->general_reg[EMULATOR_REG_SI].w.lo = Value;
490 #else
491 EmulatorContext.GeneralRegs[EMULATOR_REG_SI].LowWord = Value;
492 #endif
493 }
494
495
496
497 ULONG
498 CDECL
499 getEDI(VOID)
500 {
501 #ifndef NEW_EMULATOR
502 return EmulatorContext.state->general_reg[EMULATOR_REG_DI].val;
503 #else
504 return EmulatorContext.GeneralRegs[EMULATOR_REG_DI].Long;
505 #endif
506 }
507
508 VOID
509 CDECL
510 setEDI(ULONG Value)
511 {
512 #ifndef NEW_EMULATOR
513 EmulatorContext.state->general_reg[EMULATOR_REG_DI].val = Value;
514 #else
515 EmulatorContext.GeneralRegs[EMULATOR_REG_DI].Long = Value;
516 #endif
517 }
518
519 USHORT
520 CDECL
521 getDI(VOID)
522 {
523 #ifndef NEW_EMULATOR
524 return EmulatorContext.state->general_reg[EMULATOR_REG_DI].w.lo;
525 #else
526 return EmulatorContext.GeneralRegs[EMULATOR_REG_DI].LowWord;
527 #endif
528 }
529
530 VOID
531 CDECL
532 setDI(USHORT Value)
533 {
534 #ifndef NEW_EMULATOR
535 EmulatorContext.state->general_reg[EMULATOR_REG_DI].w.lo = Value;
536 #else
537 EmulatorContext.GeneralRegs[EMULATOR_REG_DI].LowWord = Value;
538 #endif
539 }
540
541
542
543 ULONG
544 CDECL
545 getEIP(VOID)
546 {
547 return EmulatorGetProgramCounter();
548 }
549
550 VOID
551 CDECL
552 setEIP(ULONG Value)
553 {
554 EmulatorExecute(EmulatorGetRegister(EMULATOR_REG_CS), Value);
555 }
556
557 USHORT
558 CDECL
559 getIP(VOID)
560 {
561 return LOWORD(EmulatorGetProgramCounter());
562 }
563
564 VOID
565 CDECL
566 setIP(USHORT Value)
567 {
568 EmulatorExecute(EmulatorGetRegister(EMULATOR_REG_CS), Value);
569 }
570
571
572
573 USHORT
574 CDECL
575 getCS(VOID)
576 {
577 return EmulatorGetRegister(EMULATOR_REG_CS);
578 }
579
580 VOID
581 CDECL
582 setCS(USHORT Value)
583 {
584 EmulatorSetRegister(EMULATOR_REG_CS, Value);
585 }
586
587 USHORT
588 CDECL
589 getSS(VOID)
590 {
591 return EmulatorGetRegister(EMULATOR_REG_SS);
592 }
593
594 VOID
595 CDECL
596 setSS(USHORT Value)
597 {
598 EmulatorSetRegister(EMULATOR_REG_SS, Value);
599 }
600
601 USHORT
602 CDECL
603 getDS(VOID)
604 {
605 return EmulatorGetRegister(EMULATOR_REG_DS);
606 }
607
608 VOID
609 CDECL
610 setDS(USHORT Value)
611 {
612 EmulatorSetRegister(EMULATOR_REG_DS, Value);
613 }
614
615 USHORT
616 CDECL
617 getES(VOID)
618 {
619 return EmulatorGetRegister(EMULATOR_REG_ES);
620 }
621
622 VOID
623 CDECL
624 setES(USHORT Value)
625 {
626 EmulatorSetRegister(EMULATOR_REG_ES, Value);
627 }
628
629 USHORT
630 CDECL
631 getFS(VOID)
632 {
633 return EmulatorGetRegister(EMULATOR_REG_FS);
634 }
635
636 VOID
637 CDECL
638 setFS(USHORT Value)
639 {
640 EmulatorSetRegister(EMULATOR_REG_FS, Value);
641 }
642
643 USHORT
644 CDECL
645 getGS(VOID)
646 {
647 return EmulatorGetRegister(EMULATOR_REG_GS);
648 }
649
650 VOID
651 CDECL
652 setGS(USHORT Value)
653 {
654 EmulatorSetRegister(EMULATOR_REG_GS, Value);
655 }
656
657
658
659 ULONG
660 CDECL
661 getCF(VOID)
662 {
663 return EmulatorGetFlag(EMULATOR_FLAG_CF);
664 }
665
666 VOID
667 CDECL
668 setCF(ULONG Flag)
669 {
670 if (Flag & 1)
671 EmulatorSetFlag(EMULATOR_FLAG_CF);
672 else
673 EmulatorClearFlag(EMULATOR_FLAG_CF);
674 }
675
676 ULONG
677 CDECL
678 getPF(VOID)
679 {
680 return EmulatorGetFlag(EMULATOR_FLAG_PF);
681 }
682
683 VOID
684 CDECL
685 setPF(ULONG Flag)
686 {
687 if (Flag & 1)
688 EmulatorSetFlag(EMULATOR_FLAG_PF);
689 else
690 EmulatorClearFlag(EMULATOR_FLAG_PF);
691 }
692
693 ULONG
694 CDECL
695 getAF(VOID)
696 {
697 return EmulatorGetFlag(EMULATOR_FLAG_AF);
698 }
699
700 VOID
701 CDECL
702 setAF(ULONG Flag)
703 {
704 if (Flag & 1)
705 EmulatorSetFlag(EMULATOR_FLAG_AF);
706 else
707 EmulatorClearFlag(EMULATOR_FLAG_AF);
708 }
709
710 ULONG
711 CDECL
712 getZF(VOID)
713 {
714 return EmulatorGetFlag(EMULATOR_FLAG_ZF);
715 }
716
717 VOID
718 CDECL
719 setZF(ULONG Flag)
720 {
721 if (Flag & 1)
722 EmulatorSetFlag(EMULATOR_FLAG_ZF);
723 else
724 EmulatorClearFlag(EMULATOR_FLAG_ZF);
725 }
726
727 ULONG
728 CDECL
729 getSF(VOID)
730 {
731 return EmulatorGetFlag(EMULATOR_FLAG_SF);
732 }
733
734 VOID
735 CDECL
736 setSF(ULONG Flag)
737 {
738 if (Flag & 1)
739 EmulatorSetFlag(EMULATOR_FLAG_SF);
740 else
741 EmulatorClearFlag(EMULATOR_FLAG_SF);
742 }
743
744 ULONG
745 CDECL
746 getIF(VOID)
747 {
748 return EmulatorGetFlag(EMULATOR_FLAG_IF);
749 }
750
751 VOID
752 CDECL
753 setIF(ULONG Flag)
754 {
755 if (Flag & 1)
756 EmulatorSetFlag(EMULATOR_FLAG_IF);
757 else
758 EmulatorClearFlag(EMULATOR_FLAG_IF);
759 }
760
761 ULONG
762 CDECL
763 getDF(VOID)
764 {
765 return EmulatorGetFlag(EMULATOR_FLAG_DF);
766 }
767
768 VOID
769 CDECL
770 setDF(ULONG Flag)
771 {
772 if (Flag & 1)
773 EmulatorSetFlag(EMULATOR_FLAG_DF);
774 else
775 EmulatorClearFlag(EMULATOR_FLAG_DF);
776 }
777
778 ULONG
779 CDECL
780 getOF(VOID)
781 {
782 return EmulatorGetFlag(EMULATOR_FLAG_OF);
783 }
784
785 VOID
786 CDECL
787 setOF(ULONG Flag)
788 {
789 if (Flag & 1)
790 EmulatorSetFlag(EMULATOR_FLAG_OF);
791 else
792 EmulatorClearFlag(EMULATOR_FLAG_OF);
793 }
794
795
796
797 USHORT
798 CDECL
799 getMSW(VOID)
800 {
801 return 0; // UNIMPLEMENTED
802 }
803
804 VOID
805 CDECL
806 setMSW(USHORT Value)
807 {
808 // UNIMPLEMENTED
809 }
810
811 /* EOF */