Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Pointer (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Memory-mapped hardware=== On some computing architectures, pointers can be used to directly manipulate memory or memory-mapped devices. Assigning addresses to pointers is an invaluable tool when programming [[microcontroller]]s. Below is a simple example declaring a pointer of type int and initialising it to a [[hexadecimal]] address in this example the constant 0x7FFF: <syntaxhighlight lang="C"> int *hardware_address = (int *)0x7FFF; </syntaxhighlight> In the mid 80s, using the [[BIOS]] to access the video capabilities of PCs was slow. Applications that were display-intensive typically used to access [[Color Graphics Adapter|CGA]] video memory directly by casting the [[hexadecimal]] constant 0xB8000 to a pointer to an array of 80 unsigned 16-bit int values. Each value consisted of an [[ASCII]] code in the low byte, and a colour in the high byte. Thus, to put the letter 'A' at row 5, column 2 in bright white on blue, one would write code like the following: <syntaxhighlight lang="C"> #define VID ((unsigned short (*)[80])0xB8000) void foo(void) { VID[4][1] = 0x1F00 | 'A'; } </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)