cortns.asm

来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 407 行 · 第 1/2 页

ASM
407
字号
        stfd    f21, 0x38(sp)           // ...
        stfd    f22, 0x40(sp)           // ...
        stfd    f23, 0x48(sp)           // ...
        stfd    f24, 0x50(sp)           // ...
        stfd    f25, 0x58(sp)           // ...
        stfd    f26, 0x60(sp)           // ...
        stfd    f27, 0x68(sp)           // ...
        stfd    f28, 0x70(sp)           // ...
        stfd    f29, 0x78(sp)           // ...
        stfd    f30, 0x80(sp)           // ...
        stfd    f31, 0x88(sp)           // ...

        stw     s0, 0x90(sp)            // push the gprs
        stw     s1, 0x94(sp)            // ...
        stw     s2, 0x98(sp)            // ...
        stw     s3, 0x9c(sp)            // ...
        stw     s4, 0xa0(sp)            // ...
        stw     s5, 0xa4(sp)            // ...
        stw     s6, 0xa8(sp)            // ...
        stw     s7, 0xac(sp)            // ...
        stw     s8, 0xb0(sp)            // ...
        stw     s9, 0xb4(sp)            // ...
        stw     s10, 0xb8(sp)           // ...
        stw     s11, 0xbc(sp)           // ...
        stw     s12, 0xc0(sp)           // ...
        stw     s13, 0xc4(sp)           // ...
        stw     s14, 0xc8(sp)           // ...
        stw     s15, 0xcc(sp)           // ...
        stw     s16, 0xd0(sp)           // ...
        stw     s17, 0xd4(sp)           // ...

        stw     rtoc, 0xd8(sp)          // save rtoc
        mflr    t0                      // save link register
        stw     t0, 0xdc(sp)            // ...
        mfcr    t0                      // save cr
        stw     t0, 0xe0(sp)            // ...

        stw     sp, 0x00(t1)            // save stack pointer of executing code
        lis     sp, h^__ASTACKPTR       // get start of new stack
        addi    sp, sp, l^__ASTACKPTR   // ...
        lwz     sp, 0x00(sp)            // ...

        subi    sp, sp, 0x38            // create false caller stack frame
        li      t0, 0                   // and nullify chain
        stw     t0, 0x00(sp)

        // switch to new stacklow
        stw     a0, 0x30(sp)            // save return value
        lis     t0, h^__SwitchStkLow    // Load address of stacklow switcher
        addi    t0, t0, l^__SwitchStkLow// ...
        lwz     t0, 0x00(t0)            // ...
        mtlr    t0                      // prepare to link
        blrl                            // switch stack lows
        lwz     a0, 0x30(sp)            // restore return value

        // a0 still contains the io routine address
        mtlr    a0
        blrl                            // start i/o operation

        lis     t1, h^SaveRegs          // prepare loading register
        addi    t1, t1, l^SaveRegs      // ..
        lwz     sp, 0x00(t1)            // return sp
        lwz     t0, 0x04(t1)            // return lr
        mtlr    t0                      // ...

        cmpi    0, a0, 0                // check if i/o error then do not update
        bne     no_update               // ...
          lfd   f14, 0x00(sp)           // Pop floats
          lfd   f15, 0x08(sp)           // ...
          lfd   f16, 0x10(sp)           // ...
          lfd   f17, 0x18(sp)           // ...
          lfd   f18, 0x20(sp)           // ...
          lfd   f19, 0x28(sp)           // ...
          lfd   f20, 0x30(sp)           // ...
          lfd   f21, 0x38(sp)           // ...
          lfd   f22, 0x40(sp)           // ...
          lfd   f23, 0x48(sp)           // ...
          lfd   f24, 0x50(sp)           // ...
          lfd   f25, 0x58(sp)           // ...
          lfd   f26, 0x60(sp)           // ...
          lfd   f27, 0x68(sp)           // ...
          lfd   f28, 0x70(sp)           // ...
          lfd   f29, 0x78(sp)           // ...
          lfd   f30, 0x80(sp)           // ...
          lfd   f31, 0x88(sp)           // ...

          lwz   s0, 0x90(sp)            // pop the gprs
          lwz   s1, 0x94(sp)            // ...
          lwz   s2, 0x98(sp)            // ...
          lwz   s3, 0x9c(sp)            // ...
          lwz   s4, 0xa0(sp)            // ...
          lwz   s5, 0xa4(sp)            // ...
          lwz   s6, 0xa8(sp)            // ...
          lwz   s7, 0xac(sp)            // ...
          lwz   s8, 0xb0(sp)            // ...
          lwz   s9, 0xb4(sp)            // ...
          lwz   s10, 0xb8(sp)           // ...
          lwz   s11, 0xbc(sp)           // ...
          lwz   s12, 0xc0(sp)           // ...
          lwz   s13, 0xc4(sp)           // ...
          lwz   s14, 0xc8(sp)           // ...
          lwz   s15, 0xcc(sp)           // ...
          lwz   s16, 0xd0(sp)           // ...
          lwz   s17, 0xd4(sp)           // ...

          lwz   rtoc, 0xd8(sp)          // load rtoc
          lwz   t0, 0xdc(sp)            // restore link register
          mtlr  t0                      // ...
          lwz   t0, 0xe0(sp)            // restore cr
          mtcrf 0xff, t0                // ...

no_update:                              // Do not restore from stack because
                                        // regs are same as initial call
        stw     a0, 0x34(sp)            // save result of io operation
        mflr    t0                      // save return address
        stw     t0, 0x30(sp)            // ...
        li      t0, 0                   // nulify callback chain
        stw     t0, 0x00(sp)            // ...

        lis     t0, h^__SwitchStkLow    // Load address of stacklow switcher
        addi    t0, t0, l^__SwitchStkLow// ...
        lwz     t0, 0x00(t0)            // ...
        mtlr    t0                      // prepare to link
        blrl                            // switch stack lows

        bl      j^__ReleaseIOSys        // release i/o system
        lwz     t0, 0x30(sp)            // restore return address
        mtlr    t0                      // ...
        lwz     a0, 0x34(sp)            // restore return value
        addi    sp, sp, FRAME_SIZE      // clear stack frame
        blr                             // return
// .end RdWrCommon


.globl  IOType
// .ent IOType                          // return to generated code
IOType:
        li      a0, 0                   // indicate operation succeeded
        b       j^SwitchToRT            // Use same routine as to switch in
// .end IOType


.globl  IOChar
// .ent IOChar
IOChar:
        lis     t1, h^IORslt            // load IORslt pointer
        addi    t1, t1, l^IORslt        // ...
        lwz     a1, 0x04(a0)            // Load SCB (its only 8 bytes :)
        lwz     a0, 0x00(a0)            // ...
        stw     a0, 0x00(t1)            // Store SCB in IORslt
        stw     a1, 0x04(t1)            // ...
        li      a0, PT_CHAR             // return CHARACTER*n type
        b       j^SwitchToRT            // return to caller of IOType()
// .end IOChar


.globl  IOStr
// .ent IOStr
IOStr:
        lis     t1, h^IORslt            // load IORslt pointer
        addi    t1, t1, l^IORslt        // ...
        stw     a0, 0x00(t1)            // Store SCB in IORslt
        stw     a1, 0x04(t1)            // ...
        li      a0, PT_CHAR             // return CHARACTER*n type
        b       j^SwitchToRT            // return to caller of IOType()
// .end IOStr


.globl  IOArr
// .ent IOArr                           // put array descriptor in IORslt
IOArr:
        lis     t1, h^IORslt            // load IORslt pointer
        addi    t1, t1, l^IORslt        // ...
        stw     a0, 0x00(t1)            // Store array record in IORslt (address)
        stw     a1, 0x04(t1)            // number of elements
        stw     a2, 0x0c(t1)            // type
        li      a0, PT_ARRAY            // return ARRAY type
        b       j^SwitchToRT            // return to caller of IOType()
// .end IOArr


.globl  IOChArr
// .ent IOChArr                         // put array descriptor in IORslt
IOChArr:
        lis     t1, h^IORslt            // load IORslt pointer
        addi    t1, t1, l^IORslt        // ...
        stw     a0, 0x00(t1)            // Store array record in IORslt (address)
        stw     a1, 0x04(t1)            // number of elements
        stw     a2, 0x08(t1)            // element size
        li      a1, PT_CHAR             // set type
        stw     a1, 0x0c(t1)            // ...
        li      a0, PT_ARRAY            // return ARRAY type
        b       j^SwitchToRT            // return to caller of IOType()
// .end IOChArr


.globl  __RT_EndIO
// .ent __RT_EndIO
__RT_EndIO:
        li      a0, PT_NOTYPE           // return "no i/o items remaining"
        b       j^SwitchToRT            // return to caller of IOType()
// .end __RT_EndIO

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?