From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alfonso Subject: reducing Elks code size... Date: Fri, 21 Feb 2003 23:10:09 +0100 Sender: linux-8086-owner@vger.kernel.org Message-ID: <200302212242.00571.a.martone@retepnet.it> Reply-To: a.martone@retepnet.it Mime-Version: 1.0 Content-Transfer-Encoding: 8BIT Return-path: List-Id: Content-Type: text/plain; charset="us-ascii" To: linux-8086@vger.kernel.org This file: elks/arch/i86/286pmode/irq.s may be reduced to save 564 bytes (!!) of code. This is not a massive optimization process. It just saves space by pushing a value on the stack and jumping to a generic routine instead of repeating the entire sequence every time (like elks/arch/i86/kernel/irqtab.c), so that its final code size is 0x00B6 bytes instead of 0x02EA bytes (I still wonder why the irq.s file was written in that weird mode). The do_exc routine in the file elks/arch/i86/kernel/main.c does not need changes: the bp register is changed (to get again the saved exception/interrupt value) but the stack (with all parameters) remains the same. ! ! irq.s ! ! low-level entry points for interrupts and exceptions ! PMODE_DATASEL equ 0x10 .text .extern _do_exc .extern _do_irq .globl _exc_00 .globl _exc_01 .globl _exc_02 .globl _exc_03 .globl _exc_04 .globl _exc_05 .globl _exc_06 .globl _exc_07 .globl _exc_08 .globl _exc_09 .globl _exc_0a .globl _exc_0b .globl _exc_0c .globl _exc_0d .globl _exc_0e .globl _exc_10 .globl _exc_11 .globl _exc_ff _exc_ff: push #-1 jmp _doexce _exc_00: push #0 jmp _doexce _exc_01: push #1 jmp _doexce _exc_02: push #2 jmp _doexce _exc_03: push #3 jmp _doexce _exc_04: push #4 jmp _doexce _exc_05: push #5 jmp _doexce _exc_06: push #6 jmp _doexce _exc_07: push #7 jmp _doexce _exc_08: push #8 jmp _doexce _exc_09: push #9 jmp _doexce _exc_0a: push #10 jmp _doexce _exc_0b: push #11 jmp _doexce _exc_0c: push #12 jmp _doexce _exc_0d: push #13 jmp _doexce _exc_0e: push #14 jmp _doexce _exc_10: push #16 jmp _doexce _exc_11: push #17 ! jmp _doexce ! useless jump _doexce: pusha mov bp, sp push ds push es mov ax, #PMODE_DATASEL mov ds, ax mov es, ax push [bp+16] ! push the saved number (#-1, #0, #17, etc) call _do_exc ! pop ax ! get rid of it pop es pop ds popa inc sp ! get rid of the saved number inc sp iret .globl _irq_0 .globl _irq_1 .globl _irq_2 .globl _irq_3 .globl _irq_4 .globl _irq_5 .globl _irq_6 .globl _irq_7 .globl _irq_8 .globl _irq_9 .globl _irq_10 .globl _irq_11 .globl _irq_12 .globl _irq_13 .globl _irq_14 .globl _irq_15 _irq_0: push #0 jmp _doirqs _irq_1: push #1 jmp _doirqs _irq_2: push #2 jmp _doirqs _irq_3: push #3 jmp _doirqs _irq_4: push #4 jmp _doirqs _irq_5: push #5 jmp _doirqs _irq_6: push #6 jmp _doirqs _irq_7: push #7 jmp _doirqs _irq_8: push #8 jmp _doirqs _irq_9: push #9 jmp _doirqs _irq_10: push #10 jmp _doirqs _irq_11: push #11 jmp _doirqs _irq_12: push #12 jmp _doirqs _irq_13: push #13 jmp _doirqs _irq_14: push #14 jmp _doirqs _irq_15: push #15 ! jmp _doirqs ! useless jump _doirqs: pusha mov bp, sp push ds push es mov ax, #PMODE_DATASEL mov ds, ax mov es, ax push [bp+16] call _do_irq pop ax pop es pop ds popa inc sp inc sp iret ! ---the end---