Menu

#100 DEBUG - Please, make it possible to use multiplication and division with the H command and allow decimal and ASCII values as input.

open
nobody
5
2023-07-02
2023-06-28
Oliver
No

In Digital Research's SID86 it is possible to multiply and divide two numbers
given to the h command. It's also possible to enter the numbers as decimal value
with a leading # or as an ASCII character between two inverted commas.

Here are three examples in SID:

#h #65 #2
+ 0043  - 003F  * 00000082  / 0020 (0001)
#h 'X' #3
+ 005B  - 0055  * 00000108  / 001D (0001)
#h 900 300
+ 0C00  - 0600  * 001B0000  / 0003 (0000)

The first example calculates the two values decimal 65 and decimal 2 using all
four basic arithmetic operations and outputs the result of the addition,
subtraction, multiplication and division.
If the division results in a remainder, it is shown in brackets.

The second example does a calculation between the ASCII character 'X' and the
decimal value 3. Being able to calculate with ASCII characters as input
makes it for example quite easy to calculate the distance between two
letters:
#h 'Z' 'A'
gives for example:
+ 009B - 0019 * 000016DA / 0001 (0019)

And if we enter the hex value of the subtraction result in SID, we get the following:

#h 0019
0019 #25

Where #25 is the converted value in decimal. After that we only need to add a decimal 1to get the number of letters of the alphabet.

Currently DEBUG from FreeDOS can only add and subtract HEX values. It can't do more.
It would be great if you could implement these features of SID into DEBUG, to be able to calculate
with decimal values and ASCII characters as input and perform multiplications and divisions and getting
it's remainders in the latter case.

Discussion

  • Anthony Williams

    If you want a small external calculator, try Eric Auer's calcfixp or Oleg Chukaev's resident FDRC.

     
    • Oliver

      Oliver - 2023-06-29

      No, such a feature should be in the debugger. It's helpful while debugging.

       
  • E. C. Masloch

    E. C. Masloch - 2023-06-29

    In my debugger project lDebug you can use the expression evaluator wherever a normal command parses a number. This includes unsigned multiplication, unsigned division, and modulo. The evaluator operates on 32-bit numbers. You can enter decimal numbers using the #... (or equivalently A#...) syntax, or binary using 2#... or octal like 8#... (any base of 2 to 36), all there in the manual. You can enter texts of up to 4 bytes using #'ABC' or with double quotes #"Z", also described in the manual.

    The H command displays the hexadecimal as well as decimal result if given a single expression. If given two expressions it acts more like FreeDOS or MS-DOS Debug. If given more than two expressions it acts like an extension of the classic style, summing for the first result and subtracting for the second result.

     
    • Oliver

      Oliver - 2023-06-30

      Thanks, that is good to hear.
      I also like that the expression evaluator is able to do octal and binary calculation.

      But i found one problem with it. If you do a division with remainder, the result doesn't show in LDEBUG, that the result does also have a remainder.

      -h (#10 / #3)
      0003 decimal: 3
      -h (#10 % #3)
      0001 decimal: 1
      

      You can check this, by doing a second modulo operation, but this means, that you will have to do this for every division just to be sure.

      I know that making that visible may be difficult or impossible to implement because the expression evaluator function should probably be universal so it can be used everywhere, such as in the Assembly A command.

      But for the H command it could probably be done, by simply doing an additional module operation by default as soon as there is a division in the expression and showing that result additionally.

      I'll have to read the LDEBUG manual. On the other hand, these bug reports mainly/also apply to the normal FreeDOS DEBUG, where all these features are still missing.

       
      • E. C. Masloch

        E. C. Masloch - 2023-06-30

        The H command could be modified in a way to display the remainder. I will consider this.

         
        • Oliver

          Oliver - 2023-06-30

          Okay.

           
          • E. C. Masloch

            E. C. Masloch - 2023-06-30

            Done in https://hg.pushbx.org/ecm/ldebug/rev/9b0a148075cf

            Note the conditions under which it runs; the division must be the last operator to run.

            As usual the automatic build will occur before 24:00 in the +0200 timezone, later today.

             
            • Oliver

              Oliver - 2023-07-02

              I tried it with the above example, but i don't see a difference:

              #h (#10/#3)
              0003 decimal 3
              

              No remainder is shown.

              The same applies to this simple calculation with just hex numbers:

              #h (3/2)
              0001  decimal: 1
              
               
              • E. C. Masloch

                E. C. Masloch - 2023-07-02

                You need to drop the round parentheses. As the changeset message says:

                This only activates if hh_depth is at 1 (not in indirection
                nor parentheses)

                This condition is needed because h [3/2] should not display the remainder.

                 
                • Oliver

                  Oliver - 2023-07-02

                  Thank you. I understand. That works.

                   

Log in to post a comment.