Board index » delphi » am I stupid?
Thomas Neuma
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
Thomas Neuma
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
am I stupid?Hi folks, here is something for the pros: var p:^byte; ... p^:=99; {or any other byte} Compiler TP 6, Real Mode, This occurs no mater if data word aligment is So, why???? And, of course, where stands my number? Tomy Tomy_Neum...@t-online.de |
Remco de Kort
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?QuoteThomas Neumann wrote: Remco |
Joe C. Hech
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?QuoteThomas Neumann wrote: var p:^byte; Joe |
Maraude
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid? Remco de Korte wrote in article <3364B58C.3...@xs4all.nl>... Quote>Thomas Neumann wrote: p^ := 99; {or any other byte} It's because Mem[seg(p):ofs(p)] will read the first byte of the variable p, Jeremy |
Steven J. Tuck
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?QuoteThomas Neumann (Tomy_Neum...@t-online.de) writes: itself, and not the address it holds. var p: ^byte Begin Steve |
Robert Smit
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?Quote> Hi folks, self without a new() or getmem()) But try the following writeln, writeln(mem[seg(p^):ofs(p^)]) Robert Smith. |
Maurice Valmo
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?On Mon, 28 Apr 1997 16:34:52 +0200, Remco de Korte Quote<remco...@xs4all.nl> wrote: Let's take it from the top. (Most of what I'm going to write now you var p: ^byte; means P is a pointer to a byte somewhere in memory. Therefore, P seg(p) returns the segment of the variable P, NOT the segment of the byte In a sense, you code should read: writeln(mem[seg(p^):ofs(p^)]); except I don't think TP will be happy with that. Try it, if it works, var p: ^byte; Please let me know if this works out. -- |
R.E.Dona
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?QuoteThomas Neumann wrote: initialized p. The natural way to access the value is to dereference the pointer, as Writeln(p^); But, in answer to your question - you asked to display the byte at Try using Mem[Seg(p^),Ofs(p^)] Quote>> So, why???? And, of course, where stands my number? swift slap to the forehead. Just don't hit too hard. ;-) ...red |
Scott Earnes
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?QuoteThomas Neumann wrote: program begins, p will be undefined (under the IDE, will probably be nil), and writing to an unitialized pointer is a Bad Thing. In the IDE, if this is nil, that means you're writing an arbitrary value to 0000:0000h, which is interrupt vector 0. Doing that is likely to crash the system. Quote> Compiler TP 6, Real Mode, This occurs no mater if data word aligment is others, is that your code is giving you what you're asking for, not what you want. This should be mem[seg(p^):ofs(p^)]. The seg() and ofs() return the segment and offset parts of the address of what you specify, so mem[seg(p):ofs(p)] will return the low-order byte of the offset part of the pointer as stored in the data segment. Of course, as also mentioned, "writeln (p^);" will output "99". Even Quote> Tomy Scott Earnest | We now return you to our regularly | set...@ix.netcom.com | scheduled chaos and mayhem. . . . | |
Christian Tschene
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?On 26 Apr 1997 07:38:47 GMT, Tomy_Neum...@t-online.de (Thomas Neumann) Quote>var p:^byte; you write out the first byte (lo-byte of lo-word) of the pointer-variable. What you need is: WriteLn(mem[seg(p^):ofs(p^)]). Ofs(p^) returns the (I can explain it in german if you don't understand my very bad -- |
Marco Schmi
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?On 26 Apr 1997 07:38:47 GMT, Tomy_Neum...@t-online.de (Thomas Neumann) Quote>Hi folks, The code will show you what is the first byte of the pointer address. seg(p^):ofs(p^) should work (not sure !). And : no, you're *not* stupid. This pointer {*word*99} can be very Regards, |
Slobodan Mihajlovi
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?On 26 Apr 1997, Thomas Neumann wrote: Quote
var p:byte; { NOT pointer } Your code will give one byte of ADDRESS where number 99 is stored smi...@afrodita.rcub.bg.ac.yu Slobodan Mihajlovic |
R.E.Dona
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?Quotema...@pool.informatik.rwth-aachen.de (Marco Schmidt) wrote: ...red |
Robert Smit
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?QuoteThomas Neumann wrote: the location of the pointer, not where the pointer points to. Try this: writeln(mem[seg(p^):ofs(p^)]); -- Robert Smith. |
Dr John Stockto
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:am I stupid?In article <3364BD8C.4...@bcoll.demon.co.uk> of Mon, 28 Apr 1997 Quote.demon.co.uk> wrote: to RAM. It may point to ROM or in some PCs to nothing at all. -- |
1. Enhanced exception handler - I am very stupid.
2. Am I stupid?..Or is Delphi SLOW!!!
3. Bug or am I stupid? (D5 + IB- Components)
5. Am I stupid or is this a D2 bug?
6. DBGrid: Am I stupid or is it just the Grid ?
7. stupid stupid stupid question: Notes OLE
8. Btrieve sucks and I am stupid please Help.