reducing Elks code size...
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---
Quoted 6 lines · Alfonso
This file:
elks/arch/i86/286pmode/irq.smay 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
Greetings,
Quoted 4 lines · Alfonso
This file:
elks/arch/i86/286pmode/irq.s
Quoted 10 lines
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 is0x00B6bytes instead of0x02EAbytes (I still wonder why the irq.s file was written in that weird mode). Thedo_excroutine in the fileelks/arch/i86/kernel/main.cdoes 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