Small assembler test programms...

Hardware Hacking, Programming and Game Solutions/Cheats
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Small assembler test programms...

Post 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'
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: Small assembler test programms...

Post 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. ;)
The dragon on my side: http://klasek.at/hc/dragon/
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: Small assembler test programms...

Post 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. ;)
The dragon on my side: http://klasek.at/hc/dragon/
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Small assembler test programms...

Post 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?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: Small assembler test programms...

Post 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)
The dragon on my side: http://klasek.at/hc/dragon/
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Small assembler test programms...

Post by jedie »

Exist there somewhere a small assembler prgramm, that used the SEX and MUL Instructions?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: Small assembler test programms...

Post 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 ?
The dragon on my side: http://klasek.at/hc/dragon/
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: Small assembler test programms...

Post by jedie »

Hm. Interesting.
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Post Reply