{ /*.p.t.20030716 handling for i/o port read access for Z80 */
if( aop->paged )
{ /* banked mode */
- if( aop->bcInUse ) emit2( "push bc" );
-
- emit2( "ld bc,#%s", aop->aopu.aop_dir );
- emit2( "in a,(c)" );
-
- if( aop->bcInUse )
- emit2( "pop bc" );
- else
- spillPair (PAIR_BC);
+ /* reg A goes to address bits 15-8 during "in a,(x)" instruction */
+ emit2( "ld a,!msbimmeds", aop->aopu.aop_dir);
+ emit2( "in a,(!lsbimmeds)", aop->aopu.aop_dir);
}
else if( z80_opts.port_mode == 180 )
{ /* z180 in0/out0 mode */
int count, i;
/* If true then the final operation should be a subtract */
bool active = FALSE;
+ bool byteResult;
/* Shouldn't occur - all done through function calls */
aopOp (IC_LEFT (ic), ic, FALSE, FALSE);
aopOp (IC_RIGHT (ic), ic, FALSE, FALSE);
aopOp (IC_RESULT (ic), ic, TRUE, FALSE);
+
+ byteResult = (AOP_SIZE (IC_RESULT (ic)) == 1);
if (AOP_SIZE (IC_LEFT (ic)) > 2 ||
AOP_SIZE (IC_RIGHT (ic)) > 2 ||
if ( AOP_SIZE (IC_LEFT (ic)) == 1 && !SPEC_USIGN (getSpec (operandType ( IC_LEFT (ic)))))
{
emit2 ("ld e,%s", aopGet (AOP (IC_LEFT (ic)), LSB, FALSE));
- emit2 ("ld a,e");
- emit2 ("rlc a");
- emit2 ("sbc a,a");
- emit2 ("ld d,a");
+ if (!byteResult)
+ {
+ emit2 ("ld a,e");
+ emit2 ("rlc a");
+ emit2 ("sbc a,a");
+ emit2 ("ld d,a");
+ }
}
else
{
if (active == FALSE)
{
emit2 ("ld l,e");
- emit2 ("ld h,d");
+ if (!byteResult)
+ emit2 ("ld h,d");
}
else
{
_G.stack.pushedDE = FALSE;
}
- commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);
+ if (byteResult)
+ aopPut (AOP (IC_RESULT (ic)), _pairs[PAIR_HL].l, 0);
+ else
+ commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);
freeAsmop (IC_LEFT (ic), NULL, ic);
freeAsmop (IC_RIGHT (ic), NULL, ic);
static void
genDummyRead (iCode * ic)
{
- operand *right;
+ operand *op;
int size, offset;
- right = IC_RIGHT (ic);
- aopOp (right, ic, FALSE, FALSE);
+ op = IC_RIGHT (ic);
+ if (op && IS_SYMOP (op))
+ {
+ aopOp (op, ic, FALSE, FALSE);
- /* general case */
- size = AOP_SIZE (right);
- offset = 0;
+ /* general case */
+ size = AOP_SIZE (op);
+ offset = 0;
- while (size--)
- {
- _moveA (aopGet (AOP (right), offset, FALSE));
- offset++;
+ while (size--)
+ {
+ _moveA (aopGet (AOP (op), offset, FALSE));
+ offset++;
+ }
+
+ freeAsmop (op, NULL, ic);
}
+
+ op = IC_LEFT (ic);
+ if (op && IS_SYMOP (op))
+ {
+ aopOp (op, ic, FALSE, FALSE);
+
+ /* general case */
+ size = AOP_SIZE (op);
+ offset = 0;
- freeAsmop (right, NULL, ic);
+ while (size--)
+ {
+ _moveA (aopGet (AOP (op), offset, FALSE));
+ offset++;
+ }
+
+ freeAsmop (op, NULL, ic);
+ }
}
enum