How to resolve the algorithm Create an object at a given address step by step in the COBOL programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Create an object at a given address step by step in the COBOL programming language

Table of Contents

Problem Statement

In systems programing it is sometimes required to place language objects at specific memory locations, like I/O registers, hardware interrupt vectors etc.

Show how language objects can be allocated at a specific machine addresses. Since most OSes prohibit access to the physical memory if it is not mapped by the application, as an example, rather than a physical address, take the address of some existing object (using suitable address operations if necessary).

For example:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Create an object at a given address step by step in the COBOL programming language

Source code in the cobol programming language

IDENTIFICATION DIVISION.
PROGRAM-ID. object-address-test.
DATA DIVISION.
LOCAL-STORAGE SECTION.
77  int-space PICTURE IS 9(5) VALUE IS 12345.
77  addr      PICTURE IS 9(5) BASED VALUE IS ZERO.
77  point       USAGE IS POINTER.
PROCEDURE DIVISION.
    DISPLAY "Value of integer object   : " int-space
    SET point TO ADDRESS OF int-space
    DISPLAY "Machine address of object : " point
    SET ADDRESS OF addr TO point
    DISPLAY "Value of referent object  : " addr
    MOVE 65535 TO int-space
    DISPLAY "New value of original     : " addr
    DISPLAY "New value of reference    : " int-space
    GOBACK.
END PROGRAM object-address-test.


  

You may also check:How to resolve the algorithm Verify distribution uniformity/Chi-squared test step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Numerical integration step by step in the Julia programming language
You may also check:How to resolve the algorithm Character codes step by step in the Emacs Lisp programming language
You may also check:How to resolve the algorithm Amicable pairs step by step in the Maple programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the Lua programming language