How to resolve the algorithm Address of a variable step by step in the Modula-2 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Address of a variable step by step in the Modula-2 programming language

Table of Contents

Problem Statement

Demonstrate how to get the address of a variable and how to set the address of a variable.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Address of a variable step by step in the Modula-2 programming language

Source code in the modula-2 programming language

MODULE  GetAddress;

FROM    SYSTEM IMPORT ADR;
FROM    InOut  IMPORT WriteInt, WriteLn;

VAR     var : INTEGER;
        adr : LONGINT;
BEGIN
    adr := ADR(var);    (*get the address*)
    WriteInt(adr, 0);
    WriteLn;
END GetAddress.


MODULE  SetAddress;

CONST   adress  = 134664460;

VAR     var [adress] : INTEGER;

BEGIN
    (*do nothing*)
END SetAddress.


  

You may also check:How to resolve the algorithm Execute Brain step by step in the Forth programming language
You may also check:How to resolve the algorithm Gamma function step by step in the Fortran programming language
You may also check:How to resolve the algorithm Simple windowed application step by step in the Vedit macro language programming language
You may also check:How to resolve the algorithm Reverse words in a string step by step in the Seed7 programming language
You may also check:How to resolve the algorithm String case step by step in the Falcon programming language