473,790 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IVT at address 0

Hi,

Just another question for the standards jockeys...

Suppose I have an Interrupt Vector Table located at address 0x0000 (16-bit
machine). I want to dump the context of the IVT, by treating it as an array
starting at (you guessed it) 0x0000. So I would have

struct iv_s* ivt = (struct iv_s *) 0x0000;

Which will yield a NULL pointer which may not be dereferenced, lest
undefined behavior would result.

Question: How do I get by this? Is it possible without copying the table (in
assembly to avoid dereferencing any pointers) as the current solution does
or blatantly ignore any UB and just count on my compiler not to mind too
much?

Nov 14 '05
15 2245

"Old Wolf" <ol*****@inspir e.net.nz> wrote in message
news:84******** *************** ***@posting.goo gle.com...

<snip>
Hypothetical. I allready checked the real-life situation.


You found a compiler with NULL not all-bits-zero ?


No. My compiler uses NULL (null-pointer) all bits zero and does
not mind dereferencing it.
Nov 14 '05 #11

"Chris Torek" <no****@torek.n et> wrote in message
news:co******** *@news2.newsguy .com...
[given a particular problem of constructing a "pointer to address 0"
where CPU-address-0 holds the Interrupt Vector Table or "ivt":]
"Old Wolf" <ol*****@inspir e.net.nz> wrote in message
news:84******* *************** ****@posting.go ogle.com...
I would do it this way:

struct iv_s *ivt = (struct iv_s*) sizeof *ivt;
--ivt;
In article <41************ ***********@dre ader15.news.xs4 all.nl>,
dandelion <da*******@mead ow.net> wrote:
The --ivt expression will (just as the snippet of Mr Tobin) evaluate to
0,whit the same results (in the hypothetical case of a non-0x00..0
null-pointer. Would that not give the same result? Ie. my pointe pointing tosome unwanted part of memory (or worse)?

Hypothetical . I allready checked the real-life situation.


There are a number of flawed ideas behind the question to start
with.


Ok. I'm always eager for flawed ideas on my part to be corrected. However,
after a couple of readings it's still not very clear to me what the flaws
were. Or the ideas, for that matter. But that does not make your post less
interesting.

Oh, apropos 'flawed idea'... I wanted to amke sure wether the null-pointer
conversion (from 0 to whatever) took place at compile-time. Your post more
than confirmed that.

This is, of course, the same reason the IA32
architecture is still bug-for-bug compatible with the 80186: as it
turns out, hardware is quite soft, but software is almost impossibly
hard. :-)
:-). In a flippant mood I once wrote a floppy-boot loader. All in 8086
assembly.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to

spammers.
Nov 14 '05 #12
Chris Torek <no****@torek.n et> wrote:

[given a particular problem of constructing a "pointer to address 0"
where CPU-address-0 holds the Interrupt Vector Table or "ivt":]
"Old Wolf" <ol*****@inspir e.net.nz> wrote:
I would do it this way:

struct iv_s *ivt = (struct iv_s*) sizeof *ivt;
--ivt;

[snip - explanation of problems with that]

How well would this one fare?

struct iv_s *ivt;
memset(&ivt, 0, sizeof ivt);
Nov 14 '05 #13
>Chris Torek <no****@torek.n et> wrote:
[given a particular problem of constructing a "pointer to address 0"
where CPU-address-0 holds the Interrupt Vector Table or "ivt":]
>"Old Wolf" <ol*****@inspir e.net.nz> wrote:
>> I would do it this way:
>>
>> struct iv_s *ivt = (struct iv_s*) sizeof *ivt;
>> --ivt;

[snip - explanation of problems with that]


Make that "potential problems" -- maybe it works, maybe not. :-)

In article <84************ **************@ posting.google. com>,
Old Wolf <ol*****@inspir e.net.nz> wrote:How well would this one fare?

struct iv_s *ivt;
memset(&ivt, 0, sizeof ivt);


We would need to know one other thing about the hardware and/or
compiler involved: do pointers have any "special" bits that mark
them as valid pointers, for instance. If not -- if we just need
all-bits-zero in the pointer -- this would work (and work on all
four of the proposed variants of the hardware, making it a "better
answer" than the other tricks shown).

Again, the most important thing to note here is that accessing
this Interrupt Vector Table is *already* inherently machine-dependent,
so we can and should simply look at the compiler's documentation to
find out the machine-dependent method by which we accomplish this
machine-dependent task.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #14
>"Chris Torek" <no****@torek.n et> wrote in message
news:co******* **@news2.newsgu y.com...
There are a number of flawed ideas behind the question to start
with.

In article <41************ ***********@dre ader20.news.xs4 all.nl>
dandelion <da*******@mead ow.net> wrote:Ok. I'm always eager for flawed ideas on my part to be corrected. However,
after a couple of readings it's still not very clear to me what the flaws
were. Or the ideas, for that matter. ...
I remember writing this, and trying to pick out what the assumptions
behind the question might have been, but not precisely what I thought
they could be and thus what was wrong with them. :-)

Seriously, one thing that stood out was the idea that all pointers
were "byte pointers", as it were. The old PR1ME machines had 32-bit
"word pointers" and 48-bit "byte pointers", and even in the mid-1980s,
a new machine that came on the market -- the Data General Eclipse --
had separate *formats* for pointers, with word pointers pointing to
16-or-more-bit data, and byte pointers pointing to 8-bit data. A
word pointer's value was always half as much as the corresponding
byte pointer's value.
Oh, apropos 'flawed idea'... I wanted to amke sure wether the null-pointer
conversion (from 0 to whatever) took place at compile-time. Your post more
than confirmed that.


Yes. I always like to imagine what C might have been like if Dennis
had added a "nil" kewyord. Instead of the klunky Standard C three-word
phrase, "null pointer constant", we would just say "nil". A null
pointer would be obtained by using the keyword "nil" wherever a
pointer is required:

char *p = nil; /* sets p to the "null pointer of type char *" */

or:

(int *)nil /* produces the "null pointer of type int *" */

but if you wrote:

printf("nil prints out as %p\n", nil);

you would get a compile-time diagnostic (error message), because the
prototype for printf() is:

int printf(const char *, ...);

and placing the "nil" keyword in an untyped context would be an
error -- the compiler doesn't know *which* "nil" to use ("byte
pointer null", "word pointer null", etc.) on machines where there
are multiple kinds of "null pointer". You would fix this with:

printf("nil prints out as %p\n", (void *)nil);

The cast provides the context, telling the compiler "use the kind
of null pointer needed for the type `void *'".

Dennis did not do this, though. Instead of a keyword that means
"null pointer of type supplied by context, or error if context is
missing" we have "integral constant expression with value zero".
The problem *only* occurs when the required context is missing.
With a keyword -- whether it were spelled "nil" or "__builtin_null "
or even "_KUMQUAT" -- the compiler would know: aha, context missing,
must complain! With "integral constant zero", on the other hand,
what remains when the context is removed is a valid "int": 0.

Someday (in my copious spare time perhaps :-) ) I should add a
trick to gcc, so that __builtin_nil (or however it is to be spelled)
is an integral constant expression with value 0, except that it
produces a diagnostic message whenever it is used in something
other than a pointer context. Then we can:

#define NULL __builtin_water _buffalo /* or however it is spelled */

and get what we would have now if Dennis had just added the keyword
a long time ago.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #15

"Chris Torek" <no****@torek.n et> wrote in message
news:co*******@ news4.newsguy.c om...
"Chris Torek" <no****@torek.n et> wrote in message
news:co******* **@news2.newsgu y.com...
There are a number of flawed ideas behind the question to start
with.
In article <41************ ***********@dre ader20.news.xs4 all.nl>
dandelion <da*******@mead ow.net> wrote:
Ok. I'm always eager for flawed ideas on my part to be corrected.
However,after a couple of readings it's still not very clear to me what the flaws
were. Or the ideas, for that matter. ...


I remember writing this, and trying to pick out what the assumptions
behind the question might have been, but not precisely what I thought
they could be and thus what was wrong with them. :-)


Yes... That helps. ;-).
Seriously, one thing that stood out was the idea that all pointers
were "byte pointers", as it were.
On todays systems, that's a pretty fair assumption, for reasons your post
makes very clear.
The old PR1ME machines had 32-bit
"word pointers" and 48-bit "byte pointers", and even in the mid-1980s,
a new machine that came on the market -- the Data General Eclipse --
had separate *formats* for pointers, with word pointers pointing to
16-or-more-bit data, and byte pointers pointing to 8-bit data. A
word pointer's value was always half as much as the corresponding
byte pointer's value.
word_ptr == byte_ptr << 1 ?
Oh, apropos 'flawed idea'... I wanted to amke sure wether the null-pointerconversion (from 0 to whatever) took place at compile-time. Your post morethan confirmed that.
Yes. I always like to imagine what C might have been like if Dennis
had added a "nil" kewyord.


Personally I like the C++ definition of NULL. Any value that is not a valid
pointer, with a warning on the side that you should not assume NULL to have
any specific value. I spent quite a lot of time fishing "((void *) 0)" out
of C++ programs (C+- would be a better term) last weekend.

I do agree with your 'nil' idea, though. Some *proper* support for
null-pointer-constants would be appreciated, especially now the problems
with an 'on the fly' substitution of integer constant 0 have been shown.

<snip>
Someday (in my copious spare time perhaps :-) ) I should add a
trick to gcc, so that __builtin_nil (or however it is to be spelled)
is an integral constant expression with value 0, except that it
produces a diagnostic message whenever it is used in something
other than a pointer context. Then we can:

#define NULL __builtin_water _buffalo /* or however it is spelled */

and get what we would have now if Dennis had just added the keyword
a long time ago.


Make sure you post it. I'd be more than willing to invest some of my
precious
sparetime to test it.

Sparetime project # 3829192/D, by the way...
Nov 14 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
15729
by: Alexander N. Spitzer | last post by:
If I have a machine with 3 virtual IP addresses (192.168.1.), how can I start 3 instances of the same RMI application (each started with different properties/configs), each listening on the port 1234, but each instance binds to a different ip address. that is to say: instance #1 binds to 192.168.1.5/port 1234 instance #2 binds to 192.168.1.6/port 1234 instance #3 binds to 192.168.1.7/port 1234
8
4599
by: YAN | last post by:
Hi, I want to get the mac address from a machine, which i have the IP address of that machine, how can i do that? I know how to get the mac address of the local machine from the following code: Dim mc As System.Management.ManagementClass Dim mo As System.Management.ManagementObject mc = New System.Management.ManagementClass("Win32_NetworkAdapterConfiguration")
7
21317
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of someone (client) that visits a web site through an anonymous proxy if this person ONLY has JavaScript enabled in their browser? This is NOT a question about PHP, perl, VBScript, Java(.class), or ActiveX. Let us _only_ deal with JavaScript for...
33
3191
by: baumann.Pan | last post by:
hi all, i want to get the address of buf, which defined as char buf = "abcde"; so can call strsep(address of buf, pointer to token);
4
6318
by: andreas.w.h.k. :-\) | last post by:
How do I change the address location in the wsdl <wsdl:port name="SearchSoap12" binding="tns:SearchSoap12"> <soap12:address location="http://searchservices/engine/search.asmx" /> </wsdl:port> Anderas
1
2938
by: Phoenix_ver10 | last post by:
I have a mailing list with multiple names going to the same addresses. I need one address with all the names for that address on it. I checked out the example on microsoft's site, but A: It doesn't work (error that there is an extra parenthise (sp?) ) and B: Will only let in two names for each record. If there are three, the middle on is deleted. Or to make things simpler, if nothing else, I'd like to add a field in the table that shows...
1
2365
by: Jamie J. Begin | last post by:
I'm very new to the world of Python and am trying to wrap my head around it's OOP model. Much of my OOP experience comes from VB.Net, which is very different. Let's say I wanted to create an object that simply outputted something like this: Developer Detroit Michigan
6
7052
by: Nicolas Noakes | last post by:
Hello, I would like to convert to following process to code. Any advice is welcome. I have a hardware device which requires the this procedure to set it's IP address. First create an static ARP entry for the device's MAC address and the desired IP address. Then telnet to this IP address on TCP port 1. This will set the device to temporarily respond to that IP address. Now you can use HTTP to access the device's web interface and
36
3399
by: Julienne Walker | last post by:
Ignoring implementation details and strictly following the C99 standard in terms of semantics, is there anything fundamentally flawed with describing the use of a (non-inline) function as an address? I keep feeling like I'm missing something obvious. -Jul To keep things in context, this is in reference to describing functions to a beginner.
1
3142
by: saravanatmm | last post by:
I need javascript code for validate the email address. Email address field cannot allowed the capital letters, special characters except '@' symbol. But can allowed the small letters, numeric numbers. Now i use this script for validate the email address. But it allows the cpital letters otherwise its working correctly. SCRIPT FUNCTION ************************************************
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.