How to add GOSBVL in debug4x
|
12-07-2020, 11:44 PM
(This post was last modified: 01-27-2021 11:07 PM by Giuseppe Donnini.)
Post: #2
|
|||
|
|||
RE: How to add GOSBVL in debug4x
SHORT ANSWER
Use #01160 with a sharp sign (#). LONG ANSWER If the modifier field of an instruction allows the use of expressions – which is the case with GOSBVL – and you want to use an hexadecimal constant, you must precede it with a sharp sign (#). Otherwise, it gets interpreted as a decimal constant (if the number doesn't contain any of the hexadecimal digits A to F), which in your case results in the following opcode: Code: 8F88400 GOSBVL 01160 * Crashes the machine. where 8F corresponds to the GOSBVL instruction and 88400 to the decimal constant 1160 converted to hexadecimal (#488) and put in reverse order (a.k.a. memory order) – which is not at all the address you wanted. Neither the assembler (SASM) nor the linker (SLOAD) will complain, but your code will almost certainly crash the machine. If the address you want to use happens to contain a hexadecimal digit, for example 0116A, you get an "Undefined Operator" error instead, and the resulting opcode looks like this: Code: 8F47000 GOSBVL 0116A * SASM: Undefined Operator Error. What happens here is that the assembler, expecting to find only decimal digits, tries to interpret the "A" as an operator within an expression (like + or -). Once that fails, it will simply output what has already been computed: Since the four digits 0116 up to the alleged operator "A" have already been interpreted as decimal 116 and converted to hexadecimal (#74), the opcode will contain that number in reverse order (47000), padded to 20 bits, which is the length of an address. If you use $01160, it gets interpreted as a local symbol which you haven't defined anywhere (local because it is not preceded by an equals sign (=)), and the resulting opcode is this: Code: 8F00000 GOSBVL $01160 * SASM: Undefined [Local] Symbol Error. The assembler generates an "Undefined Symbol" error because it expects to find the definition of the symbol $01160 locally, i.e. directly in your source code (or in an INCLUDEd source code file). If you add an equals sign (either to the form with or without dollar sign ($)), it gets interpreted as a global symbol. In that case, the assembler doesn't complain, as it leaves this step to the linker. However, the linker will not be able to find the symbol 01160 or $01160 in the global tables, which will eventually lead to an "Unresolved Reference" error. Code: 8F00000 GOSBVL =01160 * SLOAD: Unresolved [Global] Reference Error. RECOMMENDED PRACTICE Instead of using direct addresses, the recommended practice is to define your own symbols. In your case, if you place the following global definition at the start of your source code: Code: ASSEMBLE you can later simply write: Code: GOSBVL =CINRTN which is much easier to understand and to maintain. If your code consists of several files, use a separate file to centralize all global symbol definitions and INCLUDE that file at the beginning of each source code file. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
How to add GOSBVL in debug4x - joved - 12-07-2020, 04:46 PM
RE: How to add GOSBVL in debug4x - Giuseppe Donnini - 12-07-2020 11:44 PM
RE: How to add GOSBVL in debug4x - joved - 12-08-2020, 07:45 AM
RE: How to add GOSBVL in debug4x - Giuseppe Donnini - 12-08-2020, 09:58 AM
RE: How to add GOSBVL in debug4x - joved - 12-08-2020, 10:33 AM
|
User(s) browsing this thread: 2 Guest(s)