flat assembler
Message board for the users of flat assembler.

Index > Main > inline assembler

Author
Thread Post new topic Reply to topic
faris05



Joined: 07 Sep 2008
Posts: 2
faris05
Hi All,
I have the following macro. I need to make changes on hwint_master so that save is called inline. Any suggestions

Code:
#define hwint_master(irq)       \
call    save                    /* save interrupted process state */;\
push    (_irq_handlers+4*irq)   /* irq_handlers[irq]              */;\
call    _intr_handle            /* intr_handle(irq_handlers[irq]) */;\
pop     ecx                                                         ;\
cmp     (_irq_actids+4*irq), 0  /* interrupt still active?        */;\
jz      0f                                                          ;\
inb     INT_CTLMASK             /* get current mask */              ;\
orb     al, [1<<irq]            /* mask irq */                      ;\
outb    INT_CTLMASK             /* disable the irq                */;\
0:      movb    al, END_OF_INT                                              ;\
outb    INT_CTL                 /* reenable master 8259           */;\
ret      
    


The following is the code of save

Code:
        .align  16
 save:
         cld                     ! set direction flag to a known value
         pushad                  ! save "general" registers
   o16 push    ds              ! save ds
  o16 push    es              ! save es
  o16 push    fs              ! save fs
  o16 push    gs              ! save gs
         mov     dx, ss          ! ss is kernel data segment
         mov     ds, dx          ! load rest of kernel segments
         mov     es, dx          ! kernel does not use fs, gs
         mov     eax, esp        ! prepare to return
         incb    (_k_reenter)    ! from -1 if not reentering
         jnz     set_restart1    ! stack is already kernel stack
         mov     esp, k_stktop
         push    _restart        ! build return address for int handler
         xor     ebp, ebp        ! for stacktrace
         jmp     RETADR-P_STACKBASE(eax)
 
         .align  4
 set_restart1:
         push    restart1
         jmp     RETADR-P_STACKBASE(eax) 
    
Post 07 Sep 2008, 17:00
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Which assembler do you use? Heavily fixed/macroed FASM?
Post 10 Sep 2008, 23:16
View user's profile Send private message Reply with quote
faris05



Joined: 07 Sep 2008
Posts: 2
faris05
This is a part of the MINIX OS
Post 11 Sep 2008, 00:28
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
faris05,

You may just replace call save in hwint_master() macro with save function's body, but be aware of stack switch.

Isn't it from kernel/mpx386.s?
Post 19 Sep 2008, 18:35
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.