home *** CD-ROM | disk | FTP | other *** search
-
- /*
- ** Called as start(argc, argv, envp)
- */
-
- .text
- .globl start
- start:
- movl %esp,%ebx
- call mcount_init /* initialize the profiler */
- movl 8(%ebx),%eax
- pushl %eax
- movl %eax,_environ
- pushl 4(%ebx)
- pushl (%ebx)
- call ___main
- call _main
- addl $12,%esp
- pushl %eax
- call _exit
-
- exit_again:
- movl $0x4c00,%eax
- int $0x21
- jmp exit_again
-
- ret
-
-
- .globl __exit
- __exit:
- call mcount_write /* make sure we dump the output */
- exit_again2:
- movb 4(%esp),%al
- movb $0x4c,%ah
- int $0x21
- jmp exit_again2
-
- /* Here is where we initialize the timer interrupt - specific to go32 */
- /* In this case, the timer calls mcount_isr */
- .globl mcount_isr_init
- mcount_isr_init:
- movw $16,%ax
- movw %ax,%gs
-
- movl $960,%eax /* vector 0x78 * 8 bpv */
- movw %gs:(%eax),%cx
- movw %cx,mc_chain
- movw %gs:6(%eax),%cx
- movw %cx,mc_chain_hi
- movw %gs:2(%eax),%cx
- movw %cx,mc_chain_sel
-
- movl $mcount_isr,%ecx
- movw %cx,%gs:(%eax)
- movw $64,%gs:2(%eax) /* selector 8 == 32-bit code */
- movw $0x8f00,%gs:4(%eax)
- rorl $16,%ecx
- movw %cx,%gs:6(%eax)
- movw %ds,%ax
- movw %ax,%gs
- ret
-
- /* Obtain the PC where we interrupted, and bump the histogram. We should */
- /* do error checking here, but we don't. This routine is specific to go32 */
- /* in some spots */
- mcount_isr:
- pushl %eax
- cmpl $1,mcount_skip
- je L0
- movl 4(%esp),%eax /* get the PC */
- subl $0x1020,%eax /* to fit in low..high */
- andl $0xfffffffc,%eax
- shrl $1,%eax /* now points to one 4-byte entry */
- addl mcount_histogram,%eax
- incw (%eax)
- L0:
- popl %eax
- ljmp mc_chain /* chain to the next timer vector */
-
- .data
-
- .globl _environ
- _environ:
- .long 0
-
- mc_chain:
- .short 0
- mc_chain_hi:
- .short 0
- mc_chain_sel:
- .short 0
-
-