From c1c10089e361a12d5da101f195d0813952cee3e1 Mon Sep 17 00:00:00 2001 From: "Guillermo J. Rozas" Date: Mon, 27 Nov 1989 18:16:04 +0000 Subject: [PATCH] Fix the LDIL assembly and disassembly. The bits are not contiguous! --- v7/src/microcode/cmpintmd/hppa.h | 64 ++++++++++++-------------------- v8/src/microcode/cmpintmd/hppa.h | 64 ++++++++++++-------------------- 2 files changed, 46 insertions(+), 82 deletions(-) diff --git a/v7/src/microcode/cmpintmd/hppa.h b/v7/src/microcode/cmpintmd/hppa.h index e49f056a7..f619757b7 100644 --- a/v7/src/microcode/cmpintmd/hppa.h +++ b/v7/src/microcode/cmpintmd/hppa.h @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/hppa.h,v 1.2 1989/11/27 16:12:48 jinx Exp $ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/hppa.h,v 1.3 1989/11/27 18:16:04 jinx Exp $ * * Compiled code interface macros. * @@ -91,61 +91,43 @@ typedef unsigned short format_word; w, w1, and the top and bottom bits of w2) are zero. */ -/* This does the full decoding, unnecessary */ - -#if 0 -#define EXTRACT_ABSOLUTE_ADDRESS(target, address) \ -{ \ - unsigned long ldil_inst, ble_inst, w, w1, w2, offset; \ - \ - ldil_inst = ((long *) (address))[0]; \ - ble_inst = ((long *) (address))[1]; \ - \ - w = (ble_inst & 1); \ - w1 = ((ble_inst >> 16) & ((1 << 6) - 1)); \ - w2 = ((ble_inst >> 2) & ((1 << 12) - 1)); \ - \ - offset = ((w << 16) | (w1 << 11) | \ - ((w2 & 1) << 10) | (w2 >> 1)); \ - if (w != 0) \ - { \ - offset |= (((1 << 16) - 1) << 17); \ - } \ - \ - ((long) (target)) = \ - (((long) ((ldil_inst & ((1 << 22) - 1)) << 11)) + \ - ((long) (offset << 2))); \ -} -#endif - -/* This does the partial decoding needed. */ - #define EXTRACT_ABSOLUTE_ADDRESS(target, address) \ { \ - unsigned long ldil_inst, ble_inst, offset; \ + unsigned long *addr, ldil_inst, ble_inst, ldil_offset, ble_offset; \ \ - ldil_inst = ((long *) (address))[0]; \ - ble_inst = ((long *) (address))[1]; \ + addr = ((unsigned long *) (address)); \ + ldil_inst = *addr++; \ + ble_inst = *addr; \ \ - offset = ((ble_inst >> 3) & ((1 << 10) - 1)); \ + ldil_offset = (((ldil_inst & 1) << 20) | \ + ((ldil_inst & ((1 << 12) - (1 << 1))) << (9 - 1)) | \ + ((ldil_inst & ((1 << 16) - (1 << 14))) >> (14 - 7)) | \ + ((ldil_inst & ((1 << 21) - (1 << 16))) >> (16 - 2)) | \ + ((ldil_inst & ((1 << 14) - (1 << 12))) >> (12 - 0))); \ + ble_offset = ((ble_inst >> 3) & ((1 << 10) - 1)); \ \ - ((long) (target)) = \ - (((ldil_inst & ((1 << 22) - 1)) << 11) + \ - (offset << 2)); \ + ((long) (target)) = ((ldil_offset << 11) + (ble_offset << 2)); \ } #define STORE_ABSOLUTE_ADDRESS(absadd, address, nullify_p) \ { \ - unsigned long actual_address, offset; \ + unsigned long actual_address, ldil_offset, ble_offset; \ \ actual_address = ((long) (real_entry_point)); \ \ + ldil_offset = (actual_address >> 11); \ + \ /* LDIL L'actual_address,26 */ \ \ ((unsigned long *) (entry_point))[0] = \ - ((0x8 << 26) | (26 << 21) | (actual_address >> 11)); \ + ((0x8 << 26) | (26 << 21) | \ + ((ldil_offset & ((1 << 7) - (1 << 2))) << (16 - 2)) | \ + ((ldil_offset & ((1 << 9) - (1 << 7))) << (14 - 7)) | \ + ((ldil_offset & ((1 << 2) - 1)) << (12 - 0)) | \ + ((ldil_offset & ((1 << 20) - (1 << 9))) >> (9 - 1)) | \ + ((ldil_offset & (1 << 20)) >> 20)); \ \ - offset = ((actual_address & ((1 << 12) - 1)) >> 2); \ + ble_offset = ((actual_address & ((1 << 12) - 1)) >> 2); \ \ /* BLE R'actual_address(5,26) \ The following instruction is nullified if nullify_p is true. \ @@ -154,7 +136,7 @@ typedef unsigned short format_word; */ \ \ ((unsigned long *) (entry_point))[1] = \ - ((0x39 << 26) | (26 << 21) | (5 << 13) | ((offset << 1) << 2) | \ + ((0x39 << 26) | (26 << 21) | (5 << 13) | ((ble_offset << 1) << 2) | \ ((nullify_p) ? 2 : 0)); \ } diff --git a/v8/src/microcode/cmpintmd/hppa.h b/v8/src/microcode/cmpintmd/hppa.h index 07d802694..7c7b89cd9 100644 --- a/v8/src/microcode/cmpintmd/hppa.h +++ b/v8/src/microcode/cmpintmd/hppa.h @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/cmpintmd/hppa.h,v 1.2 1989/11/27 16:12:48 jinx Exp $ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/cmpintmd/hppa.h,v 1.3 1989/11/27 18:16:04 jinx Exp $ * * Compiled code interface macros. * @@ -91,61 +91,43 @@ typedef unsigned short format_word; w, w1, and the top and bottom bits of w2) are zero. */ -/* This does the full decoding, unnecessary */ - -#if 0 -#define EXTRACT_ABSOLUTE_ADDRESS(target, address) \ -{ \ - unsigned long ldil_inst, ble_inst, w, w1, w2, offset; \ - \ - ldil_inst = ((long *) (address))[0]; \ - ble_inst = ((long *) (address))[1]; \ - \ - w = (ble_inst & 1); \ - w1 = ((ble_inst >> 16) & ((1 << 6) - 1)); \ - w2 = ((ble_inst >> 2) & ((1 << 12) - 1)); \ - \ - offset = ((w << 16) | (w1 << 11) | \ - ((w2 & 1) << 10) | (w2 >> 1)); \ - if (w != 0) \ - { \ - offset |= (((1 << 16) - 1) << 17); \ - } \ - \ - ((long) (target)) = \ - (((long) ((ldil_inst & ((1 << 22) - 1)) << 11)) + \ - ((long) (offset << 2))); \ -} -#endif - -/* This does the partial decoding needed. */ - #define EXTRACT_ABSOLUTE_ADDRESS(target, address) \ { \ - unsigned long ldil_inst, ble_inst, offset; \ + unsigned long *addr, ldil_inst, ble_inst, ldil_offset, ble_offset; \ \ - ldil_inst = ((long *) (address))[0]; \ - ble_inst = ((long *) (address))[1]; \ + addr = ((unsigned long *) (address)); \ + ldil_inst = *addr++; \ + ble_inst = *addr; \ \ - offset = ((ble_inst >> 3) & ((1 << 10) - 1)); \ + ldil_offset = (((ldil_inst & 1) << 20) | \ + ((ldil_inst & ((1 << 12) - (1 << 1))) << (9 - 1)) | \ + ((ldil_inst & ((1 << 16) - (1 << 14))) >> (14 - 7)) | \ + ((ldil_inst & ((1 << 21) - (1 << 16))) >> (16 - 2)) | \ + ((ldil_inst & ((1 << 14) - (1 << 12))) >> (12 - 0))); \ + ble_offset = ((ble_inst >> 3) & ((1 << 10) - 1)); \ \ - ((long) (target)) = \ - (((ldil_inst & ((1 << 22) - 1)) << 11) + \ - (offset << 2)); \ + ((long) (target)) = ((ldil_offset << 11) + (ble_offset << 2)); \ } #define STORE_ABSOLUTE_ADDRESS(absadd, address, nullify_p) \ { \ - unsigned long actual_address, offset; \ + unsigned long actual_address, ldil_offset, ble_offset; \ \ actual_address = ((long) (real_entry_point)); \ \ + ldil_offset = (actual_address >> 11); \ + \ /* LDIL L'actual_address,26 */ \ \ ((unsigned long *) (entry_point))[0] = \ - ((0x8 << 26) | (26 << 21) | (actual_address >> 11)); \ + ((0x8 << 26) | (26 << 21) | \ + ((ldil_offset & ((1 << 7) - (1 << 2))) << (16 - 2)) | \ + ((ldil_offset & ((1 << 9) - (1 << 7))) << (14 - 7)) | \ + ((ldil_offset & ((1 << 2) - 1)) << (12 - 0)) | \ + ((ldil_offset & ((1 << 20) - (1 << 9))) >> (9 - 1)) | \ + ((ldil_offset & (1 << 20)) >> 20)); \ \ - offset = ((actual_address & ((1 << 12) - 1)) >> 2); \ + ble_offset = ((actual_address & ((1 << 12) - 1)) >> 2); \ \ /* BLE R'actual_address(5,26) \ The following instruction is nullified if nullify_p is true. \ @@ -154,7 +136,7 @@ typedef unsigned short format_word; */ \ \ ((unsigned long *) (entry_point))[1] = \ - ((0x39 << 26) | (26 << 21) | (5 << 13) | ((offset << 1) << 2) | \ + ((0x39 << 26) | (26 << 21) | (5 << 13) | ((ble_offset << 1) << 2) | \ ((nullify_p) ? 2 : 0)); \ } -- 2.25.1