The syntax of the "K" command is:
K Numerator Denominator
Numerator is a string, in either decimal or hexadecimal format.
Denominator is a string, in either decimal or hexadecimal format.
Notes:
No distinction is made between uppercase and lowercase.
Do not input commas when using decimal format.
Assumes that two numeric values are passed; no error if not, however.
This command demonstrates the division of one SIGNED LONG value by another
SIGNED LONG value. The first numeric value on the command line is parsed into
R25:R24:R23:R22 and the second into R21:R20:R19:R18. The Registers after
parsing are shown in the first line. The Divide2INTs
subroutine is called and the results displayed on the second line. The
quotient is returned in R25:R24:R23:R22 and the remainder in R21:R20:R19:R18.
In this first example, 99 is being divided by 5:
>K 99 5
10 32 54 76 98 1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
0000 0063 0000 0928-0004 FF00 0000 4000-0029 0005 0000 0063-0000 0000 0280 315F
0000 0063 0000 0928-0004 FF00 0000 4000-0029 0004 0000 0013-0000 0000 0280 315F
>
Line 1: R25:R24:R23:R22 = 0x00000063 (= 99) and R21:R20:R19:R18 = 0x00000005
Line 2: R25:R24:R23:R22 = 0x00000013 (= 19) and R21:R20:R19:R18 = 0x00000004
That checks out since 99 / 5 = 19 with a remainder of 4.
Note: The underlining shown above is not a standard part of this output and is
not repeated in the other examples below.
>K -99 5
10 32 54 76 98 1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
0000 FF9D FFFF 0E28-0004 FF00 0000 4000-0029 0005 0000 FF9D-FFFF 0000 0280 315F
00FF FF9D FFFF 0E28-0004 FF00 0000 4000-0029 FFFC FFFF FFED-FFFF 0000 0280 315F
>
Line 1: R25:R24:R23:R22 = 0xFFFFFF9D (= -99) and R21:R20:R19:R18 = 0x00000005
Line 2: R25:R24:R23:R22 = 0xFFFFFFED (= -19) and R21:R20:R19:R18 = 0xFFFFFFFC (= -4)
>K 99 -5
10 32 54 76 98 1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
0000 0063 0000 1428-0004 FF00 0000 4000-0029 FFFB FFFF 0063-0000 0000 0280 315F
00FE 0063 0000 1428-0004 FF00 0000 4000-0029 FFFC FFFF 0013-0000 0000 0280 315F
>
Line 1: R25:R24:R23:R22 = 0x00000063 (= 99) and R21:R20:R19:R18 = 0xFFFFFFFB (= -5)
Line 2: R25:R24:R23:R22 = 0x00000013 (= 19) and R21:R20:R19:R18 = 0xFFFFFFFC (= -4)
>K -99 -5
10 32 54 76 98 1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
0000 FF9D FFFF 1828-0004 FF00 0000 4000-0029 FFFB FFFF FF9D-FFFF 0000 0280 315F
0000 FF9D FFFF 1828-0004 FF00 0000 4000-0029 0004 0000 0013-0000 0000 0280 315F
>
Line 1: R25:R24:R23:R22 = 0xFFFFFF9D (= -99) and R21:R20:R19:R18 = 0xFFFFFFFB (= -5)
Line 2: R25:R24:R23:R22 = 0x00000013 (= 19) and R21:R20:R19:R18 = 0x00000004
>K 1234567 44
10 32 54 76 98 1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
0000 D687 0012 FF28-0004 FF00 0000 4000-0029 002C 0000 D687-0012 0000 0280 315F
0000 D687 0012 FF28-0004 FF00 0000 4000-0029 000F 0000 6D9A-0000 0000 0280 315F
>?, 0x6D9A
28,058
>
Line 1: R25:R24:R23:R22 = 0x0012D687 and R21:R20:R19:R18 = 0x0000002C (= 44)
Line 2: R25:R24:R23:R22 = 0x00006D9A (= 28,058) and R21:R20:R19:R18 = 0x0000000F (= 15)
>k -1234567 44
10 32 54 76 98 1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
0000 2979 FFED FF28-0004 FF00 0000 4000-0029 002C 0000 2979-FFED 0000 0280 315F
00FF 2979 FFED FF28-0004 FF00 0000 4000-0029 FFF1 FFFF 9266-FFFF 0000 0280 315F
>?, -0xFFED2979 ; Evaluate negative hex divisor on the command line
1,234,567
>? -0xFFFF9266 ; Negative hex quotient here (comma not specified)
28058
>? -0xFFFFFFF1 ; Negative hex remainder
15
>
See also:
The Unsigned LONG division test command
and "?" evaluation command
as well as the Divide2INTs and
Divide2ULONGs system function calls.