* src/z80/gen.c (aopPut): fixed bug #1103902
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 26 Jan 2005 14:20:13 +0000 (14:20 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 26 Jan 2005 14:20:13 +0000 (14:20 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3656 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/z80/gen.c

index 68bae6e52aa97b7a1226e6a88904e4ad7dba91ee..dbc95f60be8c4f228557a8d4320b63a6d64ce041 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-01-26 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/z80/gen.c (aopPut): fixed bug #1103902
+
 2004-01-25 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
 
        * device/lib/expf.c: fixed bug #1095792
index 97776615384011a6c91226dfa5db500cc144e05a..88324babef20bf38d18787136b0871fec30e2163 100644 (file)
@@ -1879,48 +1879,46 @@ aopPut (asmop * aop, const char *s, int offset)
 
     case AOP_SFR:
       if( IS_GB )
-      {
-        //  wassert (IS_GB);
-        if (strcmp (s, "a"))
-          emit2 ("ld a,%s", s);
-        emit2 ("ldh (%s+%d),a", aop->aopu.aop_dir, offset);
-      }
+        {
+          //  wassert (IS_GB);
+          if (strcmp (s, "a"))
+            emit2 ("ld a,%s", s);
+          emit2 ("ldh (%s+%d),a", aop->aopu.aop_dir, offset);
+        }
       else
-      { /*.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 );
-
-          if(( s[0] == '#'    ) /* immediate number */
-           ||( s[0] == '('    ) /* indirect register (ix or iy ??)*/
-           ||( isdigit( s[0] )))/* indirect register with offset (ix or iy ??)*/
-          {
-            emit2( "ld a,%s", s );
-            emit2( "out (c),a"  );
-          }
-          else
-          {
-            emit2( "out (c),%s", s );
-          }
+        { /*.p.t.20030716 handling for i/o port read access for Z80 */
+          if (aop->paged)
+            { /* banked mode */
+              if (aop->bcInUse)
+                emit2( "push bc" );
+
+              if (strlen(s) != 1
+                  || (s[0] != 'a' && s[0] != 'd' && s[0] != 'e'
+                      && s[0] != 'h' && s[0] != 'l'))
+                {
+                  emit2( "ld a,%s", s );
+                  s = "a";
+                }
+              
+              emit2( "ld bc,#%s", aop->aopu.aop_dir );
+              emit2( "out (c),%s", s );
         
-          if( aop->bcInUse )
-            emit2( "pop bc"    );
+              if( aop->bcInUse )
+                emit2( "pop bc"    );
+              else
+                spillPair (PAIR_BC);
+            }
+          else if( z80_opts.port_mode == 180 )
+            { /* z180 in0/out0 mode */
+              emit2( "ld a,%s", s );
+              emit2( "out0 (%s),a", aop->aopu.aop_dir );
+            }
           else
-            spillPair (PAIR_BC);
-        }
-        else if( z80_opts.port_mode == 180 )
-        { /* z180 in0/out0 mode */
-          emit2( "ld a,%s", s );
-          emit2( "out0 (%s),a", aop->aopu.aop_dir );
-        }
-        else
-        { /* 8 bit mode */
-          emit2( "ld a,%s", s );
-          emit2( "out (%s),a", aop->aopu.aop_dir );
+            { /* 8 bit mode */
+              emit2( "ld a,%s", s );
+              emit2( "out (%s),a", aop->aopu.aop_dir );
+            }
         }
-      }
       break;
 
     case AOP_REG: