How to declare specific address as a variable

98 Views Asked by At

In Marie assembly, how can I declare a specific address as a variable?

x should have a value of hex 2c and value should be at address 0015 Currently, I have code:

load x
add x      \ 2x
store x
halt
x, hex 2c

I could load 2c to the accumulator, and store it at address 0015, but is there any other way?

1

There are 1 best solutions below

0
On

Apparently proper command is org hhh where hhh are hex digits, and there must be 3 of them — so, for 1516 need to use org 015, or for 1510 then org 00F.

I have tested this on marie.js; it gives the error unknown operator org if 3 digits are not supplied.

Sadly, fyi, I'm having trouble using org in any position except first, i.e. in front of all the code & data.  So, if you want to put the code ahead of the data, that's going to be difficult without counting lines of code.  The following org usage will place x at 0x015.

org 011
load x
add x      
store x
halt
x, hex 2c

Alternately, you might do the following:

org 014
jump start
x,  hex 2c
start, load x
...
...

Though this will place the code after the data, it involves only counting one line of code, i.e. the jump start.


Note: marie.js will load the initial PC with the org location, so you can relocate code & data to anywhere and it will still start the simulation at the beginning of that code & data.