Assembly Language... anyone??

Author Message
yfki

  • Total Posts : 97
  • Scores: 0
  • Reward points : 0
  • Joined: 12/12/2007
  • Status: offline
Assembly Language... anyone?? Tuesday, April 01, 2008 2:50 PM (permalink)
0
Some assembly code that I am trying to understand, just thought I would throw tihs out there..
I am trying to get this to work on Vista x64

Any assebly people out there?

 
 ; FANCTRL.ASM
 ; The fan control functions; extracted from NBFAN.MDM and NBSVC.MDM from 
 ; the Dell Diagnostics 1052
 
 ; Authors: Some unknown Dell engineers using Visual C++; stripped down
 ;          and optimized by MH ;-)
 
 .386p
 .model flat
 
 extrn _printf:near
 
 public _hlcontrol
 
 .code
 ;--------------------------------------
 ; _hlcontrol: high level fan control
 ;
 ;  In: D[EBP+8]:Fan No (0=outer,1=inner)
 ;      D[EBP+12]:Speed (2=high,1=slow,0=off)
 ; Out: 1:ok 0:error
 ;--------------------------------------
 
 _hlcontrol:
         push ebp
         mov ebp,esp
         sub esp,32
         push ebx
         push esi
         push edi
         
         mov eax,dword ptr [ebp+12]
         mov eax,dword ptr [4*eax+speed]
         push eax            ; 3. arg: speed text
         mov eax,dword ptr [ebp+8]
         mov eax,dword ptr [4*eax+fan]
         push eax            ; 2. arg: fan no
         push offset setspeed        ; 1. arg: format string
         call _printf
         add esp,12
 
         mov eax,dword ptr [ebp+12]    ; fan speed
         push eax
         mov eax,dword ptr [ebp+8]    ; fan no
         push eax
         call genfanstruct
         add esp,8
         cmp eax,1
         je @a5
     
     push offset err1
     call _printf
     add esp,4
     xor eax,eax
     
 ;---------
 @a5:    pop edi
         pop esi
         pop ebx
         leave
         ret
 
 ;--------------------------------------
 ; genfanstruct: create smbios structure for fan control
 ;
 ;  In: D[EBP+8]:Fan No (0=outer,1=inner)
 ;      D[EBP+12]:Speed (2=high,1=slow,0=off)
 ; Out: 1:ok <>1:error
 ;--------------------------------------
 genfanstruct:
         push ebp
         mov ebp, esp
         sub esp, 20h
         push ebx
         push esi
         push edi
         mov byte ptr [ebp-1Ch],0a3h
         mov byte ptr [ebp-1Bh],1
         mov al,byte ptr [ebp+8]
         mov byte ptr [ebp-18h],al
         mov al,byte ptr [ebp+12]
         mov byte ptr [ebp-17h],al
         mov word ptr [ebp-14h],0
         mov word ptr [ebp-10h],0
         lea eax,dword ptr [ebp-1Ch]
         push eax
         call smbiosfct
         add esp,4
         pop edi
         pop esi
         pop ebx
         leave
         ret
 
 ;--------------------------------------
 ; smbiosfct: execute commands in smbios structure
 ;
 ;  In: D[EBP+8]:Pointer to smbios structure
 ; Out: 1:ok <>1:error
 ;--------------------------------------
 smbiosfct:
         push ebp
         mov ebp, esp
         sub esp, 14h
         push ebx
         push esi
         push edi
         mov word ptr [ebp-10h], 1
         mov eax, dword ptr [ebp+8]
         mov ax, word ptr [eax]
         mov word ptr [ebp-14h], ax
         mov eax, dword ptr [ebp+8]
         mov ax, word ptr [eax+4]
         mov word ptr [ebp-4], ax
         mov eax, dword ptr [ebp+8]
         mov ax, word ptr [eax+8]
         mov word ptr [ebp-8], ax
         mov eax, dword ptr [ebp+8]
         mov ax, word ptr [eax+0Ch]
         mov word ptr [ebp-0Ch], ax
         pushad
         mov ax, word ptr [ebp-14h]
         mov bx, word ptr [ebp-4]
         mov cx, word ptr [ebp-8]
         mov dx, word ptr [ebp-0Ch]
         out 0b2h, al
         out 084h, al
         mov word ptr [ebp-14h], ax
         mov word ptr [ebp-4], bx
         mov word ptr [ebp-8], cx
         mov word ptr [ebp-0Ch], dx
         popad
         mov eax, dword ptr [ebp+8]
         xor ecx, ecx
         mov cx, word ptr [eax]
         mov eax, dword ptr [ebp-14h]
         and eax, 0000FFFFh
         cmp ecx, eax
         jne @c1
         mov eax, dword ptr [ebp+8]
         xor ecx, ecx
         mov cx, word ptr [eax+4]
         mov eax, dword ptr [ebp-4]
         and eax, 0000FFFFh
         cmp ecx, eax
         jne @c1
         mov eax, dword ptr [ebp+8]
         xor ecx, ecx
         mov cx, word ptr [eax+8]
         mov eax, dword ptr [ebp-8]
         and eax, 0000FFFFh
         cmp ecx, eax
         jne @c1
         mov eax, dword ptr [ebp+8]
         xor ecx, ecx
         mov cx, word ptr [eax+0Ch]
         mov eax, dword ptr [ebp-0Ch]
         and eax, 0000FFFFh
         cmp ecx, eax
         jne @c1
         push offset svc52A8
         call _printf
         add esp, 4
         mov word ptr [ebp-10h], 0
 ;---------
 @c1:    mov eax, dword ptr [ebp-14h]
         and eax, 0000FFFFh
         cmp eax, 0000FFFFh
         jne @c2
         mov eax, dword ptr [ebp+8]
         xor ecx, ecx
         mov cl, byte ptr [eax+4]
         push ecx
         push offset svc52DC
         call _printf
         add esp, 8
         mov word ptr [ebp-10h], 0
 ;---------
 @c2:    mov ax, word ptr [ebp-14h]
         mov ecx, dword ptr [ebp+8]
         mov word ptr [ecx], ax
         mov ax, word ptr [ebp-4]
         mov ecx, dword ptr [ebp+8]
         mov word ptr [ecx+4], ax
         mov ax, word ptr [ebp-8]
         mov ecx, dword ptr [ebp+8]
         mov word ptr [ecx+8], ax
         mov ax, word ptr [ebp-0Ch]
         mov ecx, dword ptr [ebp+8]
         mov word ptr [ecx+0Ch], ax
         movsx eax, word ptr [ebp-10h]
         test eax, eax
         je @c4
         mov eax, 1
         jmp @c5
 ;---------
 @c4:    mov eax, 5
 ;---------
 @c5:    pop edi
         pop esi
         pop ebx
         leave
         ret
     
 ;******************************************************
 .data
 err1    db 'Failed to set fan speed',13,10,0
 
 setspeed db 'Setting %s fan to %s',13,10,0
 
 speed   dd offset off
         dd offset slow
         dd offset high
 
 fan    dd offset right
     dd offset left
     
 left    db 'inner',0
 right   db 'outer',0
 
 high    db 'high',0
 slow    db 'slow',0
 off     db 'off',0
 
 svc52A8    db 'Smbios: Function not supported somehow..',13,10,0
 svc52DC db 'Smbios: Invalid device (%d)',13,10,0
 
 ;******************************************************
 end
         
 

 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9