I'm trying to add two numbers and subtract two numbers but when I compile my code it says 'invalid op-code' (I'm using assist (IBM))
MAIN CSECT
USING MAIN,15
->invalid op-code NUM1 DC F'67'
->invalid op-code NUM2 DC F'203'
L 0,NUM1
L 1,NUM2
AR 0,1
L 2,NUM1
L 3,NUM2
SR 2,3
XDUMP
END MAIN
A few things. First, the placement of the data items is important as it will be incorporated in with the code list. Unlike higher level languages where declarations of data types are organized automatically.
Second, you are declaring the data items incorrectly. The name should start in column 1 with the data type DC
next and then followed by the data. This will simply include the data inline with the other code which will cause your program to fail with an abend S0C1.
Here is an suggested way to declare the data
Columns
0 1 2 3 4
1234567890123456789012345678901234567890
MAIN CSECT
USING MAIN,15
L 0,NUM1
L 1,NUM2
AR 0,1
L 2,NUM1
L 3,NUM2
SR 2,3
XDUMP
NUM1 DC F'67'
NUM2 DC F'203'
END MAIN
Moving the data out of the code path and putting its name in the right column communicates that your data label is not an op-code.