-2

I'm trying to translate a C++ code to Pep/8 assembly language but having a hard time understanding how i can translate a list of values into Pep/8 language such as:

val = [
        1000, 900, 500, 400,
        100, 90, 50, 40,
        10, 9, 5, 4,
        1
        ]

    syb = [
        "M", "CM", "D", "CD",
        "C", "XC", "L", "XL",
        "X", "IX", "V", "IV",
        "I"
        ]
Erik Eidt
  • 23,049
  • 2
  • 29
  • 53
Alex
  • 1

1 Answers1

1

Those are data statements in pseudo code.

In addition to having instructions for generating machine code, all assembly languages have data statements as programs require data (strings, global variables, etc..).  Global data is used for arrays like these.

To help with code statements, and flow of control, assembly languages allow labels in code; they also allow labels in data.

So, declare some data and use the data statements to initialize the data with those values.  The two data statements of interest to you are going to be .WORD and .ASCII.  Make a label with the names (val, syb) and put one in front of data declarations.

For the strings, you'll have to figure out exactly how to store them, so that later you can access them.  There are several possibilities: make them all the same length might be a good choice, then later you can index them using that constant size.

In some environments, we declare data and code as separate sections, but I don't think PEP/8 has that, so either start the program with a jump to skip around data to the real code, or, locate the data after the conclusion of the code.

Erik Eidt
  • 23,049
  • 2
  • 29
  • 53