From 07092a19ca52b2a78e07491f8c4763cd40b75fc8 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 19 Feb 1991 12:41:27 +0000 Subject: [PATCH] prevent sign-extension in unpack when needed --- lang/pc/comp/code.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lang/pc/comp/code.c b/lang/pc/comp/code.c index fcb61cc54..2f2c84ae0 100644 --- a/lang/pc/comp/code.c +++ b/lang/pc/comp/code.c @@ -1023,6 +1023,7 @@ CodeStd(nd) case R_PACK: { label lba = tp->arr_ardescr; + CodeDAddress(left); arg = arg->nd_right; left = arg->nd_left; @@ -1043,6 +1044,12 @@ CodeStd(nd) */ label lba, lbz = tp->arr_ardescr; + tp = tp->arr_elem; + if (tp->tp_fund == T_SUBRANGE && + tp->sub_lb >= 0) { + C_loc((arith) 1); + } + else C_loc((arith) 0); CodeDAddress(left); arg = arg->nd_right; left = arg->nd_left; @@ -1054,7 +1061,7 @@ CodeStd(nd) C_lae_dlb(lbz, (arith) 0); C_lae_dlb(lba, (arith) 0); C_cal("_unp"); - C_asp(4 * pointer_size + word_size); + C_asp(4 * pointer_size + 2 * word_size); break; } -- 2.34.1