public inbox for linux-8086@vger.kernel.org
 help / color / mirror / Atom feed
* reducing Elks code size...
@ 2003-02-21 22:10 Alfonso
  2003-02-22 18:23 ` Alan Cox
  2003-02-22 20:57 ` Miguel A. Bolanos
  0 siblings, 2 replies; 3+ messages in thread
From: Alfonso @ 2003-02-21 22:10 UTC (permalink / raw)
  To: linux-8086

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---


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: reducing Elks code size...
  2003-02-21 22:10 reducing Elks code size Alfonso
@ 2003-02-22 18:23 ` Alan Cox
  2003-02-22 20:57 ` Miguel A. Bolanos
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Cox @ 2003-02-22 18:23 UTC (permalink / raw)
  To: a.martone; +Cc: linux-8086

On Fri, 2003-02-21 at 22:10, Alfonso wrote:
> 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 

564 bytes is 1% of the size of the program. Thats a big deal. Neat stuff


Alan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: reducing Elks code size...
  2003-02-21 22:10 reducing Elks code size Alfonso
  2003-02-22 18:23 ` Alan Cox
@ 2003-02-22 20:57 ` Miguel A. Bolanos
  1 sibling, 0 replies; 3+ messages in thread
From: Miguel A. Bolanos @ 2003-02-22 20:57 UTC (permalink / raw)
  To: a.martone; +Cc: linux-8086

Greetings,

On Fri, 2003-02-21 at 16:10, Alfonso wrote:
> 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.
> 

This looks fine, nice work really.
Would you like to sent out a patch in stead of the code? :)
regards

Mike


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-02-22 20:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-21 22:10 reducing Elks code size Alfonso
2003-02-22 18:23 ` Alan Cox
2003-02-22 20:57 ` Miguel A. Bolanos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox