Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*

SubjectBinary Coded Decimals Reply to this message
Posted byfinaldave
Posted on05/07/04 08:45 PM

With ABCD on 68000, am I right that you need the half-carry bit in order to use a DAA table?

That's the conclusion I've come to anyway... in fact the only way I can think of to do ABCD on ARM...which has no half-carry bit and no daa or das instructions... is this:

ot(";@ Add units into r2:\n");
ot(" and r2,r10,#0x0f\n");
ot(" and r0,r1, #0x0f\n");
ot(" add r2,r2,r0\n");
ot(" cmp r2,#0x0a ;@ Decimal adjust units\n");
ot(" addge r2,r2,#0x06\n");
ot(";@ Add tens into r3:\n");
ot(" and r3,r10,#0xf0\n");
ot(" and r0,r1, #0xf0\n");
ot(" add r3,r3,r0\n");
ot(" add r1,r3,r2 ;@ Add tens and units into r1\n");
ot(" cmp r1,#0xa0 ;@ Decimal adjust tens\n");
ot(" addge r1,r1,#0x60\n");

Haven't added flags and SBCD yet. I mean that's not too bad a routine since abcd isn't used a lot, but will it cater for all the undocumented non decimal cases, e.g 0xfe 0x2b or something ??

update - Thanks for the notes Bart!
Also, can you think of a better way on ARM, or is that it do you think?

Cyclone is *almost* there... ;) just a few bits and bugs to go

For completeness here is my SBCD:

ot(";@ Sub units into r2:\n");
ot(" and r2,r1, #0x0f\n");
ot(" and r0,r10,#0x0f\n");
ot(" subs r2,r2,r0\n");
ot(" sublt r2,r2,#0x06\n");
ot(";@ Sub tens into r3:\n");
ot(" and r3,r1, #0xf0\n");
ot(" and r0,r10,#0xf0\n");
ot(" sub r3,r3,r0\n");
ot(" adds r1,r3,r2 ;@ Add tens and units into r1\n");
ot(" sublt r2,r2,#0x60\n");

Seems to work for Ghouls N Ghosts. Haven't thought about flags yet...

You learn something old everyday...

Entire Thread
Subject  Posted byPosted On
.Binary Coded Decimals  finaldave05/07/04 08:45 PM
.*Re: Binary Coded Decimals  Bart T.05/07/04 09:47 PM