Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/vax/vax Fixes from OpenBSD by Brandon Creighton. (b...



details:   https://anonhg.NetBSD.org/src/rev/44e3bf8f2871
branches:  trunk
changeset: 501892:44e3bf8f2871
user:      ragge <ragge%NetBSD.org@localhost>
date:      Mon Jan 08 22:08:22 2001 +0000

description:
Fixes from OpenBSD by Brandon Creighton. (bjc%openbsd.org@localhost)
Log message from OpenBSD:

> - add EMODD emulation (EMODF) -- this fixes modf() and some libm code
>   on systems which don't have native EMODD (i.e., most of them)
>
> - big cleanup of the getval_* stuff - have one routine doing most of the work
>   instead of four doing the same thing
>
> - add some miscellaneous routines -- count sig. bits
>
> - add more operand addressing modes (still not all fully implemented)
>   both the existing POLYD and EMODD can use them
>
> - add me to copyright
>

diffstat:

 sys/arch/vax/vax/unimpl_emul.s |  598 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 531 insertions(+), 67 deletions(-)

diffs (truncated from 669 to 300 lines):

diff -r fde7056fd033 -r 44e3bf8f2871 sys/arch/vax/vax/unimpl_emul.s
--- a/sys/arch/vax/vax/unimpl_emul.s    Mon Jan 08 21:50:47 2001 +0000
+++ b/sys/arch/vax/vax/unimpl_emul.s    Mon Jan 08 22:08:22 2001 +0000
@@ -1,6 +1,7 @@
-/*     $NetBSD: unimpl_emul.s,v 1.3 2000/08/26 02:31:02 matt Exp $     */
+/*     $NetBSD: unimpl_emul.s,v 1.4 2001/01/08 22:08:22 ragge Exp $    */
 
 /*
+ * Copyright (c) 2001 Brandon Creighton.  All rights reserved.
  * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -63,8 +64,9 @@
        pushl   r0
        movl    8(sp),r0        # get trap address
        movzbl  (r0),r0         # fetch insn generating trap
-       caseb   r0,$0x75,$0     # case to jump to address
-0:     .word   polyd-0b
+       caseb   r0,$0x74,$1     # case to jump to address
+0:     .word   emodd-0b
+       .word   polyd-0b
 
 1:     movl    (sp)+,r0        # restore reg
        rsb                     # continue fault
@@ -104,82 +106,220 @@
 goback:        movl    fp,sp           # be sure
        popr    $0x7fff         # restore all regs
        rei
-#
-# getval_dfloat get 8 bytes and stores them in r0/r1. Increases PC.
-#
+       
+/*
+ * getval: is used by the getval_* functions.  Gets the value specified by the 
+ * current operand specifier pointed to by S_PC.  It also increments S_PC.
+ */
+getval:
+       clrq    r0
+       pushr   $(R2+R3+R4+R5+R6)
+       movl    S_PC,r3         # argument address
+       extzv   $4,$4,(r3),r2   # get mode
+       caseb   r2,$0,$0xf
+0:     .word   getval_literal-0b               # 0-3 literal
+       .word   getval_literal-0b
+       .word   getval_literal-0b
+       .word   getval_literal-0b
+       .word   2f-0b           # 4 indexed
+       .word   getval_reg-0b                   # 5 register
+       .word   getval_regdefer-0b              # 6 register deferred
+       .word   2f-0b           # 7 register deferred
+       .word   getval_ai-0b                    # 8 autoincrement
+       .word   2f-0b           # 9 autoincrement deferred 
+       .word   getval_bytedis-0b               # A byte displacement 
+       .word   2f-0b           # B byte displacement deferred
+       .word   2f-0b           # C word displacement
+       .word   2f-0b           # D word displacement deferred
+       .word   getval_longdis-0b               # E longword displacement
+       .word   2f-0b           # F longword displacement deferred
+#ifdef EMULATE_INKERNEL
+2:     movab   0f,r0
+       movl    r2,r1
+       brw     die
+0:     .asciz  "getval: missing address mode %d\n"
+#else
+2:     .word   0xffff          # reserved operand
+#endif
+
+       /*
+        * 0x00-0x03  
+        * Literal mode.  Note:  getval_{d,f}float will *never* use this routine
+        * to get literal values, since they treat them differently (see those routines
+        * for details).
+        */
+getval_literal:
+       movzbl  (r3)+,r0        # correct operand
+       brw 4f
+
+       /* 
+        * 0x05  
+     * Register mode.  Grab the register number, yank the value out.
+        */
+getval_reg:    
+       extzv   $0,$4,(r3),r2   # Get reg number
+       incl    r3
+       ashl    $2,r2,r2
+       addl3   fp,r2,r5
+       bsbw    emul_extract
+       brw             4f
+
+       /* 
+        * 0x06
+     * Register deferred mode.  Grab the register number, yank the value out,
+        * use that as the address to get the real value.
+        */
+getval_regdefer:       
+       extzv   $0,$4,(r3),r2   # Get reg number
+       incl    r3
+       ashl    $2,r2,r2
+       addl2   fp,r2
+       movl    (r2),r5
+       bsbw    emul_extract
+       brw             4f
+
+       /* 
+        * 0x08 Autoincrement mode
+     * Get the value in the register, use that as the address of our target,
+        * then increment the register.
+        */
+getval_ai:
+       extzv   $0,$4,(r3),r2   # Get reg number
+       incl    r3
+
+       /*
+        * In the case of the register being PC (0xf), this is called immediate mode;
+        * we can treat it the same as any other register, as long as we keep r3
+     * and S_PC in sync.  We do that here.      
+        */
+       movl    r3,S_PC
+
+       ashl    $2,r2,r2
+       addl2   fp,r2
+       movl    (r2),r5
+       bsbw    emul_extract
+       addl2   r6,(r2)
+
+       movl    S_PC,r3         /* if PC did change, S_PC was changed too */
+       brw             4f
+
+       /*
+        * 0xA
+        * Byte displacement mode.
+     */         
+getval_bytedis: 
+       extzv   $0, $4, (r3), r2        # get register 
+       incl    r3
+       ashl    $2,r2,r2
+       addl2   fp,r2
+       movl    (r2),r5
+       movzbl  (r3),r4
+       incl    r3
+       addl2   r4, r5
+       bsbw    emul_extract
+       brw             4f
+
+       /*
+        * 0xE  
+        * Longword displacement mode.
+     */         
+getval_longdis: 
+       extzv   $0, $4, (r3), r2        # get register 
+       incl    r3
+       ashl    $2,r2,r2
+       addl2   fp,r2
+       movl    (r2),r5
+       movl    (r3)+,r4
+       addl2   r4, r5
+       bsbw    emul_extract
+
+4:     movl    r3,S_PC
+       popr    $(R2+R3+R4+R5+R6)
+       rsb
+
+/*
+ * emul_extract: used by the getval functions.  This extracts exactly r6 bytes 
+ * from the address in r5 and places them in r0 and r1 (if necessary).
+ * 8 is the current maximum length.
+ */
+emul_extract:
+       cmpl $0x8, r6
+       bgeq 1f
+       .word   0xffff          # reserved operand
+1:     
+       caseb r6, $0x1, $0x7
+0:     .word 1f-0b                     # 1: byte
+       .word 2f-0b                     # 2: word
+       .word 9f-0b                     # unknown
+       .word 4f-0b                     # 4: longword
+       .word 9f-0b                     # unknown
+       .word 9f-0b                     # unknown
+       .word 9f-0b                     # unknown
+       .word 8f-0b                     # 8: quadword
+
+1:     movzbl (r5), r0
+       rsb
+
+2:     movzwl (r5), r0
+       rsb
+
+4:     movl (r5), r0
+       rsb
+
+8:     movq (r5), r0
+       rsb
+
+9:     
+       .word   0xffff          # reserved operand
+       rsb
+
 getval_dfloat:
        clrq    r0
-       pushr   $(R2+R3)        # use r2+r3 as scratch reg
-       movl    S_PC,r3         # argument address
+       pushr   $(R2+R3+R6)     # use r2+r3 as scratch reg
+       movl    S_PC,r3         # argument address 
        extzv   $4,$4,(r3),r2   # get mode
-       caseb   r2,$0,$5
+       caseb   r2,$0,$0x3
 0:     .word   1f-0b           # 0-3 literal
        .word   1f-0b
        .word   1f-0b
        .word   1f-0b
-       .word   2f-0b           # 4 indexed
-       .word   3f-0b           # 5 register
-#ifdef EMULATE_INKERNEL
-2:     movab   0f,r0
-       movl    r2,r1
-       brw     die
-0:     .asciz  "getval_dfloat: missing address mode %d\n"
-#else
-2:     .word   0xffff          # reserved operand
-#endif
+
+       movl    $0x8, r6
+       bsbw    getval
+       brw             4f
 
 1:     insv    (r3),$0,$3,r0   # insert fraction
        extzv   $3,$3,(r3),r2   # get exponent
        addl2   $128,r2         # bias the exponent
        insv    r2,$7,$8,r0     # insert exponent
-       tstl    (r3)+
-       brb 4f
-
-3:     extzv   $0,$4,(r3),r2   # Get reg number
-       incl    r3
-       ashl    $2,r2,r2
-       addl2   fp,r2
-       movq    (r2),r0
-
-4:     movl    r3,S_PC
-       popr    $(R2+R3)
+       tstb    (r3)+
+       movl    r3,S_PC
+4:
+       popr    $(R2+R3+R6)
        rsb
 
-#
-# getval_word get 2 bytes and stores them zero-extended in r0. Increases PC.
-#
+getval_long:
+       clrl    r0
+       pushr   $(R6+R1)        
+       movl    $0x4, r6
+       bsbw    getval
+       popr    $(R6+R1)
+       rsb
+
 getval_word:
        clrl    r0
-       pushr   $(R2+R3)        # use r2+r3 as scratch reg
-       movl    S_PC,r3         # argument address
-       extzv   $4,$4,(r3),r2   # get mode
-       caseb   r2,$0,$5
-0:     .word   1f-0b           # 0-3 literal
-       .word   1f-0b
-       .word   1f-0b
-       .word   1f-0b
-       .word   2f-0b           # 4 indexed
-       .word   3f-0b           # 5 register
-#ifdef EMULATE_INKERNEL
-2:     movab   0f,r0
-       movl    r2,r1
-       brw     die
-0:     .asciz  "getval_word: missing address mode %d\n"
-#else
-2:     .word   0xffff          # reserved operand
-#endif
+       pushr   $(R6+R1)
+       movl    $0x2, r6
+       bsbw    getval
+       popr    $(R6+R1)
+       rsb
 
-1:     movb    (r3)+,r0        # correct operand
-       brb 4f
-
-3:     extzv   $0,$4,(r3),r2   # Get reg number
-       incl    r3
-       ashl    $2,r2,r2
-       addl2   fp,r2
-       movw    (r2),r0
-
-4:     movl    r3,S_PC
-       popr    $(R2+R3)
+getval_byte:
+       clrl    r0
+       pushr   $(R6+R1)        # use r2+r3 as scratch reg
+       movl    $0x1, r6
+       bsbw    getval



Home | Main Index | Thread Index | Old Index