"Gauri Kulkarni" <gauri.kulkarni@xxxxxxxxx> wrote:

>> D IntDS DS
>> D IntNum 5I 0 INZ(0)
>> D IntChar 1 Overlay(IntNum:2)
>> *
>> C MOVE X'C0' IntChar
>>
>> Now, IntNum will contain 192.
>
> But, not very well aware of OVERLAY keyword, so wondering
> how this might have returned a decimal value in 'IntNum'.
> Can anybody please help in getting this point ?

IntNum is defined as a 5-digit integer. Internally it is stored in binary
format and occupies 2 bytes of storage. The Overlay keyword tells the
compiler that IntChar is to occupy the same portion of memory as IntNum.
The 2 following the colon specifies that the first position of IntChar -
which is only one character long - occupies the same memory location as
position 2 of IntNum.

The data structure is therefore 2 bytes long, and because IntNum is
initialised to zero, and IntNum is in binary format, it initially contains
x'0000'.

IntChar occupies the 2nd byte of the data structure so moving x'C0' to it
means the data structure now contains x'00C0'.

The value of IntNum is now 192 because it is in binary format and x'00C0'
is '0000000011000000' in binary. This is 128 + 64 = 192. Note you can
calculate the decimal value directly from the hexadecimal: (4096 x 0) +
(256 x 0) + (16 x 12) + (1 x 0) = 192.

--
Dave...


______________________________________________________________________
This message may contain confidential information which may also be legally 
privileged and is intended only for the use of the parties to whom it is 
addressed. If you are not an intended recipient you are hereby notified that 
any disclosure, copying, distribution or use of any information in this e-mail 
is strictly prohibited. If you receive this message in error please notify the 
sender by return e-mail and then destroy it. Further, we make every endeavour 
to keep our network free from viruses. However, you do need to verify that this 
e-mail and any attachments are free of viruses as we can take no responsibility 
for any computer viruses which might be transferred by way of this e-mail. All 
information and attachments remain the property of Stolt Offshore Group and 
should be held as confidential.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.