flat assembler
Message board for the users of flat assembler.
Index
> DOS > AMDECHO: New kinda ECHO command replacement ;) |
Author |
|
MCD 27 May 2005, 09:14
More complete version of AMDECHO. Please post any suggestions/bugs.
-AMDECHO with proper CPU and protected mode detection. -Fixed the bug which caused the retrieved string to be cut off at 32 instead of 48 characters. -Some basic user strings were added (usage...) Code: nl equ 0Dh,0Ah org 100h Start: mov ah,70h ;check for 80386+ CPU push ax popf ;BTW this clears direction and interrupt flags pushf pop bx cmp bh,ah jne ErrNoAMDAthlon pushfd ;check for CPUID instruction pop eax bts eax,21 push eax popfd pushfd pop ebx cmp ebx,eax jne ErrNoAMDAthlon xor eax,eax cpuid or eax,eax ;CPUID page 0 and 1 supported? jz ErrNoAMDAthlon cmp ebx,"Auth" ;Allow only AMD CPUs jne ErrNoAMDAthlon ;does this work on other CPUs? I have no clue cmp edx,"enti" jne ErrNoAMDAthlon cmp ecx,"cAMD" jne ErrNoAMDAthlon mov eax,1 cpuid cmp ax,620h ;Athlon (Family 6) and Model 2 required jb ErrNoAMDAthlon smsw ax ;check whether CPU is in protected mode test al,1 jz RealModeOk call ExitMsg db "error: CPU in protected mode.$",nl ErrNoAMDAthlon: call ExitMsg db "error: AMD Athlon(tm) model 2 CPU or newer required.$",nl RealModeOk: mov si,81h mov cx,7Fh FindCmdlnStart: lodsb ;skip first spaces cmp al," " loope FindCmdlnStart dec si mov cx,48 mov bx,si ScanCmdln: lodsb or al,al jz CmdlnEnd cmp al,0Dh ;replace character 0Dh with 0 je StripTrailChr loop ScanCmdln jmp CmdlnEnd StripTrailChr: mov [si-1],ch ;ch contains 0 CmdlnEnd: dec si cmp si,bx jne CmdlnOk call ExitMsg db "usage: AMDECHO [string]",nl,nl,\ "Writes string into the CPU brand string MSRs, retrieves and echoes it.",nl,\ "String is limited to 47 characters.$",nl CmdlnOk: inc si ClrCmdln: mov [si],ch inc si loop ClrCmdln ;pad the rest with zeros until offset +48 std ;MSR writing is done in reverse lea si,[bx+48-4] mov ecx,0C0010035h ;magic MSRs WriteMSR: lodsd mov edx,eax lodsd wrmsr cmp cl,30h loopne WriteMSR sti mov eax,80000002h ;now retrieve written string mov di,81h ;use commandline as buffer, just overwrite it GetCPUStr: push eax cpuid mov [di],eax mov [di+4],ebx mov [di+8],ecx mov [di+0Ch],edx pop eax inc al add di,10h cmp al,5 jne GetCPUStr mov byte [di-1],"$" push 81h ExitMsg: mov ah,9 ;display exit message pop dx int 21h int 20h _________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||
27 May 2005, 09:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.