How to add GOSBVL in debug4x
|
12-07-2020, 04:46 PM
Post: #1
|
|||
|
|||
How to add GOSBVL in debug4x
Hello,
I used debug4x to create assembly program. I want to use "GOSBVL 01160" instead "C=IN" because it's recommended. When I compile with GOSBVL 01160 (or GOSBVL $01160), debugx4 gives me an error: 50: Entry $01160 does not exist. Is there a possibility to add a "GOSBVL mnopq" command into debug4x ? Is there a special syntax I don't have ? Thanks a lot. Joël. |
|||
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. |
|||
12-08-2020, 07:45 AM
Post: #3
|
|||
|
|||
RE: How to add GOSBVL in debug4x
Thanks a lot Giuseppe for your large answer. You're better than Google !
It works !! Just a little remark. If I just add the # chatacter (GOSBVL #01160), it does not work and the assembly hexa was 8FB7756. But with "=CINRTN EQU #01160" it's perfect. Thanks again. Joël. |
|||
12-08-2020, 09:58 AM
(This post was last modified: 12-08-2020 01:20 PM by Giuseppe Donnini.)
Post: #4
|
|||
|
|||
RE: How to add GOSBVL in debug4x
Then there must be additional errors in your source code. I just checked it and everything seems to get assembled the way I predicted.
I used the following assembly source file (TEST.A): Code: ASSEMBLE together with this linker control file (TEST.M): Code: TITLE GOSBVL Test Here is the listing returned by the assembler (TEST.L) after executing SASM TEST.A : Code: Saturn Assembler Tue Dec 08 10:51:45 2020 and the one returned by the linker (TEST.LR) after executing SLOAD -H TEST.M : Code: Saturn Loader, Ver. version 3.0.8, 12/07/02 As you can see, GOSBVL #01160 works, while the other four examples produce the errors and opcodes I mentioned. Also, the address #6577B contained in the assembled opcode you reported (8FB7756) corresponds to the supported ROM entry point $_Undefined which is usually not used as a machine code entry point, but rather as a System RPL entry. How does that come about? If you want, you can PM me your source code and I will have a look at it. |
|||
12-08-2020, 10:33 AM
Post: #5
|
|||
|
|||
RE: How to add GOSBVL in debug4x
Nice Giuseppe, thanks for your time.
I'm going to MP my code but, I specify that I use Debug4x as IDE and for now I don't know the name of its compilator. For example, NOP3, NOP4 and NOP5 mnemonics are not recognize. That's seems strange. Keep i touch. Joël. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)