百科问答小站 logo
百科问答小站 font logo



雷军写代码水平如何? 第1页

  

user avatar   nogirlnotalk 网友的相关建议: 
      

我记得好像是13年的时候?阿黎整了个小米网的讨论会。大意是各部门把过去一年里,自己觉得做的好的、和做的烂的,摆出来。

例如设计,梁师傅就整了个两个图,一好一坏对比批判一番。

到代码那块,我记得好像是海洲来讲。坏的就是整个小米网,因为他觉得小米网的代码他还是不满意,还是要一边开车一边修车。

好的,就是雷老大的一段代码,说是二十年前的。

那段代码就那么直接投影到大屏幕上,程序员弟兄们沉默一会,然后纷纷点头。

海洲发言,大意是:我不指望你们有这水平,但你们得朝这个方向努力啊!

事后我问一位程序员老铁:你们是拍马屁还是真服?我只会Hello world,看不懂。

这位后来也做了某上市公司CTO的未来大佬对我这个文科生不屑一顾:我没法和你解释。总之,雷老大写得很简练、很清晰、很干脆,这就是牛逼,而且是高层次的牛逼。

所以我觉得,应该是真牛逼。


user avatar   ren-min-you-dian-chu-ban-she-19 网友的相关建议: 
      

下面请欣赏雷总1994年写的代码片段——

这段用x86汇编写成的代码(以上是代码片段)用于清除内存驻留程序,类似内存加速工具,雷军教科书般规范地注明了代码用意、时间、作者……还细腻地用符号组成了分隔符让代码更加优雅,读起来清晰、舒适,所以雷总称之为诗一般的代码其实也不算过分。

在B站2020年6月份的一个访谈直播活动中,雷总也在给后辈的寄语中不断强调代码要整洁,逻辑要无懈可击,自己写的代码要达到例程(示范程序)的程度。这一点和《代码整洁之道》的作者Bob大叔英雄所见略同了。

Bob大叔就在《代码整洁之道》提出一种观点:代码质量与其整洁度成正比

优秀的系统往往有优秀的结构设计,层次清晰,职责单一,模块化,方便拓展和复用。功能的添加往往只是在现有的框架中添加少量代码。而且Bob大叔在《代码整洁之道》中给了我们一些行之有效的规则,涵盖从命名到重构的多个方面,只要遵循这些规则,就能编写出干净的、让人舒服的代码。

详见回答——

更多内容——

希望有一天,大家的代码都能“像诗一样优雅”!

========

赠人玫瑰,手留余香,不要忘记点赞、收藏、关注 @人民邮电出版社 哦~

一键三连,感恩有你~


user avatar   peter-25-24 网友的相关建议: 
      

下面是雷军的代码完整版,一共2000行,大家自己看看牛不牛!向雷布斯致敬!

       ; ; 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:[94] 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:[94+2] cmp word ptr es:[101h], 'IE' ; 'LEI' jz @@1 cli mov cs:StopFlag, 1 mov ax, ds:[94] mov cs:oldINT9_addr2, ax mov ax, ds:[94+2] mov cs:oldINT9_addr2[2], ax mov ds:[94], offset newINT9_2 mov ds:[94+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 cs:oldInt2F_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 cs:PrevDataSeg, 0 jz @@1 mov es, cs:PrevDataSeg 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, 94 movsw movsw mov si, offset oldInt2F_Addr mov di, 2Fh4 movsw movsw mov si, offset oldInt1C_Addr mov di, 1Ch4 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 cs:Power, True jnz @@1 call Init8259 @@1: push cs pop ds @@_0: mov ax,ds:NextDataSeg cmp ax, -1 jz @@_1 mov cs:PrevDataSeg, ds mov ds, ax jmp @@_0 @@_1: mov si,ds:DataBegin 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 cs:Power, 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 cs:old_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, cs:DosEnv 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:[33h4+2], 0 jz @@0 cmp word ptr es:[33h4], 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 + 710 + 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 <=710 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 <=526 bytes ; First DCB pointer 4 bytes ; Pointer to NUL 4 bytes ; All device driver datas <=30h10 bytes ; Flag 'XM' 2 bytes ; XMS free handle counter 2 bytes ; EMS free handle list <=100h4 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 cs:DataBegin, di mov cs:NextDataSeg, -1 mov ax, 'XX' stosw in al, 0a1h mov ah, al in al, 21h push ax mov word ptr cs:old_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, cs:DataBegin sub cx, si mov di, 120h mov cs:DataBegin, 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 ; ---------------------------------------------------------------------------- SetDosEnvSeg: push ds push es mov ax, cs @@10: mov es, ax mov ax, es:[16h] ; Get father process psp segment or ax, ax jz @@11 mov bx, es cmp ax, bx jnz @@10 @@11: mov es, word ptr es:[2ch] ; Get father process env segment mov cs:DosEnv, es pop es pop ds ret ; ---------------------------------------------------------------------------- SaveOthers: mov ax, cs:[2ch] ; Env Seg stosw call backupMCB ; Current MCB mov ax, 40h ; COM LPT Port mov ds, ax mov si, 0h mov cx, 8 rep movsw mov si, 17h ; LED status lodsb stosb ; call OpenLEDs ret ; -------------------------------------------------------------------------- backupMCB: mov ax, 'ZM' stosw push ds push es mov ah, 52h int 21h ; Get MCB chain head mov ax, es:[bx-2] pop es @@0: mov ds, ax cmp byte ptr ds:[0], 'Z' ; End ? jz @@20 cmp byte ptr ds:[0], 'M' ; Memory control block jnz @@30 cmp word ptr ds:[3], 0 ; Nul mcb jz @@10 cmp word ptr ds:[1], 0 ; Free MCB jnz @@10 call SaveFreeMCB @@10: inc ax add ax, ds:[3] jmp @@0 @@20: call SaveFreeMCB cmp ax, 0a000h inc ax jnb @@30 mov ax, 9fffh ; MS-DOS UMB jmp @@0 @@30: cmp ax, 0c000h ; 386MAX ja @@90 mov ax, 0c020h jmp @@0 @@90: ; Error ? pop ds mov ax, 'MM' ; Set MCB flag stosw ret SaveFreeMCB: stosw xor si,si movsb movsw movsw ret ; ; push ax ; stosw ; xor si,si ; movsb ; movsw ; movsw ; pop ax ; cmp ax, 09fffh ; jnb @@3 ; push ax ; push ds ; mov ds,ax ; cmp byte ptr ds:[0], 'M' ; pop ds ; pop ax ; jnz @@4 ; mov ax, 09fffh ; MS-DOS UMB ; jmp @@0 ; @@4: cmp ax, 0c000h ; ja @@3 ; mov ax, 0c020h ; 386MAX ; jmp @@0 ; ; -------------------------------------------------------------------------- OpenLEDs: push ax ; Open all LEDs or al, 070h mov ds:[17h], al mov ah, 1 int 16h mov cx, 4 ; Delay @@20: push cx xor cx, cx @@21: loop @@21 pop cx loop @@20 pop ax mov ds:[17h], al mov ah, 1 int 16h ret ; -------------------------------------------------------------------------- SetSelfInt: push es push di cmp cs:self, 0 jnz @@1 push cs pop ds mov ax,3509h int 21h mov word ptr cs:oldInt9_addr,bx mov word ptr cs:oldInt9_addr[2],es mov dx,offset NewInt9 mov ax,2509h int 21h mov ax,352Fh int 21h mov word ptr cs:oldInt2F_addr,bx mov word ptr cs:oldInt2F_addr[2],es mov dx,offset newInt2F mov ax,252Fh int 21h mov ax,351Ch int 21h mov word ptr cs:oldInt1C_addr,bx mov word ptr cs:oldInt1C_addr[2],es mov dx,offset newInt1C mov ax,251ch int 21h cli jmp @@2 @@1: mov es, cs:Self inc es:Copies @@_0: cmp es:NextDataSeg, -1 jz @@_1 mov es, es:NextDataSeg jmp @@_0 @@_1: mov es:NextDataSeg, cs @@2: pop di pop es ret ; ----------------------------------------------------------------------- SaveCounter: mov word ptr es:[di], 'EL' mov byte ptr es:[di+2], 'I' mov byte ptr es:[di+3], bl xor bx, bx add di, 4 ret ; ----------------------------------------------------------------------- DisplayStr: push cs pop ds mov ah, 9 int 21h ret ; ----------------------------------------------------------------------- CmdLine: push cs pop ds xor ax, ax mov si, 80h lodsb or al, al jnz @@1 ret @@1: mov cx, ax dec ax push ax push si @@0: lodsb cmp al, ' ' jz @@0 cmp al, '/' jnz @@2 lodsb cmp al, 'S' jz @@_2 cmp al, 's' jnz @@2 @@_2: call SetHotKey Print SetMsg mov ax, 4c00h int 21h @@2: pop si pop ax push ax push si @@_3: lodsb cmp al, 'A' jb @@3 cmp al, 'Z' ja @@3 add byte ptr ds:[si-1],20h ; DownCase @@3: loop @@_3 pop si pop cx add si, cx lodsb cmp al, 's' ; CLS jnz @@5 cmp word ptr ds:[si-3], 'lc' jnz @@5 cmp cs:Self, 0 jz @Err mov ax, 0c0d7h+1 int 2fh @@5: cmp al, 'h' ; HELP jz @help cmp al, '?' jz @help cmp al, 't' ; RET jnz @@6 cmp word ptr ds:[si-3], 'er' jnz @@6 @@7: cmp cs:Self, 0 jz @Err mov ax, 0c0d7h+2 int 2fh @@6: cmp al, 'w' ; NEW jnz @@8 cmp word ptr ds:[si-3], 'en' jnz @@8 mov cs:tsrOK, true ret @@8: cmp al, 'l' ; ALL jnz @@9 cmp word ptr ds:[si-3], 'la' jnz @@9 mov ax, 0c0d7h+3 int 2fh @@9: cmp al, ' ' jnz @Err ret @Err: Print ErrMsg @help: Print HelpMsg mov ax, 4c00h int 21h ;--------------------------------------------------------------------------- tsrReplyOK: cmp cs:Self, 0 jz @@1 Print Msg0 push es mov ax, cs:Self @@_10: mov es, ax mov ax, es:NextDataSeg cmp ax, -1 jnz @@_10 mov ax, es @@_0: push ax dec ax mov es, ax mov bx, es:[3] pop ax add ax, bx inc ax mov es, ax cmp word ptr es:[0], 'OC' jz @@_0 mov bx, cs cmp ax, bx pop es jz @@2 Print Msg_0 mov ah, 1 int 21h push ax Print crlf pop ax cmp al, 'y' jz @@3 cmp al, 'Y' jz @@3 @@2: ; Print Msg_1 mov ax, 4c01h int 21h @@3: @@1: mov cs:tsrOK, true ret PrintCopies: cmp cs:Self, 0 jz @@1 push es ; Added -by- Mr. Lei mov es, cs:Self ; Aug 24, 1993 mov al, es:Copies inc al ; Total RI copies push ax ; Set es = current mcb mov ax, cs dec ax mov es, ax pop ax mov cx, 5 ; Search end of file name mov bx, 8 @@10: inc bx cmp byte ptr es:[bx], 20h jz @@20 cmp byte ptr es:[bx], 0ffh jz @@20 cmp byte ptr es:[bx], 00h jz @@20 loop @@10 @@20: ; Set current RI no mov byte ptr es:[bx], ':' ; "RI:2" mov byte ptr es:[bx+1], al cmp bx, 8+7 jnb @@30 mov byte ptr es:[bx+2], 0 @@30: pop es mov cs:Msg_RI, al Print Msg_2 @@1: ret ;--------------------------------------------------------------------------- ; Backup Interrupt Vector List ; BackupVecList: push ds push cs pop es xor si,si ; Vectors mov ds,si movsw movsw xor bx, bx mov cx,00ffh @@0: lodsw xchg dx, ax lodsw cmp ax, es:[di-2] jnz @@1 cmp dx, es:[di-4] jz @@2 @@1: or bx, bx jz @@3 call SaveCounter @@3: xchg dx, ax stosw xchg dx, ax stosw loop @@0 jmp @@4 @@2: inc bx loop @@0 call SaveCounter @@4: pop ds ret ; ;----------------------------------------------------------------------------- BackupCVTchain: mov ax, 'VC' stosw push ax push bx push cx push ds push es mov ah, 52h int 21h ; ES:BX -- DOS table as described below ; -------------------------------------------------------------------- push es ; DPB chains push bx lds si, es:[bx] push cs pop es mov ax, si stosw mov ax, ds stosw mov bx, cs:cvtOfs xor cx, cx @@1: mov al, ds:[si+1] stosb mov ax, ds:[si+bx+12h] stosw mov ax, ds:[si+bx+14h] stosw inc cx lds si, ds:[si+bx+18h] cmp si, -1 jnz @@1 ; mov ax, 5 ; mul cl ; add ax, 4 ; add cs:tsrLength, ax pop bx pop es ; -------------------------------------------------------------------- push es ; DCB file control blocks push bx les bx, es:[bx+4] @@11: cmp word ptr es:[bx], -1 jz @@10 les bx, es:[bx] jmp @@11 @@10: mov ax, es xchg ax, bx push cs pop es stosw xchg ax, bx stosw pop bx pop es ; add cs:tsrLength, 4 ; --------------------------------------------------------------------- push es ; Device Driver Chains pop ds add bx, 22h mov si, bx ; NUL pop es mov ax, si stosw mov ax, ds stosw xor cx, cx xor bx, bx @@9: push si mov cl, 5 rep movsw inc bx pop si lds si, ds:[si] mov ax, si inc ax jnz @@9 pop ds pop cx pop bx pop ax ret ; ---------------------------------------------------------------------------- BackupBiosData: mov ax, '--' stosw push ds push si mov si, 40h mov ds, si mov si, 10h movsw mov si, 0a8h movsw movsw mov si, 49h mov cx, 1dh rep movsb mov si, 0f0h mov cx, 8 rep movsw pop si pop ds ret ; --------------------------------------------------------------------------- BackupMemoryManager: push cs pop es push ds push es call SaveXMSstatus call SaveEMSstatus pop es pop ds ret ;--------------------------------------------------------------------- SaveEMSstatus: test cs:status, EMSbit jnz @@1 ret @@1: mov ax, 'ME' stosw inc di inc di push di mov ah, 4dh int 67h pop di mov es:[di-2], bx shl bx, 1 shl bx, 1 add di, bx ret ; ------------------------------------------------------------------- SaveXMSstatus: call XMS_test test cs:status, XMSbit jnz @@1 ret @@1: mov ax, 'MX' stosw mov dx, 1 call XMS_alloc jnz @@_1 xor cx, cx ; XMS alloc failure stosw ret @@_1: push dx sub dx, MaxHandles  10 @@2: push dx call XMS_Lock pop dx jnz @@3 cmp bl, 0a2h jnz @@4 add dx, 10 jmp @@2 @@3: push dx call XMS_unlock pop dx @@4: mov cs:handle_begin, dx pop dx push dx call XMS_bstat xor cx, cx mov cl, bl inc cx pop dx call XMS_Free mov dx, cs:Handle_begin push cx push cs pop es mov ax, cx stosw @@5: push dx call XMS_Lock pop dx jnz @@6 cmp bl, 0a2h ; Handle invalid jz @@7 @@6: call XMS_unlock add dx, 10 jmp @@5 @@7: mov ax, dx stosw add dx, 10 loop @@5 pop cx ret ; ------------------------------------------------------------------ XMS_test: push es mov ax, 4300h int 2fh cmp al, 80h jnz @@9 mov ax, 4310h int 2fh mov cs:XMS_control, bx mov cs:XMS_control[2], es or cs:Status, XMSbit @@9: pop es ret XMS_stat: mov ah, 0 call dword ptr cs:xms_control mov hma_exist, dl ret hma_exist db 0 XMS_alloc: mov ah, 9 call dword ptr cs:xms_control or ax, ax ret XMS_lock: mov ah, 0ch call dword ptr cs:xms_control or ax, ax ret XMS_unlock: mov ah, 0dh call dword ptr cs:xms_control or ax, ax ret XMS_bstat: mov ah, 0eh call dword ptr cs:xms_control or ax, ax ret XMS_free: mov ah, 0ah call dword ptr cs:xms_control or ax, ax ret ; ---------------------------------------------------------------------------- EMS_test: push cs pop ds mov dx, offset EMMname mov ax, 3d00h int 21h jc @@2 mov bx, ax mov ah, 3eh int 21h or cs:Status, EMSbit @@2: ret EMMname db 'EMMXXXX0',0 ; ----------------------------------------------------------------------------- SetHotKey: xor bx, bx lodsb push ax @@1: lodsb cmp al, 0dh jz @@9 cmp al, 'C' jnz @@2 or bl, LeftCtrl jmp @@1 @@2: cmp al, 'c' jnz @@3 or bl, RightCtrl jmp @@1 @@3: cmp al, 'A' jnz @@4 or bl, LeftAlt jmp @@1 @@4: cmp al, 'a' jnz @@5 or bl, RightAlt jmp @@1 @@5: cmp al, 'S' jnz @@6 or bl, LeftShift jmp @@1 @@6: cmp al, 's' jnz @@7 or bl, RightShift jmp @@1 @@7: pop ax jmp @Err @@9: mov cs:HotKey, bl pop ax mov cs:AuxHotKey, 2dh ; 'X' scan key cmp al, '1' jz @@29 mov cs:AuxHotKey, 0 @@29: cmp cs:Self, 0 jz @@30 push es mov es, cs:Self mov es:HotKey, bl mov bl, cs:AuxHotKey mov es:AuxHotKey, bl pop es @@30: call GetRunFileName mov ax, 3d02h int 21h jc @@10 push cs pop ds mov bx, ax mov cx, 4 mov dx, 100h mov ah, 40h int 21h jc @@10 mov ax, 4200h xor cx, cx mov dx, 17h int 21h jc @@10 mov cx, 1 mov dx, offset AuxHotKey mov ah, 40h int 21h jc @@10 mov ah, 3eh int 21h @@10: ret ; ----------------------------------------------------------------------- GetRunFileName: ; Return: ; DS:DX Pointer of this run file name ASCIIZ string push ax push bx push cx push si push di push es push cs pop es mov ax, es:[2ch] mov es, ax xor di, di mov cx, 1000h xor al, al @@1: repnz scasb cmp es:[di], al loopnz @@1 mov dx, di add dx, 3 push es pop ds pop es pop di pop si pop cx pop bx pop ax ret ; --------------------------------------------------------------------------- GetMachineID: push es mov KBD102,True mov ax,40h mov es,ax test byte ptr es:[96h], 00010000b jnz @@1 mov Kbd102,False @@1: xor ax,ax dec ax mov es,ax mov al,es:[0eh] mov cs:MachineID, al pop es ret ; --------------------------------------------------------------------------- ModifyHotKeyPrompt: cmp cs:Kbd102, True jz @@9 push cs pop es push cs pop ds mov cx, 124 mov si, offset KMsg2 mov di, offset KMsg1 rep movsb @@9: cmp cs:MachineID, 0fch jna @@10 mov cs:clsStrcolor, 70h ; Mono mov cs:clsStr, 70h @@10: ret ; --------------------------------------------------------------------------- PrintHotKeyPrompt: Print Msg1 mov al, cs:HotKey mov ah, al shr al, 1 shr al, 1 and ax, 33ch or al, ah mov dx, offset KeyMsg @@40: or ax, ax ; Mr. Lei 4/25/1993 jz @@_42 shr al, 1 push ax jnc @@41 push ax call ColorDisplayStr ; mov ah, 9 ; int 21h pop ax or al, al jz @@42 push dx mov dx, offset PlusMsg call ColorDisplayStr ; Print PlusMsg pop dx @@41: add dx, 12 pop ax jmp @@40 @@42: pop ax @@_42: cmp cs:AuxHotKey, 0 jz @@43 cmp cs:HotKey, 0 ; Mr. Lei jz @@_43 mov dx, offset PlusMsg call ColorDisplayStr ; Print PlusMsg @@_43: mov dx, offset AuxHotKeyName call ColorDisplayStr ; Print AuxHotKeyName @@43: Print crlf ret ColorDisplayStr: push bx push cx push dx push si mov bl, 0fh mov si, dx xor bh, bh mov cx, 1 @@1: lodsb cmp al, '$' jz @@2 or al, al jz @@2 push cx mov ah, 09h int 10h mov ah, 3 int 10h inc dl mov ah, 2 int 10h pop cx jmp short @@1 @@2: pop si pop dx pop cx pop bx ret ; --------------------------------------------------------------------------- CmpSideKick: xor ax, ax mov es, ax les bx, es:[20h] cmp word ptr es:[bx-4], 4b53h jnz @@1 cmp word ptr es:[bx-2], 4942h jz @@2 @@1: mov es, ax les bx, es:[94h] cmp word ptr es:[bx-2], 4b53h jz @@2 ret @@2: or cs:Status, SKbit ret ; --------------------------------------------------------------------------- CmpDosVer: mov ah, 30h int 21h cmp al, 3 jb @@1 cmp al, 3 jna @@2 mov cs:cvtOfs, 1 ret @@2: mov cs:cvtOfs, 0 ret @@1: Print DosVerErr mov ax, 4cffh int 21h DosVerErr db 'Sorry, DOS version too lower !',0dh,0ah,'$' HotKeyValid: cmp cs:HotKey, 0 jnz @@_1 cmp cs:AuxHotKey, 0 jnz @@_1 Print HotKeyErr mov ax, 4cfeh int 21h @@_1: ret HotKeyErr db 'Sorry, please setup hotkey again. ',0dh,0ah,'$' eof: ends end Start ; ------------- The End ! ---------------------------------------------------     

最后,推荐一本阿里P8大佬撰写的算法笔记,刷完应该是超过雷军了

我是@袁吴范,一个教你如何提升认知、快速晋升的90后技术总监。


user avatar   yi-yang-91-9 网友的相关建议: 
      

雷军22年前写的汇编代码,大家看看牛不牛:

电脑和编程是雷军人生中最大的兴趣,关于电脑和编程,雷军是这么说的:

程序员活在自己想象的王国里!
我刚接触电脑就发现电脑的妙处,电脑远没有人那么复杂。
如果你的程序写得好,你就可以和电脑处好关系,就可以指挥电脑干你想干的事。
这个时候你是十足的主宰。
每每你坐在电脑面前,你就是在你的王国里巡行,这样的日子简直就是天堂般的日子。
电脑里的世界很大,编程人是活在自己想象的王国里。
你可以想象到电脑里细微到每一个字节、每一个比特的东西。
我爱编程这个工作,可以肯定我会干上一辈子

正是因为热爱,所以雷军一干就是10多年。

雷军认为编程是技术,也是一种艺术,程序员需要有类似艺术家对艺术一般的追求,才能真正打造出好的产品!

雷军的技术为什么这么牛逼?他在一次采访中说过一段话:我尤其喜欢阅读计算机经典书籍,那是一种如饥似渴的感觉!

另外我把大学和工作中用的经典电子书库(包含数据结构、操作系统、C++/C、网络经典、前端编程经典、Java相关、程序员认知、职场发展)、面试找工作的资料汇总都打包放在这了,这套资源可不是一般那种网上找的资源,是伴随我从学生一路成长为腾讯高级开发工程师,360技术经理、360技术总监、中小公司CTO的打包全套,非常宝贵!点击下方链接直达获取:

点击下方链接直接获取:

雷军20年前写过一篇文章:《我会当一辈子程序员》。

看完你会知道,编程在雷军的眼里是什么样子。

有的人学习编程技术,是把高级程序员做为追求的目标,甚至是终身的奋斗目标。
后来参与了真正的商品化软件开发后,反而困惑了,茫然了。
一个人只要有韧性和灵性,有机会接触并学习电脑的编程技术,就会成为一个不错的程序员。
刚开始写程序,这时候学得多的人写的好,到了后来,大家都上了一个层次。
谁写的好只取决于这个人是否细心、有韧性、有灵性。掌握多一点或少一点,很快就能补上。
成为一个高级程序员并不是件困难的事。
当我上学的时候,高级程序员也曾是我的目标,我希望我的技术能得到别人的承认。
后来发现无论多么高级的程序员都没用。
关键是你是否能够出想法出产品,你的劳动是否能被社会承认,能为社会创造财富。
成为高级程序员绝对不是追求的目标。
编程不仅仅是技术,还是艺术。
有人认为编程是一种熟练工种,也有人把编程说成是艺术创作。这两种意见争论比较激烈。
我们换个工种来看,石匠应该是熟练工种,属于工人,更和艺术似乎沾不上边。
但正是这些石匠,给我们留下多少文物古迹,如乐山大佛、莫高窟等等。
应该说这些石匠给我们留下了无穷的文化财产。
现代软件工业已具相当规模,很多软件的完成需要的是大兵团作战。
一名普通程序员接受编写某一模块的任务后,往往只是写代码,发挥的余地很小。
在大项目中,很多程序员只能了解到和自己所编模块相关的很局部的细节。
另外还受到开发环境的限制,真的很难体会到自己在从事”艺术”创造,更多的时候是感到自己在从事重体力劳动。
有的时候还担心自己苦苦参与的这个项目究竟有没有意义,是不是在同类产品中有竞争力,会不会开发出来以后就因为硬件的发展,操作系统的换代而过时……
我认为编程的工作和石匠比较相似,有技术活,更多的是体力活。
不管怎么说,写出一个好软件不是一件容易的事。
这两种想法都有片面性,编程应该说两种属性都有。
编程不仅仅是技术,也还是艺术。编程是技术活,才有可能大规模进行,才会有软件工程和软件工厂。
也正是编程是艺术,才会有如此多的好产品,让大家如痴如醉。

关于雷军的代码水平,他自己也说过:

另外,程序员多刷算法题好处多多,想要跟雷军一样长期在编程世界里遨游,先精通算法简直是必须的,算法厉害的人进大厂非常容易,再次推荐这本阿里P8大佬撰写的Leetcode刷题笔记,它帮助我身边不少朋友加入大厂:

祝大家前程似锦,在编码的道路上一马平川。

看看这本书的目录和排版!相当经典!

PS:感谢大家的阅读,觉得不错双击点赞下呀,这里也送大家一套我花1个月时间整理的超级硬核书单,总计200本书籍,希望对大家有用:

点个赞,一键三连呗,硬核码字不易。


user avatar   jiang-jiang-67-36 网友的相关建议: 
      

雷军的优秀是毋庸置疑的,在武汉大学,他两年学完计算机系四年的课程,大二就完成了毕业设计,汇编语言更是武大三十年以来仅有两个满分之一,大三就开始写加密软件、杀毒软件、财务软件、CAD软件等。至于老雷的代码水平,大家看看吧,

  1. ;
  2. ; RI.ASM Revision 2.12 [ July 12, 1994 ]
  3. Revision equ 'V2.12 '
  4. ;
  5. ;
  6. ;
  7. ; RAMinit Release 2.0
  8. ; Copyright (c) 1989-1994 by Yellow Rose Software Co.
  9. ; Written by Mr. Leijun
  10. ;
  11. ; Function:
  12. ; Press HotKey to remove all TSR program after this program
  13. ;
  14. ;

  15. ; ..........................................................................
  16. ; Removed Softwares by RI:
  17. ; SPDOS v6.0F, WPS v3.0F
  18. ; Game Busters III, IV
  19. ; NETX ( Novell 3.11 )
  20. ; PC-CACHE
  21. ; Norton Cache
  22. ; Microsoft SmartDrv
  23. ; SideKick 1.56A
  24. ; MOUSE Driver
  25. ; Crazy (Monochrome simulate CGA program)
  26. ; RAMBIOS v2.0
  27. ; 386MAX Version 6.01
  28. ; ..........................................................................
  29. ; No cancel softwares:
  30. ; Windows 3.1 MSD
  31. ;
  32. ; No removed TSR softwares:
  33. ; MS-DOS fastopen
  34. ; Buffers, Files ... (QEMM 6.0)
  35. ; QCache (386MAX 6.01)
  36. ; ..........................................................................
  37. ;
  38. COMMENT

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



  52. dosseg
  53. .model tiny
  54. .code
  55. locals @@
  56. org 100h

  57. Start: jmp Main
  58. org 103h

  59. True equ 1
  60. False equ 0
  61. MaxHandles equ 100h

  62. INT3 macro
  63. out 0ffh,al
  64. endm
  65. ;
  66. ; HotKey Status Test Var
  67. ; --------------- ---------------
  68. ;
  69. ; 7 6 5 4 3 2 1 0 417 418 496
  70. ; . . x . x . . . Left Alt is pressed 8 2
  71. ; x . . . x . . . Right Alt is pressed 8 8
  72. ; . . . x . x . . Left Ctrl is pressed 4 1
  73. ; . x . . . x . . Right Ctrl is pressed 4 4
  74. ; . . . . . . x . Left Shift is pressed 2
  75. ; . . . . . . . x Right Shift is pressed 1
  76. ;
  77. LeftAlt equ 00101000b
  78. RightAlt equ 10001000b
  79. LeftCtrl equ 00010100b
  80. RightCtrl equ 01000100b
  81. LeftShift equ 00000010b
  82. RightShift equ 00000001b
  83. HotKey db LeftCtrl or RightCtrl

  84. DataBegin dw 0
  85. NextDataSeg dw 0ffffh
  86. oldInt2F_addr dw 0, 0
  87. XMS_control dw 0, 0
  88. Handle_begin dw 0
  89. cvtOfs dw 0 ; DOS 3.0 equ 0 and above DOS 4.0 is 1
  90. org 104h
  91. db 0dh
  92. db Revision
  93. db ??date
  94. db 26
  95. org 114h
  96. tsrLength dw 0
  97. MachineID db 0FCh ; IBM PC/AT

  98. AuxHotKey db 0 ; 2Dh ; 'X' Scan Code
  99. AuxHotKeyName db 'X$ '
  100. Power db True
  101. Flag db '!'
  102. Kbd102 db 0
  103. NoFlag db 0
  104. StopFlag db 1
  105. DosEnv dw 0
  106. WorkSeg dw 0
  107. PrevDataSeg dw 0
  108. Copies db '1'
  109. old_8259 db 0 ; 21h port
  110. db 0 ; a1h port

  111. Status dw 0
  112. XMSbit equ 00000001b
  113. EMSbit equ 00000010b
  114. SKbit equ 10000000b

  115. GoINT1C: db 0eah
  116. oldInt1C_addr dw 0, 0
  117. newINT1C:
  118. test cs:Status, SKbit
  119. jnz GoINT1C
  120. cmp cs:StopFlag, 0
  121. jz @@0
  122. ;
  123. ; Mr. Lei 2/8/1993
  124. ; Problem: if WPS quit and reenter, old RI cann't control keyboard. ;
  125. push ds
  126. push ax
  127. xor ax, ax
  128. mov ds, ax
  129. mov ax, ds:[94]
  130. cmp ax, offset NewInt9
  131. pop ax
  132. pop ds
  133. jnz GoINT1C
  134. mov cs:StopFlag, 0

  135. @@0: push ax
  136. push ds
  137. push es
  138. xor ax, ax
  139. mov ds, ax
  140. mov es, ds:[94+2]
  141. cmp word ptr es:[101h], 'IE' ; 'LEI'
  142. jz @@1
  143. cli
  144. mov cs:StopFlag, 1
  145. mov ax, ds:[94]
  146. mov cs:oldINT9_addr2, ax
  147. mov ax, ds:[94+2]
  148. mov cs:oldINT9_addr2[2], ax
  149. mov ds:[94], offset newINT9_2
  150. mov ds:[94+2], cs
  151. sti
  152. @@1: pop es
  153. pop ds
  154. pop ax
  155. jmp GoINT1C

  156. ; ----------------------------------------------------------------------
  157. ; INT2F Func
  158. ;
  159. ; AX = C0D7h Return RI segment in AX
  160. ; AX = C0D8h Removes all TSR programs after RI
  161. ; AX = C0D9h Removes all TSR programs include RI
  162. ; AX = C0DAh Removes all RI copies
  163. ; ----------------------------------------------------------------------

  164. newINT2F:
  165. cmp ax, 0c0d7h ; LEI Hanzi GB Code
  166. jnz @@1
  167. push cs
  168. pop ax
  169. iret
  170. @@1: cmp ax, 0c0d7h+1
  171. jnz @@2
  172. jmp KeepSelf
  173. @@2: cmp ax, 0c0d7h+2
  174. jnz @@3
  175. jmp NoKeepSelf
  176. @@3: cmp ax, 0c0d7h+3
  177. jnz @@9
  178. mov cs:NextDataSeg, -1
  179. mov cs:Copies, '1'
  180. jmp NoKeepSelf
  181. @@9: jmp dword ptr cs:oldInt2F_addr


  182. CallInt9:
  183. ret


  184. newINT9_2:
  185. mov cs:NoFlag, 1
  186. pushf
  187. db 9ah ; call far ptr oldint9_addr
  188. oldInt9_Addr2 dw 0, 0
  189. jmp newINT9_proc

  190. newINT9:
  191. pushf
  192. db 9ah ; call far ptr oldint9_addr
  193. oldInt9_Addr dw 0, 0 cmp cs:NoFlag, 0
  194. jz newINT9_proc
  195. mov cs:NoFlag, 0
  196. iret
  197. newINT9_proc:
  198. cmp cs:Flag, '!' ; busy ?
  199. jnz @@0
  200. iret
  201. @@0:
  202. mov cs:Flag, '!' ; set busy flag
  203. push ax ; cmp hot key
  204. push bx
  205. push es
  206. mov ax,40h
  207. mov es,ax

  208. cmp cs:AuxHotKey, 0
  209. jz @@_1
  210. mov bx, es:[1ah]
  211. cmp bx, es:[1ch]
  212. jz @@10
  213. push bx
  214. mov bl, es:[bx+1]
  215. cmp bl, cs:AuxHotKey
  216. pop bx
  217. jnz @@10
  218. @@_1:
  219. mov ah,es:[17h] ; test CTRL SHIFT ALT
  220. mov al,cs:HotKey
  221. push ax
  222. and ax,0f0fh
  223. cmp al,ah
  224. pop ax
  225. jnz @@10 cmp cs:Kbd102, True
  226. jnz @@1
  227. shr al, 1
  228. shr al, 1
  229. shr al, 1
  230. shr al, 1
  231. push ax
  232. mov ah, es:[18h]
  233. and ax, 303h
  234. cmp al, ah
  235. pop ax
  236. jnz @@10
  237. mov ah, es:[96h]
  238. shr ax, 1
  239. shr ax, 1
  240. and ax, 303h
  241. cmp al, ah
  242. jnz @@10 cmp cs:AuxHotKey, 0
  243. jz @@_3
  244. inc bx
  245. inc bx
  246. cmp bx, 3eh
  247. jb @@_2
  248. mov bx, 1eh
  249. @@_2:
  250. mov es:[1ah], bx
  251. @@_3:
  252. call IsWinDos
  253. or ax, ax
  254. jz @@1
  255. call Beep
  256. @@10:
  257. sti
  258. pop es
  259. pop bx
  260. pop ax
  261. mov cs:Flag, ' ' ; no busy
  262. iret
  263. @@1: ; OK
  264. pop es
  265. pop bx
  266. pop ax

  267. KeepSelf:
  268. call RemoveTSR
  269. push es
  270. mov es,cs:WorkSeg
  271. mov dx,es:tsrLength
  272. mov di,dx
  273. mov al,0h ; Aug 24, 1993
  274. mov cx,100h
  275. rep stosb
  276. pop es
  277. int 27h

  278. NoKeepSelf:
  279. mov ax,0e07h
  280. int 10h
  281. mov cs:clsStr, 47h ; Color (White in Red)
  282. call RemoveTSR
  283. dec cs:Copies
  284. call RestoreSelfIntVec
  285. push es
  286. cmp cs:PrevDataSeg, 0
  287. jz @@1
  288. mov es, cs:PrevDataSeg
  289. mov es:NextDataSeg, -1
  290. @@1: pop es
  291. mov ax, 4c00h
  292. int 21h

  293. ; ---------------------------------------------------------------------------

  294. IsWinDOS:
  295. mov ax, 1600h
  296. int 2fh
  297. cmp al, 01h
  298. jz @@9 cmp al, 0ffh
  299. jz @@9 ; Windows/386 Version 2.X
  300. cmp al, 00h
  301. jz @@1 cmp al, 80h
  302. jnz @@9 ; Windows 3 in enhanced mode
  303. ; Version number in AL/AH
  304. @@1:
  305. mov ax, 4680h
  306. int 2fh
  307. cmp al, 80h
  308. jnz @@9
  309. xor ax, ax
  310. jmp @@10
  311. @@9: mov ax, 1
  312. @@10: ret

  313. ; -----------------------------------------------------------------------
  314. RestoreSelfIntVec:
  315. cmp Copies, '0'
  316. jz @@0
  317. ret
  318. @@0:
  319. cli
  320. push cs
  321. pop ds
  322. xor ax, ax
  323. mov es, ax
  324. mov si, offset oldInt9_Addr
  325. mov di, 94
  326. movsw
  327. movsw
  328. mov si, offset oldInt2F_Addr
  329. mov di, 2Fh4
  330. movsw
  331. movsw
  332. mov si, offset oldInt1C_Addr
  333. mov di, 1Ch4
  334. movsw
  335. movsw
  336. sti
  337. ret

  338. ; ------------- KERNEL PROGRAM ----------------------------------------------
  339. RemoveTSR:
  340. pop ax
  341. cli ; Set stack
  342. mov sp, cs
  343. mov ss, sp
  344. mov sp, 100h
  345. sti
  346. push ax

  347. cmp cs:Power, True
  348. jnz @@1
  349. call Init8259
  350. @@1:
  351. push cs
  352. pop ds
  353. @@_0:
  354. mov ax,ds:NextDataSeg
  355. cmp ax, -1
  356. jz @@_1
  357. mov cs:PrevDataSeg, ds
  358. mov ds, ax
  359. jmp @@_0
  360. @@_1: mov si,ds:DataBegin
  361. mov cs:WorkSeg, ds
  362. lodsw
  363. cmp ax, 'XX'
  364. jz @@_2
  365. call Beep
  366. ret
  367. @@_2:
  368. call RestoreEnvStr
  369. call RestoreMCB ; restore current mcb
  370. call CloseFiles
  371. call RestorePort
  372. call RestoreLEDs
  373. call RestoreVecList ; Restore vectors list
  374. call RestoreFloppyParam
  375. cmp cs:Power, True
  376. jnz @@2
  377. call RestoreCVTchain ; Restore cvt chain
  378. call RestoreMemoryManager
  379. @@2:
  380. call RestoreBiosData
  381. call Enable8259
  382. mov ah, 1 int 16h

  383. call RestoreClockSpeed
  384. call CloseSpeaker
  385. call ResetDisk
  386. call UpdateTime

  387. call ClosePRN
  388. mov bx,cs:WorkSeg
  389. mov ah,50h
  390. int 21h ; Set PSP segment
  391. mov ax,3 int 10h ; Set display mode

  392. call InitPRN
  393. call InitMouse
  394. mov al, cs:Copies
  395. cmp al, '1'
  396. ja @@_sh1
  397. mov cs:ShowCopies, ''
  398. jmp @@_sh2
  399. @@_sh1: mov cs:ShowCopies, al
  400. @@_sh2:
  401. mov si, offset clsStr
  402. call ColorPrintStr
  403. mov cs:Flag, ' ' ; no busy
  404. cmp Copies, '1'
  405. jnz @@_end
  406. mov cs:StopFlag, 0
  407. @@_end:
  408. call ClearKB_buffer
  409. ret

  410. Beep:
  411. mov ax,0e07h
  412. int 10h
  413. ret

  414. ; #########################################################################

  415. ClearKB_Buffer:
  416. push es
  417. push bx
  418. mov bx, 0040h
  419. mov es, bx
  420. cli
  421. mov bx, es:[1ah]
  422. mov es:[1ch], bx
  423. sti
  424. pop bx
  425. pop es
  426. ret


  427. Init8259:
  428. ; cmp cs:Copies, '1'
  429. ; jz @@1
  430. ; ret
  431. @@1:
  432. cmp cs:MachineID, 0fch
  433. ja @@pc_xt
  434. @@AT:
  435. mov bx,870h ;
  436. mov al,0 ;
  437. out 0F1h,al ;
  438. jcxz $+2
  439. jcxz $+2
  440. mov al,11h ; ICW1
  441. out 0A0h,al
  442. jcxz $+2
  443. jcxz $+2
  444. out 20h,al
  445. jcxz $+2
  446. jcxz $+2
  447. mov al,bl ; ICW2
  448. out 0A1h,al
  449. jcxz $+2
  450. jcxz $+2
  451. mov al,bh
  452. out 21h,al
  453. jcxz $+2
  454. jcxz $+2
  455. mov al,2 ; ICW3
  456. out 0A1h,al
  457. jcxz $+2
  458. jcxz $+2
  459. mov al,4
  460. out 21h,al
  461. jcxz $+2
  462. jcxz $+2
  463. mov al,1 ; ICW4
  464. out 0A1h,al
  465. jcxz $+2
  466. jcxz $+2
  467. out 21h,al
  468. jcxz $+2
  469. jcxz $+2
  470. mov al,0FFh ; OCW1
  471. out 0A1h,al
  472. jcxz $+2
  473. jcxz $+2
  474. out 21h,al
  475. ret
  476. @@PC_XT:
  477. mov al,13h ; ICW1
  478. out 20h,al
  479. jcxz $+2
  480. jcxz $+2
  481. mov al,8 ; ICW2
  482. out 21h,al
  483. jcxz $+2
  484. jcxz $+2
  485. mov al,9 ; ICW4
  486. out 21h,al
  487. jcxz $+2
  488. jcxz $+2
  489. mov al,0FFh ; OCW1
  490. out 21h,al
  491. ret

  492. Enable8259:
  493. mov ax, word ptr cs:old_8259
  494. out 021h,al
  495. jcxz $+2
  496. jcxz $+2
  497. mov al,ah
  498. out 0a1h,al ; DEC PC Bus Mouse
  499. ret ; July 1994 by Mr. Lei

  500. ; -------------------------------------------------------------------------

  501. RestoreBiosData:
  502. lodsw
  503. cmp ax, '--'
  504. jz @@1
  505. call Beep
  506. ret
  507. @@1: push es
  508. push di
  509. mov di, 40h
  510. mov es, di

  511. mov di, 10h
  512. movsw
  513. mov di, 0a8h ; [40h:a8h]
  514. movsw
  515. movsw
  516. mov di, 49h
  517. mov cx, 1dh
  518. rep movsb

  519. mov di, 0f0h ; User data
  520. mov cx, 8
  521. rep movsw

  522. pop di
  523. pop es
  524. ret

  525. ; -------------------------------------------------------------------------

  526. RestoreMCB:
  527. push ds
  528. push es
  529. lodsw ; 'MZ'
  530. @@0: lodsw
  531. cmp ax, 'MM'
  532. jz @@1
  533. mov es,ax
  534. xor di,di
  535. movsb
  536. movsw
  537. movsw
  538. inc ax
  539. mov bx, ds
  540. cmp ax, bx
  541. jz @@10
  542. mov byte ptr es:[8], 0 ; Aug 24, 1993
  543. @@10: cmp byte ptr es:[0], 'Z'
  544. jnz @@0
  545. mov byte ptr es:[10h], 0
  546. jmp @@0
  547. @@1:
  548. pop es
  549. pop ds
  550. ret

  551. ; -------------------------------------------------------------------------
  552. CloseFiles:
  553. mov ax, 5 ; Begin handle
  554. push ds
  555. push si
  556. mov cx, 15 ; Max handle
  557. sub cx, ax
  558. inc cx
  559. mov bx, ax
  560. @@1: push bx
  561. push cx
  562. mov ah, 3eh
  563. int 21h
  564. pop cx
  565. pop bx
  566. inc bx
  567. loop @@1
  568. pop si
  569. pop ds
  570. ret

  571. ; -------------------------------------------------------------------------
  572. RestorePort:
  573. mov di, 40h ; restore port
  574. mov es, di
  575. xor di, di
  576. mov cx, 8
  577. rep movsw
  578. ret

  579. ; -------------------------------------------------------------------------
  580. RestoreLEDs:
  581. lodsb
  582. and al, 11110000b ; LED status
  583. mov ah, es:[17h]
  584. and ah, 00001111b
  585. or ah, al
  586. and ah, 0f0h ; Clear CTRL ALT SHIFT
  587. mov es:[17h], ah
  588. ret

  589. ; -------------------------------------------------------------------------
  590. RestoreEnvStr:
  591. lodsw
  592. push si
  593. push di
  594. push ds
  595. push es
  596. mov es, cs:DosEnv
  597. mov ds, ax
  598. xor si, si
  599. mov di, si
  600. @@0: lodsb
  601. or al, al
  602. jnz @@1 cmp byte ptr ds:[si], 0
  603. jz @@2
  604. @@1: stosb
  605. jmp @@0
  606. @@2: stosb
  607. stosb
  608. pop es
  609. pop ds
  610. pop di
  611. pop si
  612. ret

  613. ; -----------------------------------------------------------------------
  614. RestoreVecList:
  615. xor ax,ax
  616. mov di,ax
  617. mov es,ax
  618. mov cx,100h
  619. @@0: lodsw
  620. xchg dx, ax
  621. lodsw
  622. cmp dx, 'EL'
  623. jnz @@1 cmp al, 'I'
  624. jnz @@1
  625. sub cl, ah
  626. push cx
  627. mov cl, ah
  628. mov ax, es:[di-4]
  629. mov dx, es:[di-2]
  630. @@a: stosw
  631. xchg ax, dx
  632. stosw
  633. xchg ax, dx
  634. loop @@a
  635. pop cx
  636. or cx, cx
  637. jz @@9
  638. jmp @@0
  639. @@1:
  640. xchg ax, dx
  641. stosw
  642. xchg ax, dx
  643. stosw
  644. loop @@0
  645. @@9:
  646. ret

  647. ;----------------------------------------------------------------------------
  648. RestoreFloppyParam: ; Mr. Lei 2/10/1992
  649. push es
  650. push ax
  651. xor ax, ax
  652. mov es, ax
  653. mov byte ptr es:[525h], 2
  654. pop ax
  655. pop es
  656. ret

  657. ;---------------------------------------------------------------------------
  658. RestoreCVTchain:
  659. lodsw
  660. cmp ax, 'VC'
  661. jz @@_0
  662. call Beep
  663. ret
  664. @@_0:
  665. push ax
  666. push cx
  667. push es

  668. ; -----------------------------------------------------------------
  669. lodsw ; DPB
  670. mov di, ax
  671. lodsw
  672. mov es, ax
  673. @@1: lodsb
  674. inc di
  675. stosb
  676. add di, cs:cvtOfs
  677. add di, 10h
  678. movsw
  679. movsw
  680. les di, es:[di+2]
  681. cmp di, -1
  682. jnz @@1

  683. ; -----------------------------------------------------------------
  684. lodsw ; DCB
  685. mov di, ax
  686. lodsw
  687. mov es, ax
  688. xor ax, ax
  689. dec ax
  690. stosw

  691. ; -----------------------------------------------------------------
  692. lodsw ; Device Driver Chain
  693. mov di, ax
  694. lodsw
  695. mov es, ax
  696. xor cx, cx
  697. @@9: push di
  698. mov cl, 5
  699. rep movsw
  700. pop di
  701. les di, es:[di]
  702. mov ax, di
  703. inc ax
  704. jnz @@9
  705. pop es
  706. pop cx
  707. pop ax
  708. ret

  709. ; ----------------------------------------------------------------------------
  710. RestoreMemoryManager:
  711. test cs:Status, XMSbit
  712. jz @@1
  713. call LoadXMSstatus
  714. @@1:
  715. test cs:Status, EMSbit
  716. jz @@2
  717. call LoadEMSstatus
  718. @@2:
  719. ret


  720. LoadEMSstatus:
  721. lodsw
  722. cmp ax, 'ME'
  723. jz @@_0
  724. call Beep
  725. ret
  726. @@_0:
  727. lodsw
  728. mov cx, ax
  729. xor dx, dx
  730. @@_1: push ds
  731. push si
  732. push dx
  733. push cx

  734. @@0: cmp dx, ds:[si]
  735. jz @@1
  736. add si, 4
  737. loop @@0

  738. push cx
  739. mov cx, 5
  740. @@0: mov ah, 45h ; Deallocate Handle and Memory
  741. int 67h
  742. or ah, ah
  743. jz @@1
  744. loop @@0
  745. @@1: pop cx

  746. @@1:
  747. pop cx
  748. pop dx
  749. pop si
  750. pop ds
  751. inc dx
  752. cmp dx, 100h
  753. jb @@_1
  754. shl cx, 1
  755. shl cx, 1
  756. add si, cx
  757. ret


  758. LoadXMSstatus:
  759. lodsw
  760. cmp ax, 'MX'
  761. jz @@_0
  762. call Beep
  763. ret
  764. @@_0:
  765. lodsw
  766. mov cx, ax
  767. jcxz @@5
  768. @@1:
  769. lodsw
  770. mov dx, ax
  771. @@2: push dx
  772. mov ah, 0ah ; free
  773. call dword ptr cs:xms_control
  774. or ax, ax
  775. pop dx
  776. jnz @@4 cmp bl, 0abh
  777. jnz @@4
  778. push dx
  779. mov ah, 0dh ; unlock
  780. call dword ptr cs:xms_control
  781. or ax, ax
  782. pop dx
  783. jmp @@2
  784. @@4: loop @@1
  785. @@5: ret
  786. endp

  787. ; -----------------------------------------------------------------------
  788. CloseSpeaker:
  789. in al, 61h
  790. and al, 0fch
  791. out 61h, al
  792. ret

  793. ; -----------------------------------------------------------------------
  794. RestoreClockSpeed:
  795. mov al, 00110110b
  796. out 43h, al
  797. xor ax, ax
  798. out 40h, al
  799. out 40h, al
  800. ret

  801. ; -----------------------------------------------------------------------
  802. ResetDisk:
  803. xor ax, ax
  804. xor dx, dx
  805. int 13h ; Restore A
  806. inc dx
  807. int 13h ; Restore B
  808. mov dl, 80h
  809. int 13h ; Restore C
  810. ret



  811. ; --------------------------------------------------------------------------
  812. ClosePRN:
  813. mov ah, 51h ; Get PSP seg
  814. int 21h
  815. mov es, bx
  816. mov ax, es:[16h] ; Prev PSP seg
  817. cmp ax, bx
  818. jnz @@9
  819. mov ax, 3e00h ; COMMAND
  820. mov bx, 4 int 21h
  821. @@9:
  822. ret

  823. InitPRN:
  824. mov ax, 3e00h
  825. mov bx, 4 ; PRN
  826. int 21h
  827. mov ax, 3d01h
  828. mov dx, offset PRNname
  829. push cs
  830. pop ds
  831. int 21h
  832. ret
  833. PRNname db 'PRN',0

  834. InitMouse: ; 2/16/1993 by Mr. Lei
  835. push es
  836. xor ax, ax
  837. mov es, ax
  838. cmp word ptr es:[33h4+2], 0
  839. jz @@0 cmp word ptr es:[33h4], 0
  840. jz @@0
  841. mov ax, 21h
  842. int 33h ; Hook Mouse Interrupt
  843. @@0: pop es
  844. ret

  845. ; ------------- CMOS CLOCK set to System -----------------------------------
  846. UpdateTime:
  847. call GetRealTime
  848. mov ah, 2dh
  849. int 21h
  850. ret

  851. GetRealTime:
  852. mov ah,2 int 1Ah
  853. mov al,ch
  854. call bcdxchg
  855. mov ch,al
  856. mov al,cl
  857. call bcdxchg
  858. mov cl,al
  859. mov al,dh
  860. call bcdxchg
  861. mov dh,al
  862. mov dl,0
  863. ret

  864. BCDxchg:
  865. push ax
  866. push cx
  867. mov cl,4
  868. shr al,cl
  869. pop cx
  870. mov bl,0Ah
  871. mul bl
  872. pop bx
  873. and bl,0Fh
  874. add al,bl
  875. ret

  876. ; -----------------------------------------------------------------------
  877. ; Display string
  878. ColorPrintStr:
  879. lodsb
  880. mov bh, al ; color
  881. xor cx, cx
  882. mov dx, 014fh
  883. mov ax, 0600h
  884. int 10h

  885. mov ah, 02 ; GotoXY (0, 0)
  886. xor dx, dx
  887. mov bh, 0 int 10h
  888. PrintStr:
  889. push cs
  890. pop ds
  891. xor bx, bx
  892. @@1: lodsb
  893. cmp al, '$'
  894. jz @@2
  895. or al, al
  896. jz @@2
  897. mov ah, 0eh
  898. int 10h
  899. jmp short @@1
  900. @@2: mov al, cs:clsStrcolor
  901. mov cs:clsStr, al
  902. ret

  903. ; -----------------------------------------------------------------------
  904. Self dw 0
  905. clsStrcolor db 17h
  906. clsStr db 17h ; Color (White in Blue)
  907. db ' RAMinit Version 2.12 (c) 1989-1994 by KingSoft Ltd. Mr. Leijun'
  908. db 0dh,0ah
  909. db ' ['
  910. ShowCopies db ''
  911. db '] Activate...',0ah,0dh,'$'

  912. endTSR equ $
  913. mcbList equ offset endTSR + 2 + 2
  914. vecList equ mcbList + 710 + 2 + 10h + 1 + 400h
  915. devLink equ vecList + 4 + 5 26 + 4 + 10 30h + 4
  916. xmsList equ devLink + 2 + MaxHandles 2
  917. emsList equ xmsList + 4 + 1024
  918. crtMode equ emsList + 2 + 1Dh + 4 + 10h
  919. tsrLen equ crtMode + 1
  920. ;
  921. ; DOS Environment Reserved by RI
  922. ; --------------------------------------------------
  923. ; Flag 'XX' 2 bytes
  924. ; Environment Segment 1 word
  925. ; Free MCBs <=710 bytes
  926. ; MCB segment 1 word
  927. ; MCB 5 bytes
  928. ; End flag 'MM' 1 word
  929. ; COM LPT ports 10h bytes
  930. ; LEDs status 1 bytes
  931. ; Packed vectors list <=400h bytes
  932. ; Flag 'CV' 2 bytes
  933. ; CVT First DPB pointer 4 bytes
  934. ; DPBs data <=526 bytes
  935. ; First DCB pointer 4 bytes
  936. ; Pointer to NUL 4 bytes
  937. ; All device driver datas <=30h10 bytes
  938. ; Flag 'XM' 2 bytes
  939. ; XMS free handle counter 2 bytes
  940. ; EMS free handle list <=100h4 bytes
  941. ; Flag 'EM' 2 bytes
  942. ; EMS free handle counter 2 bytes
  943. ; EMS free handle list <=1024 bytes
  944. ; EMS handle 1 word
  945. ; Number of pages 1 word
  946. ; Flag '--' 1 word
  947. ; Equipment List 1 word
  948. ; CRT 40:49h-66h 1dh bytes
  949. ; 40:A8h 1 dword
  950. ; BIOS User Data Area 40:F0--FF 10h bytes
  951. ; **
  952. ;
  953. main: jmp main0

  954. Print Macro Str
  955. Lea dx, Str
  956. call DisplayStr
  957. endm

  958. InstMsg db 'RAMinit Version 2.12 '
  959. db 'Copyright (c) 1989-1994 by KingSoft Ltd. ',0dh,0ah,'$'
  960. Msg0 db 'Already installed !',0dh,0ah,0ah
  961. db 'For Help, type "RI /?". ',0dh,0ah,'$'
  962. Msg_0 db 0ah,'Residents a new RAMinit copy [y/n] ? $'
  963. Msg_2 db 'OK, RI No.'
  964. Msg_RI db '2'
  965. db ' residents successful !', 0dh,0ah,'$'
  966. Msg1 db 'Activate with: $'
  967. KeyMsg db 'Right_Shift$'
  968. db 'Left_Shift$ '
  969. KMsg1 db 'Left_Ctrl$ '
  970. db 'Left_Alt$ '
  971. db 'Right_Ctrl$ '
  972. db 'Right_Alt$ '
  973. KMsg2 db 'Ctrl$ '
  974. db 'Alt$ '
  975. db 'Ctrl$ '
  976. db 'Alt$ '
  977. PlusMsg db ' + $'
  978. crlf db 0dh,0ah,'$'

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

  1003. Main0:
  1004. cld
  1005. Print instMsg
  1006. call IsWinDos
  1007. or ax, ax
  1008. jz @@1
  1009. Print WinErr
  1010. mov ax, 4c00h
  1011. int 21h
  1012. @@1:
  1013. call HotKeyValid
  1014. mov cs:Status, 0
  1015. call EMS_test
  1016. call CmpDosVer
  1017. call CmpSideKick
  1018. call GetMachineID
  1019. call ModifyHotKeyPrompt

  1020. mov ax, 0c0d7h
  1021. int 2fh
  1022. mov es, ax
  1023. cmp word ptr es:[101h], 'IE' ; 'LEI'
  1024. jnz @@0
  1025. mov cs:Self, ax
  1026. @@0:
  1027. call CmdLine
  1028. call PrintHotKeyPrompt

  1029. cmp cs:tsrOK, true
  1030. jz @@2
  1031. call tsrReplyOK
  1032. @@2: cmp cs:tsrOK, true
  1033. jnz @@_2
  1034. call PrintCopies
  1035. @@_2:
  1036. mov word ptr cs:[100h], 'EL'
  1037. mov byte ptr cs:[102h], 'I'

  1038. push cs
  1039. pop es
  1040. push cs
  1041. pop ds
  1042. std
  1043. mov si, offset eof
  1044. mov cx, eof - offset Here
  1045. mov di, tsrLen
  1046. add di, cx
  1047. inc cx
  1048. rep movsb
  1049. cld
  1050. mov bx, tsrLen
  1051. jmp bx

  1052. Here:
  1053. mov ax,cs
  1054. mov es,ax
  1055. mov di,offset endTSR
  1056. mov cs:DataBegin, di
  1057. mov cs:NextDataSeg, -1
  1058. mov ax, 'XX'
  1059. stosw
  1060. in al, 0a1h
  1061. mov ah, al
  1062. in al, 21h
  1063. push ax
  1064. mov word ptr cs:old_8259, ax
  1065. xor ax, ax
  1066. out 21h,al ; CLI
  1067. call SaveOthers
  1068. call SetSelfInt
  1069. call BackupVecList
  1070. cmp cs:Power, true
  1071. jnz @@20
  1072. call BackupCVTchain
  1073. call BackupMemoryManager
  1074. @@20:
  1075. call BackupBiosData

  1076. sti
  1077. mov cs:Flag, ' ' ; no busy
  1078. mov cs:StopFlag, 0 ;

  1079. mov cs:tsrLength, di
  1080. call SetDosEnvSeg
  1081. cmp cs:Self, 0
  1082. jz @@29
  1083. push cs
  1084. pop ds
  1085. push cs
  1086. pop es
  1087. cld
  1088. mov cx, cs:tsrLength
  1089. mov si, cs:DataBegin
  1090. sub cx, si
  1091. mov di, 120h
  1092. mov cs:DataBegin, di
  1093. rep movsb
  1094. mov cs:tsrLength, di
  1095. @@29:
  1096. pop ax
  1097. out 21h, al ; STI
  1098. mov al, ah
  1099. out 0a1h, al
  1100. mov dx, cs:tsrLength
  1101. inc dx
  1102. int 27h

  1103. ; ----------------------------------------------------------------------------
  1104. SetDosEnvSeg:
  1105. push ds
  1106. push es
  1107. mov ax, cs
  1108. @@10: mov es, ax
  1109. mov ax, es:[16h] ; Get father process psp segment
  1110. or ax, ax
  1111. jz @@11
  1112. mov bx, es
  1113. cmp ax, bx
  1114. jnz @@10
  1115. @@11:
  1116. mov es, word ptr es:[2ch] ; Get father process env segment
  1117. mov cs:DosEnv, es
  1118. pop es
  1119. pop ds
  1120. ret

  1121. ; ----------------------------------------------------------------------------

  1122. SaveOthers:
  1123. mov ax, cs:[2ch] ; Env Seg
  1124. stosw
  1125. call backupMCB ; Current MCB
  1126. mov ax, 40h ; COM LPT Port
  1127. mov ds, ax
  1128. mov si, 0h
  1129. mov cx, 8
  1130. rep movsw

  1131. mov si, 17h ; LED status
  1132. lodsb
  1133. stosb
  1134. ; call OpenLEDs
  1135. ret

  1136. ; --------------------------------------------------------------------------
  1137. backupMCB:
  1138. mov ax, 'ZM'
  1139. stosw
  1140. push ds
  1141. push es
  1142. mov ah, 52h
  1143. int 21h ; Get MCB chain head
  1144. mov ax, es:[bx-2]
  1145. pop es
  1146. @@0: mov ds, ax
  1147. cmp byte ptr ds:[0], 'Z' ; End ?
  1148. jz @@20 cmp byte ptr ds:[0], 'M' ; Memory control block
  1149. jnz @@30 cmp word ptr ds:[3], 0 ; Nul mcb
  1150. jz @@10 cmp word ptr ds:[1], 0 ; Free MCB
  1151. jnz @@10
  1152. call SaveFreeMCB
  1153. @@10: inc ax
  1154. add ax, ds:[3]
  1155. jmp @@0
  1156. @@20:
  1157. call SaveFreeMCB
  1158. cmp ax, 0a000h
  1159. inc ax
  1160. jnb @@30
  1161. mov ax, 9fffh ; MS-DOS UMB
  1162. jmp @@0

  1163. @@30:
  1164. cmp ax, 0c000h ; 386MAX
  1165. ja @@90
  1166. mov ax, 0c020h
  1167. jmp @@0

  1168. @@90: ; Error ?
  1169. pop ds
  1170. mov ax, 'MM' ; Set MCB flag
  1171. stosw
  1172. ret

  1173. SaveFreeMCB:
  1174. stosw
  1175. xor si,si
  1176. movsb
  1177. movsw
  1178. movsw
  1179. ret
  1180. ;
  1181. ; push ax
  1182. ; stosw
  1183. ; xor si,si
  1184. ; movsb
  1185. ; movsw
  1186. ; movsw
  1187. ; pop ax
  1188. ; cmp ax, 09fffh
  1189. ; jnb @@3
  1190. ; push ax
  1191. ; push ds
  1192. ; mov ds,ax
  1193. ; cmp byte ptr ds:[0], 'M'
  1194. ; pop ds
  1195. ; pop ax
  1196. ; jnz @@4
  1197. ; mov ax, 09fffh ; MS-DOS UMB
  1198. ; jmp @@0
  1199. ; @@4: cmp ax, 0c000h
  1200. ; ja @@3
  1201. ; mov ax, 0c020h ; 386MAX
  1202. ; jmp @@0
  1203. ;
  1204. ; --------------------------------------------------------------------------

  1205. OpenLEDs: push ax ; Open all LEDs
  1206. or al, 070h
  1207. mov ds:[17h], al
  1208. mov ah, 1 int 16h
  1209. mov cx, 4 ; Delay
  1210. @@20: push cx
  1211. xor cx, cx
  1212. @@21: loop @@21
  1213. pop cx
  1214. loop @@20
  1215. pop ax
  1216. mov ds:[17h], al
  1217. mov ah, 1 int 16h
  1218. ret

  1219. ; --------------------------------------------------------------------------
  1220. SetSelfInt:
  1221. push es
  1222. push di

  1223. cmp cs:self, 0
  1224. jnz @@1
  1225. push cs
  1226. pop ds
  1227. mov ax,3509h
  1228. int 21h
  1229. mov word ptr cs:oldInt9_addr,bx
  1230. mov word ptr cs:oldInt9_addr[2],es
  1231. mov dx,offset NewInt9
  1232. mov ax,2509h
  1233. int 21h

  1234. mov ax,352Fh
  1235. int 21h
  1236. mov word ptr cs:oldInt2F_addr,bx
  1237. mov word ptr cs:oldInt2F_addr[2],es
  1238. mov dx,offset newInt2F
  1239. mov ax,252Fh
  1240. int 21h

  1241. mov ax,351Ch
  1242. int 21h
  1243. mov word ptr cs:oldInt1C_addr,bx
  1244. mov word ptr cs:oldInt1C_addr[2],es
  1245. mov dx,offset newInt1C
  1246. mov ax,251ch
  1247. int 21h
  1248. cli
  1249. jmp @@2
  1250. @@1:
  1251. mov es, cs:Self
  1252. inc es:Copies
  1253. @@_0: cmp es:NextDataSeg, -1
  1254. jz @@_1
  1255. mov es, es:NextDataSeg
  1256. jmp @@_0
  1257. @@_1: mov es:NextDataSeg, cs
  1258. @@2:
  1259. pop di
  1260. pop es
  1261. ret

  1262. ; -----------------------------------------------------------------------
  1263. SaveCounter:
  1264. mov word ptr es:[di], 'EL'
  1265. mov byte ptr es:[di+2], 'I'
  1266. mov byte ptr es:[di+3], bl
  1267. xor bx, bx
  1268. add di, 4
  1269. ret

  1270. ; -----------------------------------------------------------------------
  1271. DisplayStr: push cs
  1272. pop ds
  1273. mov ah, 9 int 21h
  1274. ret

  1275. ; -----------------------------------------------------------------------
  1276. CmdLine:
  1277. push cs
  1278. pop ds
  1279. xor ax, ax
  1280. mov si, 80h
  1281. lodsb
  1282. or al, al
  1283. jnz @@1
  1284. ret
  1285. @@1:
  1286. mov cx, ax
  1287. dec ax
  1288. push ax
  1289. push si
  1290. @@0: lodsb
  1291. cmp al, ' '
  1292. jz @@0 cmp al, '/'
  1293. jnz @@2
  1294. lodsb
  1295. cmp al, 'S'
  1296. jz @@_2
  1297. cmp al, 's'
  1298. jnz @@2
  1299. @@_2:
  1300. call SetHotKey
  1301. Print SetMsg
  1302. mov ax, 4c00h
  1303. int 21h
  1304. @@2:
  1305. pop si
  1306. pop ax
  1307. push ax
  1308. push si
  1309. @@_3: lodsb
  1310. cmp al, 'A'
  1311. jb @@3 cmp al, 'Z'
  1312. ja @@3
  1313. add byte ptr ds:[si-1],20h ; DownCase
  1314. @@3: loop @@_3
  1315. pop si
  1316. pop cx

  1317. add si, cx
  1318. lodsb
  1319. cmp al, 's' ; CLS
  1320. jnz @@5 cmp word ptr ds:[si-3], 'lc'
  1321. jnz @@5 cmp cs:Self, 0
  1322. jz @Err
  1323. mov ax, 0c0d7h+1 int 2fh

  1324. @@5: cmp al, 'h' ; HELP
  1325. jz @help
  1326. cmp al, '?'
  1327. jz @help
  1328. cmp al, 't' ; RET
  1329. jnz @@6 cmp word ptr ds:[si-3], 'er'
  1330. jnz @@6
  1331. @@7:
  1332. cmp cs:Self, 0
  1333. jz @Err
  1334. mov ax, 0c0d7h+2 int 2fh
  1335. @@6: cmp al, 'w' ; NEW
  1336. jnz @@8 cmp word ptr ds:[si-3], 'en'
  1337. jnz @@8
  1338. mov cs:tsrOK, true
  1339. ret
  1340. @@8:
  1341. cmp al, 'l' ; ALL
  1342. jnz @@9 cmp word ptr ds:[si-3], 'la'
  1343. jnz @@9
  1344. mov ax, 0c0d7h+3 int 2fh
  1345. @@9:
  1346. cmp al, ' '
  1347. jnz @Err
  1348. ret

  1349. @Err:
  1350. Print ErrMsg
  1351. @help:
  1352. Print HelpMsg
  1353. mov ax, 4c00h
  1354. int 21h

  1355. ;---------------------------------------------------------------------------
  1356. tsrReplyOK:
  1357. cmp cs:Self, 0
  1358. jz @@1
  1359. Print Msg0

  1360. push es
  1361. mov ax, cs:Self
  1362. @@_10: mov es, ax
  1363. mov ax, es:NextDataSeg
  1364. cmp ax, -1
  1365. jnz @@_10
  1366. mov ax, es

  1367. @@_0: push ax
  1368. dec ax
  1369. mov es, ax
  1370. mov bx, es:[3]
  1371. pop ax

  1372. add ax, bx
  1373. inc ax
  1374. mov es, ax
  1375. cmp word ptr es:[0], 'OC'
  1376. jz @@_0

  1377. mov bx, cs
  1378. cmp ax, bx
  1379. pop es
  1380. jz @@2
  1381. Print Msg_0
  1382. mov ah, 1 int 21h

  1383. push ax
  1384. Print crlf
  1385. pop ax

  1386. cmp al, 'y'
  1387. jz @@3 cmp al, 'Y'
  1388. jz @@3
  1389. @@2: ; Print Msg_1
  1390. mov ax, 4c01h
  1391. int 21h
  1392. @@3:
  1393. @@1: mov cs:tsrOK, true
  1394. ret

  1395. PrintCopies:
  1396. cmp cs:Self, 0
  1397. jz @@1
  1398. push es ; Added -by- Mr. Lei
  1399. mov es, cs:Self ; Aug 24, 1993
  1400. mov al, es:Copies
  1401. inc al ; Total RI copies
  1402. push ax ; Set es = current mcb
  1403. mov ax, cs
  1404. dec ax
  1405. mov es, ax
  1406. pop ax
  1407. mov cx, 5 ; Search end of file name
  1408. mov bx, 8
  1409. @@10: inc bx
  1410. cmp byte ptr es:[bx], 20h
  1411. jz @@20 cmp byte ptr es:[bx], 0ffh
  1412. jz @@20 cmp byte ptr es:[bx], 00h
  1413. jz @@20
  1414. loop @@10
  1415. @@20: ; Set current RI no
  1416. mov byte ptr es:[bx], ':' ; "RI:2"
  1417. mov byte ptr es:[bx+1], al
  1418. cmp bx, 8+7
  1419. jnb @@30
  1420. mov byte ptr es:[bx+2], 0
  1421. @@30:
  1422. pop es

  1423. mov cs:Msg_RI, al
  1424. Print Msg_2
  1425. @@1: ret

  1426. ;---------------------------------------------------------------------------
  1427. ; Backup Interrupt Vector List
  1428. ;
  1429. BackupVecList:
  1430. push ds
  1431. push cs
  1432. pop es
  1433. xor si,si ; Vectors
  1434. mov ds,si
  1435. movsw
  1436. movsw
  1437. xor bx, bx
  1438. mov cx,00ffh
  1439. @@0: lodsw
  1440. xchg dx, ax
  1441. lodsw
  1442. cmp ax, es:[di-2]
  1443. jnz @@1 cmp dx, es:[di-4]
  1444. jz @@2
  1445. @@1: or bx, bx
  1446. jz @@3
  1447. call SaveCounter
  1448. @@3: xchg dx, ax
  1449. stosw
  1450. xchg dx, ax
  1451. stosw
  1452. loop @@0
  1453. jmp @@4
  1454. @@2: inc bx
  1455. loop @@0
  1456. call SaveCounter
  1457. @@4:
  1458. pop ds
  1459. ret
  1460. ;
  1461. ;-----------------------------------------------------------------------------
  1462. BackupCVTchain:
  1463. mov ax, 'VC'
  1464. stosw
  1465. push ax
  1466. push bx
  1467. push cx
  1468. push ds
  1469. push es
  1470. mov ah, 52h
  1471. int 21h ; ES:BX -- DOS table as described below

  1472. ; --------------------------------------------------------------------
  1473. push es ; DPB chains
  1474. push bx
  1475. lds si, es:[bx]
  1476. push cs
  1477. pop es
  1478. mov ax, si
  1479. stosw
  1480. mov ax, ds
  1481. stosw
  1482. mov bx, cs:cvtOfs
  1483. xor cx, cx
  1484. @@1: mov al, ds:[si+1]
  1485. stosb
  1486. mov ax, ds:[si+bx+12h]
  1487. stosw
  1488. mov ax, ds:[si+bx+14h]
  1489. stosw
  1490. inc cx
  1491. lds si, ds:[si+bx+18h]
  1492. cmp si, -1
  1493. jnz @@1
  1494. ; mov ax, 5
  1495. ; mul cl
  1496. ; add ax, 4
  1497. ; add cs:tsrLength, ax
  1498. pop bx
  1499. pop es

  1500. ; --------------------------------------------------------------------
  1501. push es ; DCB file control blocks
  1502. push bx
  1503. les bx, es:[bx+4]
  1504. @@11: cmp word ptr es:[bx], -1
  1505. jz @@10
  1506. les bx, es:[bx]
  1507. jmp @@11
  1508. @@10:
  1509. mov ax, es
  1510. xchg ax, bx
  1511. push cs
  1512. pop es
  1513. stosw
  1514. xchg ax, bx
  1515. stosw
  1516. pop bx
  1517. pop es
  1518. ; add cs:tsrLength, 4

  1519. ; ---------------------------------------------------------------------
  1520. push es ; Device Driver Chains
  1521. pop ds
  1522. add bx, 22h
  1523. mov si, bx ; NUL

  1524. pop es
  1525. mov ax, si
  1526. stosw
  1527. mov ax, ds
  1528. stosw
  1529. xor cx, cx
  1530. xor bx, bx
  1531. @@9: push si
  1532. mov cl, 5
  1533. rep movsw
  1534. inc bx
  1535. pop si
  1536. lds si, ds:[si]
  1537. mov ax, si
  1538. inc ax
  1539. jnz @@9

  1540. pop ds
  1541. pop cx
  1542. pop bx
  1543. pop ax
  1544. ret

  1545. ; ----------------------------------------------------------------------------

  1546. BackupBiosData:
  1547. mov ax, '--'
  1548. stosw
  1549. push ds
  1550. push si
  1551. mov si, 40h
  1552. mov ds, si
  1553. mov si, 10h
  1554. movsw
  1555. mov si, 0a8h
  1556. movsw
  1557. movsw
  1558. mov si, 49h
  1559. mov cx, 1dh
  1560. rep movsb

  1561. mov si, 0f0h
  1562. mov cx, 8
  1563. rep movsw
  1564. pop si
  1565. pop ds
  1566. ret

  1567. ; ---------------------------------------------------------------------------

  1568. BackupMemoryManager:
  1569. push cs
  1570. pop es
  1571. push ds
  1572. push es
  1573. call SaveXMSstatus
  1574. call SaveEMSstatus
  1575. pop es
  1576. pop ds
  1577. ret

  1578. ;---------------------------------------------------------------------

  1579. SaveEMSstatus:
  1580. test cs:status, EMSbit
  1581. jnz @@1
  1582. ret
  1583. @@1:
  1584. mov ax, 'ME'
  1585. stosw
  1586. inc di
  1587. inc di
  1588. push di
  1589. mov ah, 4dh
  1590. int 67h
  1591. pop di
  1592. mov es:[di-2], bx
  1593. shl bx, 1
  1594. shl bx, 1
  1595. add di, bx
  1596. ret
  1597. ; -------------------------------------------------------------------

  1598. SaveXMSstatus:
  1599. call XMS_test
  1600. test cs:status, XMSbit
  1601. jnz @@1
  1602. ret
  1603. @@1:
  1604. mov ax, 'MX'
  1605. stosw

  1606. mov dx, 1
  1607. call XMS_alloc
  1608. jnz @@_1
  1609. xor cx, cx ; XMS alloc failure
  1610. stosw
  1611. ret
  1612. @@_1:
  1613. push dx
  1614. sub dx, MaxHandles 10
  1615. @@2:
  1616. push dx
  1617. call XMS_Lock
  1618. pop dx
  1619. jnz @@3 cmp bl, 0a2h
  1620. jnz @@4
  1621. add dx, 10
  1622. jmp @@2
  1623. @@3: push dx
  1624. call XMS_unlock
  1625. pop dx
  1626. @@4:
  1627. mov cs:handle_begin, dx
  1628. pop dx
  1629. push dx
  1630. call XMS_bstat
  1631. xor cx, cx
  1632. mov cl, bl
  1633. inc cx
  1634. pop dx
  1635. call XMS_Free
  1636. mov dx, cs:Handle_begin

  1637. push cx
  1638. push cs
  1639. pop es
  1640. mov ax, cx
  1641. stosw
  1642. @@5: push dx
  1643. call XMS_Lock
  1644. pop dx
  1645. jnz @@6 cmp bl, 0a2h ; Handle invalid
  1646. jz @@7
  1647. @@6: call XMS_unlock
  1648. add dx, 10
  1649. jmp @@5
  1650. @@7: mov ax, dx
  1651. stosw
  1652. add dx, 10
  1653. loop @@5
  1654. pop cx
  1655. ret
  1656. ; ------------------------------------------------------------------

  1657. XMS_test:
  1658. push es
  1659. mov ax, 4300h
  1660. int 2fh
  1661. cmp al, 80h
  1662. jnz @@9
  1663. mov ax, 4310h
  1664. int 2fh
  1665. mov cs:XMS_control, bx
  1666. mov cs:XMS_control[2], es
  1667. or cs:Status, XMSbit
  1668. @@9:
  1669. pop es
  1670. ret

  1671. XMS_stat:
  1672. mov ah, 0
  1673. call dword ptr cs:xms_control
  1674. mov hma_exist, dl
  1675. ret
  1676. hma_exist db 0

  1677. XMS_alloc:
  1678. mov ah, 9
  1679. call dword ptr cs:xms_control
  1680. or ax, ax
  1681. ret

  1682. XMS_lock:
  1683. mov ah, 0ch
  1684. call dword ptr cs:xms_control
  1685. or ax, ax
  1686. ret

  1687. XMS_unlock:
  1688. mov ah, 0dh
  1689. call dword ptr cs:xms_control
  1690. or ax, ax
  1691. ret
  1692. XMS_bstat:
  1693. mov ah, 0eh
  1694. call dword ptr cs:xms_control
  1695. or ax, ax
  1696. ret

  1697. XMS_free:
  1698. mov ah, 0ah
  1699. call dword ptr cs:xms_control
  1700. or ax, ax
  1701. ret

  1702. ; ----------------------------------------------------------------------------
  1703. EMS_test:
  1704. push cs
  1705. pop ds
  1706. mov dx, offset EMMname
  1707. mov ax, 3d00h
  1708. int 21h
  1709. jc @@2
  1710. mov bx, ax
  1711. mov ah, 3eh
  1712. int 21h
  1713. or cs:Status, EMSbit
  1714. @@2:
  1715. ret
  1716. EMMname db 'EMMXXXX0',0

  1717. ; -----------------------------------------------------------------------------

  1718. SetHotKey:
  1719. xor bx, bx
  1720. lodsb
  1721. push ax

  1722. @@1: lodsb
  1723. cmp al, 0dh
  1724. jz @@9 cmp al, 'C'
  1725. jnz @@2
  1726. or bl, LeftCtrl
  1727. jmp @@1
  1728. @@2:
  1729. cmp al, 'c'
  1730. jnz @@3
  1731. or bl, RightCtrl
  1732. jmp @@1
  1733. @@3:
  1734. cmp al, 'A'
  1735. jnz @@4
  1736. or bl, LeftAlt
  1737. jmp @@1
  1738. @@4:
  1739. cmp al, 'a'
  1740. jnz @@5
  1741. or bl, RightAlt
  1742. jmp @@1
  1743. @@5:
  1744. cmp al, 'S'
  1745. jnz @@6
  1746. or bl, LeftShift
  1747. jmp @@1
  1748. @@6:
  1749. cmp al, 's'
  1750. jnz @@7
  1751. or bl, RightShift
  1752. jmp @@1
  1753. @@7: pop ax
  1754. jmp @Err
  1755. @@9:
  1756. mov cs:HotKey, bl
  1757. pop ax
  1758. mov cs:AuxHotKey, 2dh ; 'X' scan key
  1759. cmp al, '1'
  1760. jz @@29
  1761. mov cs:AuxHotKey, 0
  1762. @@29:
  1763. cmp cs:Self, 0
  1764. jz @@30
  1765. push es
  1766. mov es, cs:Self
  1767. mov es:HotKey, bl
  1768. mov bl, cs:AuxHotKey
  1769. mov es:AuxHotKey, bl
  1770. pop es
  1771. @@30:
  1772. call GetRunFileName
  1773. mov ax, 3d02h
  1774. int 21h
  1775. jc @@10
  1776. push cs
  1777. pop ds
  1778. mov bx, ax
  1779. mov cx, 4
  1780. mov dx, 100h
  1781. mov ah, 40h
  1782. int 21h
  1783. jc @@10
  1784. mov ax, 4200h
  1785. xor cx, cx
  1786. mov dx, 17h
  1787. int 21h
  1788. jc @@10
  1789. mov cx, 1
  1790. mov dx, offset AuxHotKey
  1791. mov ah, 40h
  1792. int 21h
  1793. jc @@10
  1794. mov ah, 3eh
  1795. int 21h
  1796. @@10:
  1797. ret


  1798. ; -----------------------------------------------------------------------
  1799. GetRunFileName:
  1800. ; Return:
  1801. ; DS:DX Pointer of this run file name ASCIIZ string
  1802. push ax
  1803. push bx
  1804. push cx
  1805. push si
  1806. push di
  1807. push es

  1808. push cs
  1809. pop es
  1810. mov ax, es:[2ch]
  1811. mov es, ax
  1812. xor di, di
  1813. mov cx, 1000h
  1814. xor al, al
  1815. @@1: repnz scasb
  1816. cmp es:[di], al
  1817. loopnz @@1
  1818. mov dx, di
  1819. add dx, 3
  1820. push es
  1821. pop ds

  1822. pop es
  1823. pop di
  1824. pop si
  1825. pop cx
  1826. pop bx
  1827. pop ax
  1828. ret

  1829. ; ---------------------------------------------------------------------------
  1830. GetMachineID:
  1831. push es
  1832. mov KBD102,True
  1833. mov ax,40h
  1834. mov es,ax
  1835. test byte ptr es:[96h], 00010000b
  1836. jnz @@1
  1837. mov Kbd102,False
  1838. @@1:
  1839. xor ax,ax
  1840. dec ax
  1841. mov es,ax
  1842. mov al,es:[0eh]
  1843. mov cs:MachineID, al
  1844. pop es
  1845. ret

  1846. ; ---------------------------------------------------------------------------
  1847. ModifyHotKeyPrompt:
  1848. cmp cs:Kbd102, True
  1849. jz @@9
  1850. push cs
  1851. pop es
  1852. push cs
  1853. pop ds
  1854. mov cx, 124
  1855. mov si, offset KMsg2
  1856. mov di, offset KMsg1
  1857. rep movsb
  1858. @@9: cmp cs:MachineID, 0fch
  1859. jna @@10
  1860. mov cs:clsStrcolor, 70h ; Mono
  1861. mov cs:clsStr, 70h
  1862. @@10:
  1863. ret

  1864. ; ---------------------------------------------------------------------------
  1865. PrintHotKeyPrompt:
  1866. Print Msg1
  1867. mov al, cs:HotKey
  1868. mov ah, al
  1869. shr al, 1
  1870. shr al, 1
  1871. and ax, 33ch
  1872. or al, ah
  1873. mov dx, offset KeyMsg
  1874. @@40:
  1875. or ax, ax ; Mr. Lei 4/25/1993
  1876. jz @@_42
  1877. shr al, 1
  1878. push ax
  1879. jnc @@41

  1880. push ax
  1881. call ColorDisplayStr
  1882. ; mov ah, 9
  1883. ; int 21h
  1884. pop ax

  1885. or al, al
  1886. jz @@42

  1887. push dx
  1888. mov dx, offset PlusMsg
  1889. call ColorDisplayStr
  1890. ; Print PlusMsg
  1891. pop dx

  1892. @@41: add dx, 12
  1893. pop ax
  1894. jmp @@40
  1895. @@42: pop ax
  1896. @@_42: cmp cs:AuxHotKey, 0
  1897. jz @@43 cmp cs:HotKey, 0 ; Mr. Lei
  1898. jz @@_43
  1899. mov dx, offset PlusMsg
  1900. call ColorDisplayStr
  1901. ; Print PlusMsg
  1902. @@_43: mov dx, offset AuxHotKeyName
  1903. call ColorDisplayStr
  1904. ; Print AuxHotKeyName
  1905. @@43:
  1906. Print crlf
  1907. ret

  1908. ColorDisplayStr:
  1909. push bx
  1910. push cx
  1911. push dx
  1912. push si
  1913. mov bl, 0fh
  1914. mov si, dx
  1915. xor bh, bh
  1916. mov cx, 1
  1917. @@1: lodsb
  1918. cmp al, '$'
  1919. jz @@2
  1920. or al, al
  1921. jz @@2
  1922. push cx
  1923. mov ah, 09h
  1924. int 10h
  1925. mov ah, 3 int 10h
  1926. inc dl
  1927. mov ah, 2 int 10h
  1928. pop cx
  1929. jmp short @@1
  1930. @@2:
  1931. pop si
  1932. pop dx
  1933. pop cx
  1934. pop bx
  1935. ret

  1936. ; ---------------------------------------------------------------------------
  1937. CmpSideKick:
  1938. xor ax, ax
  1939. mov es, ax
  1940. les bx, es:[20h]
  1941. cmp word ptr es:[bx-4], 4b53h
  1942. jnz @@1 cmp word ptr es:[bx-2], 4942h
  1943. jz @@2
  1944. @@1: mov es, ax
  1945. les bx, es:[94h]
  1946. cmp word ptr es:[bx-2], 4b53h
  1947. jz @@2
  1948. ret
  1949. @@2: or cs:Status, SKbit
  1950. ret

  1951. ; ---------------------------------------------------------------------------
  1952. CmpDosVer: mov ah, 30h
  1953. int 21h
  1954. cmp al, 3
  1955. jb @@1 cmp al, 3
  1956. jna @@2
  1957. mov cs:cvtOfs, 1
  1958. ret
  1959. @@2: mov cs:cvtOfs, 0
  1960. ret
  1961. @@1: Print DosVerErr
  1962. mov ax, 4cffh
  1963. int 21h

  1964. DosVerErr db 'Sorry, DOS version too lower !',0dh,0ah,'$'

  1965. HotKeyValid:
  1966. cmp cs:HotKey, 0
  1967. jnz @@_1
  1968. cmp cs:AuxHotKey, 0
  1969. jnz @@_1
  1970. Print HotKeyErr
  1971. mov ax, 4cfeh
  1972. int 21h
  1973. @@_1: ret

  1974. HotKeyErr db 'Sorry, please setup hotkey again. ',0dh,0ah,'$'

  1975. eof:
  1976. ends
  1977. end Start

  1978. ; ------------- The End ! ---------------------------------------------------




反正我这个菜鸡是编不出来啊,大兄弟你们怎么样;


user avatar   song-qi-49 网友的相关建议: 
      

雷军当年可是黄玫瑰工作室的创始人呀,90年代左右,满大街的盗版工具软件光盘里面都是他们软件工作室开发的那些解密软件,我们当时用的很多正版软件都是用他们编的解密软件破壳的哦。

其实很多IT名人现在看起来好像只负责管理,不懂技术,其实他们中的不少人也是程序高手,除了雷军之外,还有他的老对头周鸿祎,当年可是中国第一个Windows平台上的电子邮件客户端的开发者哦,再往远处说,当年新浪创始人王志东,也是当年名满Windows 3.1的中文平台,中文之星的开发者。

所以说,不要以为他们只是通过管人管事而出名,他们自己本身也是实力超强的技术高手,才能看准技术的潮流呀。


user avatar   meng-zhao-zuo-lian 网友的相关建议: 
      

老实说,我对穿越技术比对这个问题感兴趣多了,为什么大家那么喜欢cos呢?成天幻想着自己是托洛茨基同志,在红场上对红军战士招手吗?能赚几个毛主席啊?洗洗睡吧,cos有风险。


user avatar   ji-ke-chen-xing-22 网友的相关建议: 
      

不是很懂现在人怎么买啥都成投资了,买车也要核算一下机会成本了,买手机也要考虑卖二手了,买游戏主机也要考虑跌价了,买游戏卡带也要考虑好不好出手了。

车是消费品啊,什么手机电脑主机卡带也都是消费品,消费品就是用来让你用,感受效用的。

你需要这个效用,它能提供这个效用,它的价格受供求关系影响最终维持在一个你愿意接受的水平,这就够了。

你要是不需要这个效用你就不买呗,如果你的城市真有良好的公共交通,确实省钱,省时间还省力,那你就别买呗。你买了难道不是你需要么?既然需要那还说什么呢。。


要我说,撸串才是一生最坏的投资,变成了肥肉你还得花时间、金钱和精力去减肥,可能还会带来未来潜在医疗成本。那为什么撸串摊子还是这么火?因为爽啊,因为它提供的效用我们确实需要啊。


所以不要干什么事都用投资思维去理解,这样会成为资本增殖的奴隶的。生产的目的是为了让人得到效用,而不是让生产进一步扩大。


user avatar   zhuanzhizhuangbi 网友的相关建议: 
      

湘潭老人家如果自称NO2,无人敢称NO1




  

相关话题

  c++如此繁琐,为什么大学不直接开展python课程? 
  结合深度学习的图像修复怎么实现? 
  什么才算是真正的编程能力? 
  如何看待小米与美图达成战略合作? 
  如何看待华为和小米同样曝光折叠屏手机时,网友和媒体口风截然不同? 
  小米真的像很多人说的那样没有核心技术吗? 
  如何看待 TapTap 喊话雷军「小米游戏中心虽然爱学习,但抄错了作业」? 
  可以用最通俗的语言告诉我程序员敲的一行行代码怎么变成一个个游戏?那么写代码的难度又在哪里? 
  如何看待小米手表出现大量差评现象?真的很难用吗? 
  学习编程必须要会英语吗? 

前一个讨论
吴亦凡事件之后,「小鲜肉流量经济」将受到怎样的震荡?是否还会存在?
下一个讨论
电影《阿凡达》内地重映,看完后你有什么感受?





© 2024-12-26 - tinynew.org. All Rights Reserved.
© 2024-12-26 - tinynew.org. 保留所有权利