From: Alfonso <a.martone@retepnet.it>
To: linux-8086@vger.kernel.org
Subject: reducing Elks code size...
Date: Fri, 21 Feb 2003 23:10:09 +0100 [thread overview]
Message-ID: <200302212242.00571.a.martone@retepnet.it> (raw)
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---
next reply other threads:[~2003-02-21 22:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-21 22:10 Alfonso [this message]
2003-02-22 18:23 ` reducing Elks code size Alan Cox
2003-02-22 20:57 ` Miguel A. Bolanos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200302212242.00571.a.martone@retepnet.it \
--to=a.martone@retepnet.it \
--cc=linux-8086@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox