Skip to content

Commit

Permalink
Handle negative pointers in MGDPTR
Browse files Browse the repository at this point in the history
Negative pointers may appear when the address of the `Mem` common
block is larger than the handled address.

In this case, the `mod()` function may return a negative result, which
is then corrected by this patch.
  • Loading branch information
olebole committed Oct 15, 2017
1 parent e390f7e commit 8a3e8cb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys/nmemio/mgdptr.x
Expand Up @@ -23,6 +23,8 @@ begin
bufadr = fwa + (5 * SZ_INT)

modulus = mod (bufadr - fwa_align, sz_align)
if (modulus < 0)
modulus = modulus + sz_align
if (modulus != 0)
bufadr = bufadr + (sz_align - modulus)

Expand Down

0 comments on commit 8a3e8cb

Please sign in to comment.