Page 2 of 2

Re: Small assembler test programms...

Posted: Thu Jul 03, 2014 7:43 am
by jedie
OK, i updated my test here: https://github.com/jedie/DragonPy/commi ... fa11831911
Based on the changes here: https://github.com/6809/sbc09/commit/3f ... 080f65e534

Now these tests passed:

Code: Select all

test(10, 10) # OK: 10/10=1 remainder: 0
test(10, 5) # OK: 10/5=2 remainder: 0
test(10, 3) # OK: 10/3=3 remainder: 1
test(0xffff, 0x80) # OK: 65535/128=511 remainder: 127
test(0xffff, 0xff) # OK: 65535/255=257 remainder: 0
test(0xfffff, 0x800) # OK: 1048575/2048=511 remainder: 2047
test(0xffffff, 0x8000) # OK: 16777215/32768=511 remainder: 32767
test(0xfffffff, 0x8000) # OK: 268435455/32768=8191 remainder: 32767
test(0xfffffff, 0xffff) # OK: 268435455/65535=4096 remainder: 4095
test(1, 0xffff) # OK: 1/65535=0 remainder: 1
test(1, 0x8000) # OK: 1/32768=0 remainder: 1
Theses fails:

Code: Select all

test(0xfffffff, 0x1) # ERROR: '268435455/1=16 remainder: 65535' should be: '268435455/1=268435455 remainder: 0'
test(0x58000000, 0x3000) # ERROR: '1476395008/12288=16 remainder: 65535' should be: '1476395008/12288=120149 remainder: 4096'

Re: Small assembler test programms...

Posted: Thu Jul 03, 2014 10:35 pm
by JeeK
jedie wrote:OK, i updated my test here: https://github.com/jedie/DragonPy/commi ... fa11831911
Based on the changes here: https://github.com/6809/sbc09/commit/3f ... 080f65e534

[..]
Theses fails:

Code: Select all

test(0xfffffff, 0x1) # ERROR: '268435455/1=16 remainder: 65535' should be: '268435455/1=268435455 remainder: 0'
test(0x58000000, 0x3000) # ERROR: '1476395008/12288=16 remainder: 65535' should be: '1476395008/12288=120149 remainder: 4096'
These are overflow cases leading to value, which can't expressed 16 bit quotient/remainder. So the overflow condition is - in this actual implemention - flagged by a remainder with value 0xFFFF, beside this, the quotient value is meaningless.
As far as I can see (checked it on a 6502 Forth) - this USLASH implementation is mainly for Forth environments - the quotient (top of stack) is expected to return 0xFFFF (or -1 as signed integer) where the remainder has the value of the divisor.
I will change the implementation towards this to keep the various Forth implementations consistent. ;)

Re: Small assembler test programms...

Posted: Fri Jul 04, 2014 5:11 pm
by JeeK
JeeK wrote:
jedie wrote:OK, i updated my test here: https://github.com/jedie/DragonPy/commi ... fa11831911
Based on the changes here: https://github.com/6809/sbc09/commit/3f ... 080f65e534

[..]
Theses fails:

Code: Select all

test(0xfffffff, 0x1) # ERROR: '268435455/1=16 remainder: 65535' should be: '268435455/1=268435455 remainder: 0'
test(0x58000000, 0x3000) # ERROR: '1476395008/12288=16 remainder: 65535' should be: '1476395008/12288=120149 remainder: 4096'
These are overflow cases leading to value, which can't expressed 16 bit quotient/remainder. So the overflow condition is - in this actual implemention - flagged by a remainder with value 0xFFFF, beside this, the quotient value is meaningless.
As far as I can see (checked it on a 6502 Forth) - this USLASH implementation is mainly for Forth environments - the quotient (top of stack) is expected to return 0xFFFF (or -1 as signed integer) where the remainder has the value of the divisor.
I will change the implementation towards this to keep the various Forth implementations consistent. ;)
Fixed it know, see https://github.com/6809/sbc09/blob/usla ... uslash.asm
Quotient = 0xFFFF and remainder = 0x0000 marks a division by zero, hence the result is undefined
A remainder > 0 if the quotient is 0xFFFF is just an overflow. ;)

Re: Small assembler test programms...

Posted: Fri Jul 04, 2014 9:16 pm
by jedie
I updated my code, too and test your examples.

Only the underflow seems to be wrong:

Code: Select all

DIVH  DIVL    DVSR    QUOT    REM     comment
0000  0001    8000    0000    8000    underflow
Here i get:

Code: Select all

$1 / $8000
OK: 1/32768=0 remainder: 1 (hex: q:$0 r:=$1)
So there is no underflow, isn't it?

Re: Small assembler test programms...

Posted: Mon Jul 07, 2014 3:39 pm
by JeeK
jedie wrote:I updated my code, too and test your examples.

Only the underflow seems to be wrong:

Code: Select all

DIVH  DIVL    DVSR    QUOT    REM     comment
0000  0001    8000    0000    8000    underflow
Here i get:

Code: Select all

$1 / $8000
OK: 1/32768=0 remainder: 1 (hex: q:$0 r:=$1)
So there is no underflow, isn't it?
Wrong documentation of the test value section. Should be

Code: Select all

DIVH  DIVL    DVSR    QUOT    REM     comment
0000  0001    8000    0000    0001    underflow (REM = DIVL)

Re: Small assembler test programms...

Posted: Wed Jul 16, 2014 2:49 pm
by jedie
Exist there somewhere a small assembler prgramm, that used the SEX and MUL Instructions?

Re: Small assembler test programms...

Posted: Wed Jul 16, 2014 3:09 pm
by JeeK
jedie wrote:Exist there somewhere a small assembler prgramm, that used the SEX and MUL Instructions?
What about
https://github.com/6809/sbc09/blob/mast ... test09.asm ?

Re: Small assembler test programms...

Posted: Wed Jul 16, 2014 3:59 pm
by jedie
Hm. Interesting.