Totally new to ASM, with that said, can someone point me in the right direction of figuring out how to compile this.
There is a GUI to this application, but I would just like to be able to call this directly.

http://www.diefer.de/i8kfan/i8kfan.html

Says on the site: "If you want to compile it yourself, you need the DiceRTE environment"
The DiceRTE env comes with DASM32, would I be able to compile this with NASM.
http://www.diefer.de/dicerte/

Sorry fore the noob questions, but ya gota start somewhere right..


; 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:Fan No (0=outer,1=inner)
;      D: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
        mov eax,dword ptr [4*eax+speed]
        push eax ; 3. arg: speed text
        mov eax,dword ptr
        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 ; fan speed
        push eax
        mov eax,dword ptr ; 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:Fan No (0=outer,1=inner)
;      D: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 ,0a3h
        mov byte ptr ,1
        mov al,byte ptr
        mov byte ptr ,al
        mov al,byte ptr
        mov byte ptr ,al
        mov word ptr ,0
        mov word ptr ,0
        lea eax,dword ptr
        push eax
        call smbiosfct
        add esp,4
        pop edi
        pop esi
        pop ebx
        leave
        ret

;--------------------------------------
; smbiosfct: execute commands in smbios structure
;
;  In: D: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 , 1
        mov eax, dword ptr
        mov ax, word ptr
        mov word ptr , ax
        mov eax, dword ptr
        mov ax, word ptr
        mov word ptr , ax
        mov eax, dword ptr
        mov ax, word ptr
        mov word ptr , ax
        mov eax, dword ptr
        mov ax, word ptr
        mov word ptr , ax
        pushad
        mov ax, word ptr
        mov bx, word ptr
        mov cx, word ptr
        mov dx, word ptr
        out 0b2h, al
        out 084h, al
        mov word ptr , ax
        mov word ptr , bx
        mov word ptr , cx
        mov word ptr , dx
        popad
        mov eax, dword ptr
        xor ecx, ecx
        mov cx, word ptr
        mov eax, dword ptr
        and eax, 0000FFFFh
        cmp ecx, eax
        jne @c1
        mov eax, dword ptr
        xor ecx, ecx
        mov cx, word ptr
        mov eax, dword ptr
        and eax, 0000FFFFh
        cmp ecx, eax
        jne @c1
        mov eax, dword ptr
        xor ecx, ecx
        mov cx, word ptr
        mov eax, dword ptr
        and eax, 0000FFFFh
        cmp ecx, eax
        jne @c1
        mov eax, dword ptr
        xor ecx, ecx
        mov cx, word ptr
        mov eax, dword ptr
        and eax, 0000FFFFh
        cmp ecx, eax
        jne @c1
        push offset svc52A8
        call _printf
        add esp, 4
        mov word ptr , 0
;---------
@c1:    mov eax, dword ptr
        and eax, 0000FFFFh
        cmp eax, 0000FFFFh
        jne @c2
        mov eax, dword ptr
        xor ecx, ecx
        mov cl, byte ptr
        push ecx
        push offset svc52DC
        call _printf
        add esp, 8
        mov word ptr , 0
;---------
@c2:    mov ax, word ptr
        mov ecx, dword ptr
        mov word ptr , ax
        mov ax, word ptr
        mov ecx, dword ptr
        mov word ptr , ax
        mov ax, word ptr
        mov ecx, dword ptr
        mov word ptr , ax
        mov ax, word ptr
        mov ecx, dword ptr
        mov word ptr , ax
        movsx eax, word ptr
        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',13,10,0
svc52DC db 'Smbios: Invalid device (%d)',13,10,0

;******************************************************
end
       
Posted on 2008-04-27 16:57:11 by yfki
and here is the C that it was originally compiled with..



// I8KFAN.C - just parse the arguments and call 'hlcontrol'
// Author: MH
#include <stdio.h>

extern int __cdecl hlcontrol( int fan, int speed );

int main( int argc, char* argv[] )
{
  int i;
 
  if( argc != 3 )
  {
    printf( "Inspiron 8000 fan control utility V1.0 - extracted and optimized by MH\n" );
    printf( "\nUsage: I8KFAN <inner fan speed> <outer fan speed>\n" );
    printf( "      Fan speeds: 2=high, 1=slow, 0=off, -=don't change\n" );
    printf( "      Example: I8KFAN 1 1 -> set both fans to slow speed\n\n" );
    return 0;
  }

  for( i=1; i<argc; i++ )
  {
    switch( *argv )
    {
      case '0':
      case '1':
      case '2': hlcontrol( i==1?1:0, *argv-'0' );
      break;
     
      case '-': break;
     
      default:  printf( "Ignoring unknown option '%s'\n", argv );
      break;
    }
  }
 
  return 0;
}

Posted on 2008-04-27 17:22:48 by yfki
If it's for Windows then it won't be trivial to make the 'out' instructions work. On Win9x you could use it with no big problems, but on Windows NT you can't communicate with the devices directly (at least not in any easy/quick way).

Or maybe I don't know something..?
Posted on 2008-04-27 18:20:10 by ti_mo_n
That ASM source looks like it needs MASM or TASM. It would need translation for NASM to assemble it.
Posted on 2008-04-27 18:45:23 by SpooK
; 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 ;-)



EXTERN _printf

global _hlcontrol


;--------------------------------------
; _hlcontrol: high level fan control
;
;  In: D:Fan No (0=outer,1=inner)
;      D: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
        mov eax,dword [4*eax+speed]
        push eax ; 3. arg: speed text
        mov eax,dword
        mov eax,dword [4*eax+fan]
        push eax ; 2. arg: fan no
        push dword setspeed ; 1. arg: format string
        call _printf
        add esp,12

        mov eax,dword ; fan speed
        push eax
        mov eax,dword ; fan no
        push eax
        call genfanstruct
        add esp,8
        cmp eax,1
        je @a5

push dword 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:Fan No (0=outer,1=inner)
;      D: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 ,0a3h
        mov byte ,1
        mov al,byte
        mov byte ,al
        mov al,byte
        mov byte ,al
        mov word ,0
        mov word ,0
        lea eax,
        push eax
        call smbiosfct
        add esp,4
        pop edi
        pop esi
        pop ebx
        leave
        ret

;--------------------------------------
; smbiosfct: execute commands in smbios structure
;
;  In: D: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 , 1
        mov eax, dword
        mov ax, word
        mov word , ax
        mov eax, dword
        mov ax, word
        mov word , ax
        mov eax, dword
        mov ax, word
        mov word , ax
        mov eax, dword
        mov ax, word
        mov word , ax
        pushad
        mov ax, word
        mov bx, word
        mov cx, word
        mov dx, word
        out 0b2h, al
        out 084h, al
        mov word , ax
        mov word , bx
        mov word , cx
        mov word , dx
        popad
        mov eax, dword
        xor ecx, ecx
        mov cx, word
        mov eax, dword
        and eax, 0000FFFFh
        cmp ecx, eax
        jne @c1
        mov eax, dword
        xor ecx, ecx
        mov cx, word
        mov eax, dword
        and eax, 0000FFFFh
        cmp ecx, eax
        jne @c1
        mov eax, dword
        xor ecx, ecx
        mov cx, word
        mov eax, dword
        and eax, 0000FFFFh
        cmp ecx, eax
        jne @c1
        mov eax, dword
        xor ecx, ecx
        mov cx, word
        mov eax, dword
        and eax, 0000FFFFh
        cmp ecx, eax
        jne @c1
        push dword svc52A8
        call _printf
        add esp, 4
        mov word , 0
;---------
@c1:    mov eax, dword
        and eax, 0000FFFFh
        cmp eax, 0000FFFFh
        jne @c2
        mov eax, dword
        xor ecx, ecx
        mov cl, byte
        push ecx
        push dword svc52DC
        call _printf
        add esp, 8
        mov word , 0
;---------
@c2:    mov ax, word
        mov ecx, dword
        mov word , ax
        mov ax, word
        mov ecx, dword
        mov word , ax
        mov ax, word
        mov ecx, dword
        mov word , ax
        mov ax, word
        mov ecx, dword
        mov word , ax
        movsx eax, word
        test eax, eax
        je @c4
        mov eax, 1
        jmp @c5
;---------
@c4:    mov eax, 5
;---------
@c5:    pop edi
        pop esi
        pop ebx
        leave
        ret

;******************************************************

err1 db 'Failed to set fan speed',13,10,0

setspeed db 'Setting %s fan to %s',13,10,0

speed  dd off
        dd slow
        dd high

fan dd right
dd 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',13,10,0
svc52DC db 'Smbios: Invalid device (%d)',13,10,0

;******************************************************


This will assemble, but I've not tested it against your source to see if it works.. Partially cause I don't plan on trying out an I8K Dell fan control utility that's been hacked up by some random person, especially when I don't own a Dell. ;) Could be unforsen side effects from running such code and I'm not a very trusting person. But it'll create the .obj you need.
Posted on 2008-04-27 19:10:01 by Synfire