Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > openwatcom.users.c_cpp > #3579
| From | nospam_2019@efbe.prima.de |
|---|---|
| Newsgroups | openwatcom.users.c_cpp |
| Subject | Re: How do I use #pragma aux with the HLT instruction? |
| Date | 2019-10-09 21:42 +0200 |
| Message-ID | <h06rg8Ffg8eU1@mid.individual.net> (permalink) |
| References | <qnl1td$crh$1@www.openwatcom.org> |
Am 09.10.19 um 19:31 schrieb Johann 'Myrkraverk' Oskarsson: > Dear o.u.c_cpp, > > How do I write a #pragma aux for the HLT instruction? And how do I use > said #pragma aux? Are there any cotchas I need to be aware of when I > use the HLT instruction? > > For context, I'm writing a DOS extended program with CauseWay, and want > to be nice to the CPU fan in my program's idle loop for people such as > myself who run DOS operating systems in a virtual machine. > > You have seen this info about Auxiliary Pragmas in the C Guide? ... In the following DOS example, Open Watcom C/C++ will generate the sequence of bytes following the "=" character in the auxiliary pragma whenever a call to mode4 is encountered. mode4 is called an in-line function. void mode4(void); #pragma aux mode4 = \ 0xb4 0x00 /* mov AH,0 */ \ 0xb0 0x04 /* mov AL,4 */ \ 0xcd 0x10 /* int 10H */ \ modify [ AH AL ]; The sequence in the above DOS example represents the following lines of assembly language instructions. mov AH,0 ; select function "set mode" mov AL,4 ; specify mode (mode 4) int 10H ; BIOS video call The above example demonstrates how to generate BIOS function calls in-line without writing an assembly language function and calling it from your C/C++ program. The C prototype for the function mode4 is not necessary but is included so that we can take advantage of the argument type checking provided by Open Watcom C/C++. The following DOS example is equivalent to the above example but mnemonics for the assembly language instructions are used instead of the binary encoding of the assembly language instructions. void mode4(void); #pragma aux mode4 = "mov AH,0", "mov AL,4", "int 10H" modify [ AH AL ]; ... CU/2 Frank
Back to openwatcom.users.c_cpp | Previous | Next — Previous in thread | Next in thread | Find similar
How do I use #pragma aux with the HLT instruction? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2019-10-10 01:31 +0800
Re: How do I use #pragma aux with the HLT instruction? nospam_2019@efbe.prima.de - 2019-10-09 21:42 +0200
Re: How do I use #pragma aux with the HLT instruction? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2019-10-10 23:37 +0800
Re: How do I use #pragma aux with the HLT instruction? Paul S Person <psperson1@ix.netcom.invalid> - 2019-10-10 09:07 -0700
Re: How do I use #pragma aux with the HLT instruction? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2019-10-11 00:18 +0800
Re: How do I use #pragma aux with the HLT instruction? Frank Beythien <fbeythien@gmx.de> - 2019-10-10 18:43 +0200
Re: How do I use #pragma aux with the HLT instruction? "Steven Levine" <steve53@nomail.earthlink.net> - 2019-10-12 16:55 +0000
csiph-web