diff --git a/i386-dm/helper2.c b/i386-dm/helper2.c
index 8f2a893..5eb1901 100644
--- a/i386-dm/helper2.c
+++ b/i386-dm/helper2.c
@@ -339,14 +339,30 @@ static void do_outp(CPUState *env, unsigned long addr,
     }
 }
 
-static inline void read_physical(uint64_t addr, unsigned long size, void *val)
+static inline void read_physical_offset(target_phys_addr_t addr,
+                                        unsigned long offset,
+                                        int sign,
+                                        unsigned long size,
+                                        void *val)
 {
-    return cpu_physical_memory_rw((target_phys_addr_t)addr, val, size, 0);
+    if (sign >= 0)
+        addr += offset;
+    else
+        addr -= offset;
+    return cpu_physical_memory_rw(addr, val, size, 0);
 }
 
-static inline void write_physical(uint64_t addr, unsigned long size, void *val)
+static inline void write_physical_offset(target_phys_addr_t addr,
+                                         unsigned long offset,
+                                         int sign,
+                                         unsigned long size,
+                                         void *val)
 {
-    return cpu_physical_memory_rw((target_phys_addr_t)addr, val, size, 1);
+    if (sign >= 0)
+        addr += offset;
+    else
+        addr -= offset;
+    return cpu_physical_memory_rw(addr, val, size, 1);
 }
 
 static void cpu_ioreq_pio(CPUState *env, ioreq_t *req)
@@ -364,9 +380,9 @@ static void cpu_ioreq_pio(CPUState *env, ioreq_t *req)
 
             for (i = 0; i < req->count; i++) {
                 tmp = do_inp(env, req->addr, req->size);
-                write_physical((target_phys_addr_t) req->data
-                  + (sign * i * req->size),
-                  req->size, &tmp);
+                write_physical_offset((target_phys_addr_t) req->data,
+                                      i * req->size, sign,
+                                      req->size, &tmp);
             }
         }
     } else if (req->dir == IOREQ_WRITE) {
@@ -376,9 +392,9 @@ static void cpu_ioreq_pio(CPUState *env, ioreq_t *req)
             for (i = 0; i < req->count; i++) {
                 unsigned long tmp = 0;
 
-                read_physical((target_phys_addr_t) req->data
-                  + (sign * i * req->size),
-                  req->size, &tmp);
+                read_physical_offset((target_phys_addr_t) req->data,
+                              i * req->size, sign,
+                              req->size, &tmp);
                 do_outp(env, req->addr, req->size, tmp);
             }
         }
@@ -395,14 +411,14 @@ static void cpu_ioreq_move(CPUState *env, ioreq_t *req)
     if (!req->data_is_ptr) {
         if (req->dir == IOREQ_READ) {
             for (i = 0; i < req->count; i++) {
-                read_physical(req->addr
-                  + (sign * i * req->size),
+                read_physical_offset(req->addr,
+                  i * req->size, sign,
                   req->size, &req->data);
             }
         } else if (req->dir == IOREQ_WRITE) {
             for (i = 0; i < req->count; i++) {
-                write_physical(req->addr
-                  + (sign * i * req->size),
+                write_physical_offset(req->addr,
+                  i * req->size, sign,
                   req->size, &req->data);
             }
         }
@@ -411,20 +427,20 @@ static void cpu_ioreq_move(CPUState *env, ioreq_t *req)
 
         if (req->dir == IOREQ_READ) {
             for (i = 0; i < req->count; i++) {
-                read_physical(req->addr
-                  + (sign * i * req->size),
+                read_physical_offset(req->addr,
+                  i * req->size, sign,
                   req->size, &tmp);
-                write_physical((target_phys_addr_t )req->data
-                  + (sign * i * req->size),
+                write_physical_offset((target_phys_addr_t )req->data,
+                  i * req->size, sign,
                   req->size, &tmp);
             }
         } else if (req->dir == IOREQ_WRITE) {
             for (i = 0; i < req->count; i++) {
-                read_physical((target_phys_addr_t) req->data
-                  + (sign * i * req->size),
+                read_physical_offset((target_phys_addr_t) req->data,
+                  i * req->size, sign,
                   req->size, &tmp);
-                write_physical(req->addr
-                  + (sign * i * req->size),
+                write_physical_offset(req->addr,
+                  i * req->size, sign,
                   req->size, &tmp);
             }
         }
