23

雷军22年前写的代码 你见过吗?1530709226233644

 5 years ago
source link: http://www.cocoachina.com/programmer/20180704/24030.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

作为小米科技的创始人、董事长和首席执行官,雷军的名字如雷贯耳。网上出现一篇“刘强东的代码水平如何”的文章,有网友在下面回复“代码只服雷军”。这个回复吸引了小编的注意,雷军的代码水平真的很牛吗?

原来雷军年轻的时候,也是一名程序员,而且一干就是10年。雷军在22年前的作文中写道:我会当一辈子程序员,由此可以看出雷军对编程有着狂热的爱好。

还有网友分享了一篇雷军22年前写的代码,废话不多说,直接贴代码。

;
; RI.ASM  Revision 2.12         [ July 12, 1994 ]
Revision        equ     'V2.12 '
;
; **************************************************************************
; *                                                                        *
; *  RAMinit  Release 2.0                                                  *
; *  Copyright (c) 1989-1994 by Yellow Rose Software Co.                   *
; *  Written by Mr. Leijun                                                 *
; *                                                                        *
; *  Function:                                                             *
; *    Press HotKey to remove all TSR program after this program           *
; *                                                                        *
; **************************************************************************

; ..........................................................................
; Removed Softwares by RI:
;   SPDOS v6.0F, WPS v3.0F
;   Game Busters III, IV
;   NETX ( Novell 3.11 )
;   PC-CACHE
;   Norton Cache
;   Microsoft SmartDrv
;   SideKick 1.56A
;   MOUSE Driver
;   Crazy (Monochrome simulate CGA program)
;   RAMBIOS v2.0
;   386MAX Version 6.01
; ..........................................................................
; No cancel softwares:
;   Windows 3.1 MSD
;
; No removed TSR softwares:
;   MS-DOS fastopen
;   Buffers, Files ... (QEMM 6.0)
;   QCache (386MAX 6.01)
; ..........................................................................
;
COMMENT *

V2.04  Use mouse driver software reset function to initiation mouse
        2/17/1993 by  Mr. Lei and Mr. Feng
V2.05  RI cannot work in Windows DOS prompt
        3/9/1993  by Mr. Lei
V2.06  1. When XMS cannot allocate 1K memory, RI halts.
        2. RI repeat deallocates EMS memory.
V2.07  HotKey Setup Error
        4/25/1993 by Mr. Lei
V2.08  KB Buffer
V2.10  1. Release high memory blocks (EMM386 QEMM386 S-ICE 386MAX)
        2. RI copies flag
V2.12  1. Exists a critical error in Init 8259 procedure
        2. Save [40:F0--FF] user data area

*

                dosseg
                .model tiny
                .code
                locals  @@
                org     100h

Start:          jmp     Main
                org     103h

  True          equ     1
  False         equ     0
  MaxHandles    equ     100h

        INT3    macro
                out     0ffh,al
                endm
  ;
  ;             HotKey Status                             Test Var
  ;            ---------------                         ---------------
  ;
  ;  7 6 5 4 3 2 1 0                                    417  418  496
  ;  . . x . x . . .    Left Alt is pressed              8    2
  ;  x . . . x . . .    Right Alt is pressed             8         8
  ;  . . . x . x . .    Left Ctrl is pressed             4    1
  ;  . x . . . x . .    Right Ctrl is pressed            4         4
  ;  . . . . . . x .    Left Shift is pressed            2
  ;  . . . . . . . x    Right Shift is pressed           1
  ;
  LeftAlt       equ     00101000b
  RightAlt      equ     10001000b
  LeftCtrl      equ     00010100b
  RightCtrl     equ     01000100b
  LeftShift     equ     00000010b
  RightShift    equ     00000001b
  HotKey        db      LeftCtrl or RightCtrl

  DataBegin     dw      0
  NextDataSeg   dw      0ffffh
  oldInt2F_addr dw      0, 0
  XMS_control   dw      0, 0
  Handle_begin  dw      0
  cvtOfs        dw      0       ; DOS 3.0 equ 0 and above DOS 4.0 is 1
                org     104h
                db      0dh
                db      Revision
                db      ??date
                db      26
                org     114h
  tsrLength     dw      0
  MachineID     db      0FCh    ; IBM PC/AT

  AuxHotKey     db      0       ; 2Dh     ; 'X' Scan Code
  AuxHotKeyName db      'X$      '
  Power         db      True
  Flag          db      '!'
  Kbd102        db      0
  NoFlag        db      0
  StopFlag      db      1
  DosEnv        dw      0
  WorkSeg       dw      0
  PrevDataSeg   dw      0
  Copies        db      '1'
  old_8259      db      0       ; 21h port
                db      0       ; a1h port

  Status        dw      0
  XMSbit        equ     00000001b
  EMSbit        equ     00000010b
  SKbit         equ     10000000b

GoINT1C:        db      0eah
  oldInt1C_addr dw      0, 0
newINT1C:
                test    cs:Status, SKbit
                jnz     GoINT1C
                cmp     cs:StopFlag, 0
                jz      @@0
;
; Mr. Lei  2/8/1993
; Problem: if WPS quit and reenter, old RI cann't control keyboard.
;
                push    ds
                push    ax
                xor     ax, ax
                mov     ds, ax
                mov     ax, ds:[9*4]
                cmp     ax, offset NewInt9
                pop     ax
                pop     ds
                jnz     GoINT1C
                mov     cs:StopFlag, 0

        @@0:    push    ax
                push    ds
                push    es
                xor     ax, ax
                mov     ds, ax
                mov     es, ds:[9*4+2]
                cmp     word ptr es:[101h], 'IE'        ; 'LEI'
                jz      @@1
                cli
                mov     cs:StopFlag, 1
                mov     ax, ds:[9*4]
                mov     csldINT9_addr2, ax
                mov     ax, ds:[9*4+2]
                mov     csldINT9_addr2[2], ax
                mov     ds:[9*4], offset newINT9_2
                mov     ds:[9*4+2], cs
                sti
        @@1:    pop     es
                pop     ds
                pop     ax
                jmp     GoINT1C

; ----------------------------------------------------------------------
;  INT2F Func
;
;     AX = C0D7h   Return RI segment in AX
;     AX = C0D8h   Removes all TSR programs after RI
;     AX = C0D9h   Removes all TSR programs include RI
;     AX = C0DAh   Removes all RI copies
; ----------------------------------------------------------------------

newINT2F:
                cmp     ax, 0c0d7h      ; LEI Hanzi GB Code
                jnz     @@1
                push    cs
                pop     ax
                iret
        @@1:    cmp     ax, 0c0d7h+1
                jnz     @@2
                jmp     KeepSelf
        @@2:    cmp     ax, 0c0d7h+2
                jnz     @@3
                jmp     NoKeepSelf
        @@3:    cmp     ax, 0c0d7h+3
                jnz     @@9
                mov     cs:NextDataSeg, -1
                mov     cs:Copies, '1'
                jmp     NoKeepSelf
        @@9:    jmp     dword ptr csldInt2F_addr


CallInt9:
                ret


newINT9_2:
                mov     cs:NoFlag, 1
                pushf
                db      9ah             ; call far ptr oldint9_addr
  oldInt9_Addr2 dw      0, 0
                jmp     newINT9_proc

newINT9:
                pushf
                db      9ah             ; call far ptr oldint9_addr
  oldInt9_Addr  dw      0, 0
                cmp     cs:NoFlag, 0
                jz      newINT9_proc
                mov     cs:NoFlag, 0
                iret
newINT9_proc:
                cmp     cs:Flag, '!'    ; busy ?
                jnz     @@0
                iret
        @@0:
                mov     cs:Flag, '!'    ; set busy flag
                push    ax              ; cmp hot key
                push    bx
                push    es
                mov     ax,40h
                mov     es,ax

                cmp     cs:AuxHotKey, 0
                jz      @@_1
                mov     bx, es:[1ah]
                cmp     bx, es:[1ch]
                jz      @@10
                push    bx
                mov     bl, es:[bx+1]
                cmp     bl, cs:AuxHotKey
                pop     bx
                jnz     @@10
        @@_1:
                mov     ah,es:[17h]     ; test CTRL SHIFT ALT
                mov     al,cs:HotKey
                push    ax
                and     ax,0f0fh
                cmp     al,ah
                pop     ax
                jnz     @@10
                cmp     cs:Kbd102, True
                jnz     @@1
                shr     al, 1
                shr     al, 1
                shr     al, 1
                shr     al, 1
                push    ax
                mov     ah, es:[18h]
                and     ax, 303h
                cmp     al, ah
                pop     ax
                jnz     @@10
                mov     ah, es:[96h]
                shr     ax, 1
                shr     ax, 1
                and     ax, 303h
                cmp     al, ah
                jnz     @@10

                cmp     cs:AuxHotKey, 0
                jz      @@_3
                inc     bx
                inc     bx
                cmp     bx, 3eh
                jb      @@_2
                mov     bx, 1eh
        @@_2:
                mov     es:[1ah], bx
        @@_3:
                call    IsWinDos
                or      ax, ax
                jz      @@1
                call    Beep
        @@10:
                sti
                pop     es
                pop     bx
                pop     ax
                mov     cs:Flag, ' '    ; no busy
                iret
        @@1:                                            ; OK
                pop     es
                pop     bx
                pop     ax

KeepSelf:
                call    RemoveTSR
                push    es
                mov     es,cs:WorkSeg
                mov     dx,es:tsrLength
                mov     di,dx
                mov     al,0h           ; Aug 24, 1993
                mov     cx,100h
                rep     stosb
                pop     es
                int     27h

NoKeepSelf:
                mov     ax,0e07h
                int     10h
                mov     cs:clsStr, 47h  ; Color (White in Red)
                call    RemoveTSR
                dec     cs:Copies
                call    RestoreSelfIntVec
                push    es
                cmp     csrevDataSeg, 0
                jz      @@1
                mov     es, csrevDataSeg
                mov     es:NextDataSeg, -1
        @@1:    pop     es
                mov     ax, 4c00h
                int     21h

; ---------------------------------------------------------------------------

IsWinDOS:
                mov     ax, 1600h
                int     2fh
                cmp     al, 01h
                jz      @@9
                cmp     al, 0ffh
                jz      @@9                     ; Windows/386 Version 2.X
                cmp     al, 00h
                jz      @@1
                cmp     al, 80h
                jnz     @@9                     ; Windows 3 in enhanced mode
                                                ; Version number in AL/AH
        @@1:
                mov     ax, 4680h
                int     2fh
                cmp     al, 80h
                jnz     @@9
                xor     ax, ax
                jmp     @@10
        @@9:    mov     ax, 1
        @@10:   ret

; -----------------------------------------------------------------------
RestoreSelfIntVec:
                cmp     Copies, '0'
                jz      @@0
                ret
        @@0:
                cli
                push    cs
                pop     ds
                xor     ax, ax
                mov     es, ax
                mov     si, offset oldInt9_Addr
                mov     di, 9*4
                movsw
                movsw
                mov     si, offset oldInt2F_Addr
                mov     di, 2Fh*4
                movsw
                movsw
                mov     si, offset oldInt1C_Addr
                mov     di, 1Ch*4
                movsw
                movsw
                sti
                ret

; ------------- KERNEL PROGRAM ----------------------------------------------
RemoveTSR:
                pop     ax
                cli                     ; Set stack
                mov     sp, cs
                mov     ss, sp
                mov     sp, 100h
                sti
                push    ax

                cmp     csower, True
                jnz     @@1
                call    Init8259
        @@1:
                push    cs
                pop     ds
        @@_0:
                mov     ax,ds:NextDataSeg
                cmp     ax, -1
                jz      @@_1
                mov     csrevDataSeg, ds
                mov     ds, ax
                jmp     @@_0
        @@_1:   mov     si,dsataBegin
                mov     cs:WorkSeg, ds
                lodsw
                cmp     ax, 'XX'
                jz      @@_2
                call    Beep
                ret
        @@_2:
                call    RestoreEnvStr
                call    RestoreMCB         ; restore current mcb
                call    CloseFiles
                call    RestorePort
                call    RestoreLEDs
                call    RestoreVecList     ; Restore vectors list
                call    RestoreFloppyParam
                cmp     csower, True
                jnz     @@2
                call    RestoreCVTchain    ; Restore cvt chain
                call    RestoreMemoryManager
        @@2:
                call    RestoreBiosData
                call    Enable8259
                mov     ah, 1
                int     16h

                call    RestoreClockSpeed
                call    CloseSpeaker
                call    ResetDisk
                call    UpdateTime

                call    ClosePRN
                mov     bx,cs:WorkSeg
                mov     ah,50h
                int     21h                ; Set PSP segment
                mov     ax,3
                int     10h                ; Set display mode

                call    InitPRN
                call    InitMouse
                mov     al, cs:Copies
                cmp     al, '1'
                ja      @@_sh1
                mov     cs:ShowCopies, '*'
                jmp     @@_sh2
        @@_sh1: mov     cs:ShowCopies, al
        @@_sh2:
                mov     si, offset clsStr
                call    ColorPrintStr
                mov     cs:Flag, ' '       ; no busy
                cmp     Copies, '1'
                jnz     @@_end
                mov     cs:StopFlag, 0
        @@_end:
                call    ClearKB_buffer
                ret

Beep:
                mov     ax,0e07h
                int     10h
                ret

; #########################################################################

ClearKB_Buffer:
                push    es
                push    bx
                mov     bx, 0040h
                mov     es, bx
                cli
                mov     bx, es:[1ah]
                mov     es:[1ch], bx
                sti
                pop     bx
                pop     es
                ret


Init8259:
        ;       cmp     cs:Copies, '1'
        ;       jz      @@1
        ;       ret
        @@1:
                cmp     cs:MachineID, 0fch
                ja      @@pc_xt
        @@AT:
                mov     bx,870h         ;
                mov     al,0            ;
                out     0F1h,al         ;
                jcxz    $+2
                jcxz    $+2
                mov     al,11h          ; ICW1
                out     0A0h,al
                jcxz    $+2
                jcxz    $+2
                out     20h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,bl           ; ICW2
                out     0A1h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,bh
                out     21h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,2            ; ICW3
                out     0A1h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,4
                out     21h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,1            ; ICW4
                out     0A1h,al
                jcxz    $+2
                jcxz    $+2
                out     21h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,0FFh         ; OCW1
                out     0A1h,al
                jcxz    $+2
                jcxz    $+2
                out     21h,al
                ret
        @@PC_XT:
                mov     al,13h          ; ICW1
                out     20h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,8            ; ICW2
                out     21h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,9            ; ICW4
                out     21h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,0FFh         ; OCW1
                out     21h,al
                ret

Enable8259:
                mov     ax, word ptr csld_8259
                out     021h,al
                jcxz    $+2
                jcxz    $+2
                mov     al,ah
                out     0a1h,al         ; DEC PC Bus Mouse
                ret                     ; July 1994 by Mr. Lei

; -------------------------------------------------------------------------

RestoreBiosData:
                lodsw
                cmp     ax, '--'
                jz      @@1
                call    Beep
                ret
        @@1:    push    es
                push    di
                mov     di, 40h
                mov     es, di

                mov     di, 10h
                movsw
                mov     di, 0a8h         ; [40h:a8h]
                movsw
                movsw
                mov     di, 49h
                mov     cx, 1dh
                rep     movsb

                mov     di, 0f0h         ; User data
                mov     cx, 8
                rep     movsw

                pop     di
                pop     es
                ret

; -------------------------------------------------------------------------

RestoreMCB:
                push    ds
                push    es
                lodsw                           ; 'MZ'
        @@0:    lodsw
                cmp     ax, 'MM'
                jz      @@1
                mov     es,ax
                xor     di,di
                movsb
                movsw
                movsw
                inc     ax
                mov     bx, ds
                cmp     ax, bx
                jz      @@10
                mov     byte ptr es:[8], 0      ; Aug 24, 1993
        @@10:   cmp     byte ptr es:[0], 'Z'
                jnz     @@0
                mov     byte ptr es:[10h], 0
                jmp     @@0
        @@1:
                pop     es
                pop     ds
                ret

; -------------------------------------------------------------------------
CloseFiles:
                mov     ax, 5           ; Begin handle
                push    ds
                push    si
                mov     cx, 15          ; Max handle
                sub     cx, ax
                inc     cx
                mov     bx, ax
        @@1:    push    bx
                push    cx
                mov     ah, 3eh
                int     21h
                pop     cx
                pop     bx
                inc     bx
                loop    @@1
                pop     si
                pop     ds
                ret

; -------------------------------------------------------------------------
RestorePort:
                mov     di, 40h            ; restore port
                mov     es, di
                xor     di, di
                mov     cx, 8
                rep     movsw
                ret

; -------------------------------------------------------------------------
RestoreLEDs:
                lodsb
                and     al, 11110000b      ; LED status
                mov     ah, es:[17h]
                and     ah, 00001111b
                or      ah, al
                and     ah, 0f0h           ; Clear CTRL ALT SHIFT
                mov     es:[17h], ah
                ret

; -------------------------------------------------------------------------
RestoreEnvStr:
                lodsw
                push    si
                push    di
                push    ds
                push    es
                mov     es, csosEnv
                mov     ds, ax
                xor     si, si
                mov     di, si
        @@0:    lodsb
                or      al, al
                jnz     @@1
                cmp     byte ptr ds:[si], 0
                jz      @@2
        @@1:    stosb
                jmp     @@0
        @@2:    stosb
                stosb
                pop     es
                pop     ds
                pop     di
                pop     si
                ret

; -----------------------------------------------------------------------
RestoreVecList:
                xor     ax,ax
                mov     di,ax
                mov     es,ax
                mov     cx,100h
        @@0:    lodsw
                xchg    dx, ax
                lodsw
                cmp     dx, 'EL'
                jnz     @@1
                cmp     al, 'I'
                jnz     @@1
                sub     cl, ah
                push    cx
                mov     cl, ah
                mov     ax, es:[di-4]
                mov     dx, es:[di-2]
         @@a:   stosw
                xchg    ax, dx
                stosw
                xchg    ax, dx
                loop    @@a
                pop     cx
                or      cx, cx
                jz      @@9
                jmp     @@0
        @@1:
                xchg    ax, dx
                stosw
                xchg    ax, dx
                stosw
                loop    @@0
        @@9:
                ret

;----------------------------------------------------------------------------
RestoreFloppyParam:                                     ; Mr. Lei   2/10/1992
                push    es
                push    ax
                xor     ax, ax
                mov     es, ax
                mov     byte ptr es:[525h], 2
                pop     ax
                pop     es
                ret

;---------------------------------------------------------------------------
RestoreCVTchain:
                lodsw
                cmp     ax, 'VC'
                jz      @@_0
                call    Beep
                ret
        @@_0:
                push    ax
                push    cx
                push    es

        ; -----------------------------------------------------------------
                lodsw                   ; DPB
                mov     di, ax
                lodsw
                mov     es, ax
        @@1:    lodsb
                inc     di
                stosb
                add     di, cs:cvtOfs
                add     di, 10h
                movsw
                movsw
                les     di, es:[di+2]
                cmp     di, -1
                jnz     @@1

        ; -----------------------------------------------------------------
                lodsw                   ; DCB
                mov     di, ax
                lodsw
                mov     es, ax
                xor     ax, ax
                dec     ax
                stosw

        ; -----------------------------------------------------------------
                lodsw                   ; Device Driver Chain
                mov     di, ax
                lodsw
                mov     es, ax
                xor     cx, cx
        @@9:    push    di
                mov     cl, 5
                rep     movsw
                pop     di
                les     di, es:[di]
                mov     ax, di
                inc     ax
                jnz     @@9
                pop     es
                pop     cx
                pop     ax
                ret

; ----------------------------------------------------------------------------
RestoreMemoryManager:
                test    cs:Status, XMSbit
                jz      @@1
                call    LoadXMSstatus
        @@1:
                test    cs:Status, EMSbit
                jz      @@2
                call    LoadEMSstatus
        @@2:
                ret


LoadEMSstatus:
                lodsw
                cmp     ax, 'ME'
                jz      @@_0
                call    Beep
                ret
        @@_0:
                lodsw
                mov     cx, ax
                xor     dx, dx
        @@_1:   push    ds
                push    si
                push    dx
                push    cx

        @@0:    cmp     dx, ds:[si]
                jz      @@1
                add     si, 4
                loop    @@0

                push    cx
                mov     cx, 5
        @@__0:  mov     ah, 45h         ; Deallocate Handle and Memory
                int     67h
                or      ah, ah
                jz      @@__1
                loop    @@__0
        @@__1:  pop     cx

        @@1:
                pop     cx
                pop     dx
                pop     si
                pop     ds
                inc     dx
                cmp     dx, 100h
                jb      @@_1
                shl     cx, 1
                shl     cx, 1
                add     si, cx
                ret


LoadXMSstatus:
                lodsw
                cmp     ax, 'MX'
                jz      @@_0
                call    Beep
                ret
        @@_0:
                lodsw
                mov     cx, ax
                jcxz    @@5
        @@1:
                lodsw
                mov     dx, ax
        @@2:    push    dx
                mov     ah, 0ah                 ; free
                call    dword ptr cs:xms_control
                or      ax, ax
                pop     dx
                jnz     @@4
                cmp     bl, 0abh
                jnz     @@4
                push    dx
                mov     ah, 0dh                 ; unlock
                call    dword ptr cs:xms_control
                or      ax, ax
                pop     dx
                jmp     @@2
        @@4:    loop    @@1
        @@5:    ret
                endp

; -----------------------------------------------------------------------
CloseSpeaker:
                in      al, 61h
                and     al, 0fch
                out     61h, al
                ret

; -----------------------------------------------------------------------
RestoreClockSpeed:
                mov     al, 00110110b
                out     43h, al
                xor     ax, ax
                out     40h, al
                out     40h, al
                ret

; -----------------------------------------------------------------------
ResetDisk:
                xor     ax, ax
                xor     dx, dx
                int     13h             ; Restore A
                inc     dx
                int     13h             ; Restore B
                mov     dl, 80h
                int     13h             ; Restore C
                ret



; --------------------------------------------------------------------------
ClosePRN:
                mov     ah, 51h         ; Get PSP seg
                int     21h
                mov     es, bx
                mov     ax, es:[16h]    ; Prev PSP seg
                cmp     ax, bx
                jnz     @@9
                mov     ax, 3e00h       ; COMMAND
                mov     bx, 4
                int     21h
        @@9:
                ret

InitPRN:
                mov     ax, 3e00h
                mov     bx, 4           ; PRN
                int     21h
                mov     ax, 3d01h
                mov     dx, offset PRNname
                push    cs
                pop     ds
                int     21h
                ret
PRNname         db      'PRN',0

InitMouse:                              ; 2/16/1993 by Mr. Lei
                push    es
                xor     ax, ax
                mov     es, ax
                cmp     word ptr es:[33h*4+2], 0
                jz      @@0
                cmp     word ptr es:[33h*4], 0
                jz      @@0
                mov     ax, 21h
                int     33h             ; Hook Mouse Interrupt
        @@0:    pop     es
                ret

; ------------- CMOS CLOCK set to System -----------------------------------
UpdateTime:
                call    GetRealTime
                mov     ah, 2dh
                int     21h
                ret

GetRealTime:
                mov     ah,2
                int     1Ah
                mov     al,ch
                call    bcdxchg
                mov     ch,al
                mov     al,cl
                call    bcdxchg
                mov     cl,al
                mov     al,dh
                call    bcdxchg
                mov     dh,al
                mov     dl,0
                ret

BCDxchg:
                push    ax
                push    cx
                mov     cl,4
                shr     al,cl
                pop     cx
                mov     bl,0Ah
                mul     bl
                pop     bx
                and     bl,0Fh
                add     al,bl
                ret

; -----------------------------------------------------------------------
; Display string
ColorPrintStr:
                lodsb
                mov     bh, al          ; color
                xor     cx, cx
                mov     dx, 014fh
                mov     ax, 0600h
                int     10h

                mov     ah, 02          ; GotoXY (0, 0)
                xor     dx, dx
                mov     bh, 0
                int     10h
PrintStr:
                push    cs
                pop     ds
                xor     bx, bx
        @@1:    lodsb
                cmp     al, '$'
                jz      @@2
                or      al, al
                jz      @@2
                mov     ah, 0eh
                int     10h
                jmp     short @@1
        @@2:    mov     al, cs:clsStrcolor
                mov     cs:clsStr, al
                ret

; -----------------------------------------------------------------------
  Self          dw      0
  clsStrcolor   db      17h
  clsStr        db      17h             ; Color (White in Blue)
    db ' RAMinit  Version 2.12  (c) 1989-1994 by KingSoft Ltd.  Mr. Leijun'
    db 0dh,0ah
    db ' ['
  ShowCopies    db      '*'
    db '] Activate...',0ah,0dh,'$'

endTSR  equ     $
mcbList equ     offset endTSR + 2 + 2
vecList equ     mcbList + 7*10 + 2 + 10h + 1 + 400h
devLink equ     vecList + 4 + 5 * 26 + 4 + 10 * 30h + 4
xmsList equ     devLink + 2 + MaxHandles * 2
emsList equ     xmsList + 4 + 1024
crtMode equ     emsList + 2 + 1Dh + 4 + 10h
tsrLen  equ     crtMode + 1
;
; DOS Environment Reserved by RI
; --------------------------------------------------
;   Flag                        'XX'       2 bytes
;   Environment Segment                    1 word
;   Free MCBs                         <=7*10 bytes
;     MCB segment               1 word
;     MCB                       5 bytes
;   End flag                    'MM'       1 word
;   COM LPT ports                        10h bytes
;   LEDs status                            1 bytes
;   Packed vectors list               <=400h bytes
;   Flag                        'CV'       2 bytes
;   CVT First DPB pointer                  4 bytes
;       DPBs data                     <=5*26 bytes
;       First DCB pointer                  4 bytes
;       Pointer to NUL                     4 bytes
;       All device driver datas     <=30h*10 bytes
;   Flag                        'XM'       2 bytes
;   XMS free handle counter                2 bytes
;   EMS free handle list            <=100h*4 bytes
;   Flag                        'EM'       2 bytes
;   EMS free handle counter                2 bytes
;   EMS free handle list              <=1024 bytes
;       EMS handle              1 word
;       Number of pages         1 word
;   Flag                        '--'       1 word
;   Equipment List                         1 word
;   CRT 40:49h-66h                       1dh bytes
;       40:A8h                             1 dword
;   BIOS User Data Area  40:F0--FF       10h bytes
; ***************************************************************************
;
main:           jmp     main0

Print           Macro   Str
                Lea     dx, Str
                call    DisplayStr
                endm

InstMsg db  'RAMinit  Version 2.12 '
        db  'Copyright (c) 1989-1994  by KingSoft Ltd. ',0dh,0ah,'$'
Msg0    db  'Already installed !',0dh,0ah,0ah
        db  'For Help, type "RI /?". ',0dh,0ah,'$'
Msg_0   db  0ah,'Residents a new RAMinit copy [y/n] ? $'
Msg_2   db  'OK, RI No.'
Msg_RI  db  '2'
        db  ' residents successful !', 0dh,0ah,'$'
Msg1    db  'Activate with:  $'
KeyMsg  db  'Right_Shift$'
        db  'Left_Shift$ '
  KMsg1 db  'Left_Ctrl$  '
        db  'Left_Alt$   '
        db  'Right_Ctrl$ '
        db  'Right_Alt$  '
  KMsg2 db  'Ctrl$       '
        db  'Alt$        '
        db  'Ctrl$       '
        db  'Alt$        '
PlusMsg db  ' + $'
crlf    db  0dh,0ah,'$'

HelpMsg db  'Programmed by Mr. Leijun    Dec 1992', 0dh,0ah,0ah
        db  'Usage:   RI [options]',0dh,0ah,0ah
        db  '/H,/?    Display this screen',0dh,0ah
        db  '/CLS     Removes all TSR programs after current RI',0dh,0ah
        db  '/RET     Removes TSR programs include current RI',0dh,0ah
        db  '/NEW     Residents a new data copy of current environment',0dh,0ah
        db  '/ALL     Removes all RI copies and all other tsr programs',0dh,0ah
        db  '/Sxyy..  Define Hotkey   x=AuxHotkey   yy..=shift status',0dh,0ah
        db  '         x=auxiliary hotkey (default is "X" ',0dh,0ah
        db  '           x equ "1" means need AuxHotkey',0dh,0ah
        db  '         yy..=shift status  [CAScas]',0dh,0ah
        db  '           C: Left Ctrl    A: Left Alt    S: Left Shift',0dh,0ah
        db  '           c: Right Ctrl   a: Right Alt   s: Right Shift',0dh,0ah,0ah
        db  'Example: "RI /S1c"  means Hotkey is Right_Ctrl+X',0dh,0ah
        db  '         "RI /S0Cc" means HotKey is Left_Ctrl+Right_Ctrl',0dh,0ah
        db  '         "RI /CLS"  equals simply press hotkey',0dh,0ah
        db  '         "RI /RET"  Removes all TSRs after current RI and this RI',0dh,0ah
        db  0ah
        db  'Contact me for RAMinit problems: (01)2561155 Call 1997',0dh,0ah
        db  '$'
ErrMsg  db  'ERROR: Invalid options !',0dh,0ah,0ah,'$'
WinErr  db  7, 'Sorry, I cannot work in Windows DOS environment.',0dh,0ah,'$'
SetMsg  db  7, 'Defines new Hotkey successful !',0dh,0ah,0ah,'$'
tsrOK   db  False

Main0:
                cld
                Print   instMsg
                call    IsWinDos
                or      ax, ax
                jz      @@1
                Print   WinErr
                mov     ax, 4c00h
                int     21h
        @@1:
                call    HotKeyValid
                mov     cs:Status, 0
                call    EMS_test
                call    CmpDosVer
                call    CmpSideKick
                call    GetMachineID
                call    ModifyHotKeyPrompt

                mov     ax, 0c0d7h
                int     2fh
                mov     es, ax
                cmp     word ptr es:[101h], 'IE'        ; 'LEI'
                jnz     @@0
                mov     cs:Self, ax
        @@0:
                call    CmdLine
                call    PrintHotKeyPrompt

                cmp     cs:tsrOK, true
                jz      @@2
                call    tsrReplyOK
        @@2:    cmp     cs:tsrOK, true
                jnz     @@_2
                call    PrintCopies
        @@_2:
                mov     word ptr cs:[100h], 'EL'
                mov     byte ptr cs:[102h], 'I'

                push    cs
                pop     es
                push    cs
                pop     ds
                std
                mov     si, offset eof
                mov     cx, eof - offset Here
                mov     di, tsrLen
                add     di, cx
                inc     cx
                rep     movsb
                cld
                mov     bx, tsrLen
                jmp     bx

Here:
                mov     ax,cs
                mov     es,ax
                mov     di,offset endTSR
                mov     csataBegin, di
                mov     cs:NextDataSeg, -1
                mov     ax, 'XX'
                stosw
                in      al, 0a1h
                mov     ah, al
                in      al, 21h
                push    ax
                mov     word ptr csld_8259, ax
                xor     ax, ax
                out     21h,al                  ; CLI
                call    SaveOthers
                call    SetSelfInt
                call    BackupVecList
                cmp     cs:Power, true
                jnz     @@20
                call    BackupCVTchain
                call    BackupMemoryManager
        @@20:
                call    BackupBiosData

                sti
                mov     cs:Flag, ' '    ; no busy
                mov     cs:StopFlag, 0  ;

                mov     cs:tsrLength, di
                call    SetDosEnvSeg
                cmp     cs:Self, 0
                jz      @@29
                push    cs
                pop     ds
                push    cs
                pop     es
                cld
                mov     cx, cs:tsrLength
                mov     si, csataBegin
                sub     cx, si
                mov     di, 120h
                mov     csataBegin, di
                rep     movsb
                mov     cs:tsrLength, di
        @@29:
                pop     ax
                out     21h, al                         ; STI
                mov     al, ah
                out     0a1h, al
                mov     dx, cs:tsrLength
                inc     dx
                int     27h

; ----------------------------------------------------------------------------

电脑是雷军人生中的最爱,电脑 的世界对于雷军而言实在太美妙。雷军觉得,电脑的世界没有人那么复杂。只要你程序写得好,就可以和电脑处好关系,也可以指挥电脑,做一些你想做的事情。雷 军认为,电脑的世界很大,程序员都是活在自己的王国里。在这里,程序员可以主宰一切。正是因为热爱,所以雷军一干就是10年。

myQJJfE.jpg!web

对于雷军来说,虽然现在他更加 专注在产品开发以及管理方面,但是曾经他对心爱的代码视为珍宝。之前来了一位技术支持人员,而这位技术人员进公司的第一份工作,就是帮雷军整理他的硬盘。 一位理解错误,原本只要覆盖式的安装系统就可以的事情,这位程序员却把雷军的硬盘格式化了。这些代码是雷军多年来积累下来,而且也是他的最爱,就这样成为 炮灰,相信雷军非常难过。

编程是技术,也是一种艺术

雷军认为,编程的工作同石匠的工作相类似,即是技术活,也是体力活,而编写优秀的软件,算是一件比较难得事。编程是一门技术活,因此才有可能大规模的进行,进而才会有软件工程。此外,因为编程是一种艺术,因此有很多好的产品。

zAJfymZ.jpg!web

雷军关爱下属 亲自指导女程序员

因为自己是程序员出身,雷军在技术方面的水平不用质疑。雷军对于下面的程序员,也是很关照的。早前,雷军亲自指导美女程序员的一张图片爆红。从曝光的图片来看,这名由雷总亲自指导的女程序员,竟是位前端开发工程师。雷总下基层,还亲自指导码农,小米不强大都说不过去。

当然,上面的只是雷军生活中的一个小插曲。曾经,雷军认为自己会干一辈子的编程。但是现在,雷军作为小米董事长,身价已经不能用数字来衡量了。他接触程序的机会,相信是少之又少,因为下面有很多程序员帮他干活。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK