And here is my macro. Now the question is, how do I undo all the damage I've done by not having this
BUGS: Probably does not work for OFFSET = 0
Add base address to buffer B.
$2A890
Automating the creation of labels for instructions that use $v(An), requires base address in buffer B.
1. Remember current cursor position.
C/CURSOR/Remember $002C [F10]
"Push" the current cursor location on ReSource's location stack.
2. Get symbol value from the selected field on the current line to the accumulator.
S/STRINGS/Get/Symbol value $020E
Copy the symbol value from the selected field on the current line to the
accumulator.
3. Add the base offset to the accumulator to get the label address which should be referenced.
... adding a negative offset will fail, so we drop out of the conditional to handle that
... otherwise, we skip the handling
MACROS 1/Directives/Start conditional
... add the address from buffer B to the accumulator.
S/STRINGS/Maths functions/Add $022E
STORE "\eB"
You will be asked for a number, to be added to the accumulator. If a carry
results, a macro 'fail' will occur.
MACROS 1/Next macro label/#1
MACROS 1/Directives/End conditional
... Can't add the negative offset, so negate it, and subtract it from the address.
... a) the failed add clobbers the offset with the address
S/STRINGS/Get/Symbol value $020E
... b) negate the offset
S/STRINGS/Maths functions/Negate
... c) store for subtraction in buffer C
S/STRINGS/Swap with buffer/C
... d) put base address in accumulator
S/STRINGS/Define string/Acm
STORE "\eB"
... d) subtract offset (buffer C) from base address (accumulator)
S/STRINGS/Maths functions/Subtract
STORE "\eC"
MACROS 1/Set macro label/#1
4. Go to the desired label address.
C/CURSOR/Absolute/Specify offset $01AD [ctl]+[n]
STORE "\e\e"
You will be asked to supply an offset representing how far from the start of
the file, the cursor location should be. The number may be specified in
hexadecimal, decimal, or binary. If hexadecimal, the string must start with
"$", if binary, it must start with "%".3. Make a label if one does not currently exist.
5. Store the accumulator value in buffer A.
S/STRINGS/Swap with buffer/A
6. Create a "shop" label if one does not exist.
MACROS 1/Directives/Start conditional
S/STRINGS/Get/Label $0209
-- Note that this does nothing. It should fail and bail out to the replace label, but I dont't think it does.
If there is a label defined at the cursor location, it will be copied to the
accumulator.
L/LABELS/Create single/Label - fwd ref $0034 [F6]
The current line of code will be searched for references to positions within
the current file. If any are found, ReSource will make a decision on which
type of data is at the position referenced. It will then set the
data type (unless it has already been set), and create a label at that offset
(unless a label has already been defined for that location). This new label
will be immediately used for all references to that location, which of course
includes the reference within the current line. If there are no references,
or there is a reference, but it is outside of the range of the current file,
then this function will do nothing. Normally, this function will only be
used within macros, as the "PROJECT/Disassemble" normally will create all
necessary labels.
MACROS 1/Next macro label/#2
MACROS 1/Directives/End conditional
7. If there is no label we arrived here. So create a generic one OR ask the user.
L/LABELS/Replace single/Label $0184 [F4]
Create a "shop" label at the cursor position. A "shop" label is one that is
9 characters long, begins with "lb", has the data type immediately following,
and ends with the code offset. It may also be of some other length, and end
with ".MSG".
The "data type known" attribute will be set also.
8. Allow skipping replacing the label if there already is one.
MACROS 1/Set macro label/#2
7. Return to last stored location on the stack.
C/CURSOR/Absolute/Previous location $8x3F [leftarrow]
"Pop" the cursor location from the top of the cursor location stack. If the
stack is empty, a macro "fail" will result.
6. Build the symbol to put in the selected field on the current line in the accumulator.
S/STRINGS/Define string/Acm
STORE "\e0"
S/STRINGS/Edit functions/Append $0208
STORE "\eA"
You will be asked to supply a string, which will be appended to (added to the
end of) the accumulator, providing that the resulting string is no longer
than 240 characters
S/STRINGS/Edit functions/Append $0208
STORE "\e-\e0"
S/STRINGS/Edit functions/Append $0208
STORE "\eB"
S/STRINGS/Edit functions/Append $0208
STORE "\e"
7. Put the accumulator as the symbol for the selected field on the current line.
L/LABELS/Create single/Symbol $0359
STORE "\e\e"
You will be asked to supply a string, which will replace one of the numbers
on the current line. A symbol may be created for the first, second, third of
fourth number on the current line.