Post Reply 
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.
Find all posts by this user
Quote this message in a reply
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.
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
=CINRTN EQU #01160

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.
Find all posts by this user
Quote this message in a reply
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 Wink !

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.
Find all posts by this user
Quote this message in a reply
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
        GOSBVL  01160
        GOSBVL  #01160
        GOSBVL  $01160
        GOSBVL  =01160
        GOSBVL  =$01160

together with this linker control file (TEST.M):

Code:
TITLE GOSBVL Test
OUTPUT TEST
LLIST TEST.LR
SUPPRESS XREF
SEARCH ENTRIES.O
REL TEST.O
END

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
V3.0.8 (12/06/2002)                                      TEST.A         Page    1

    1 00000       ASSEMBLE
    2 00000 8F884         GOSBVL  01160
            00
    3 00007 8F061         GOSBVL  #01160
            10
*** ERROR: Undefined symbol ***
    4 0000E 8F000         GOSBVL  $01160
            00
    5 00015 8F000         GOSBVL  =01160
            00
    6 0001C 8F000         GOSBVL  =$01160
            00
Saturn Assembler                                       Tue Dec 08 10:51:45 2020
V3.0.8 (12/06/2002)   Symbol Table                       TEST.A         Page    2

 $01160                            Ext                   -     4     6
 01160                             Ext                   -     5
 ASSEMBLE                          Rel       0 #00000000 -     1
Saturn Assembler                                       Tue Dec 08 10:51:45 2020
V3.0.8 (12/06/2002)   Statistics                         TEST.A         Page    3

Input Parameters

  Source file name is TEST.A

  Listing file name is TEST.l

  Object file name is TEST.o

  Flags set on command line
    None

Warnings:

  None

Errors:

  1 error (line 4)

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


Output Module:
Module=TEST
  Start=00000 End=00022 Length=00023   Symbols=9162 References=   2
  Date=Tue Dec 08 10:51:49 2020   Title= GOSBVL Test


Source modules:
Module=ENTRIES.O
  Start=00000 Module Contains No Code
  Date=Tue Dec 08 10:47:50 2020   Title=                                        Tue Dec 08 10:47:50 2020

Module=TEST.O
  Start=00000 End=00022 Length=00023
  Date=Tue Dec 08 10:51:45 2020   Title=                                        Tue Dec 08 10:51:45 2020

Unresolved References

$01160                          (  1)   01160                           (  1)

/SLOAD:  End of Saturn Loader Execution

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.
Find all posts by this user
Quote this message in a reply
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.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)