I need a assembly program that converts pounds to kilos and vice versa. In fact, I just stuck badly at the multiplication part as it has to deal with floating point numbers i think.. Don't know much about fl points... so pls help. thanks!
Posted on 2001-03-20 05:01:00 by nash
Here ya go. Contents of Kilo2Lbs.asm

;==========================================================================
.386
.model flat, stdcall
option casemap :none
;==========================================================================
include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\masm32.inc
include \MASM32\INCLUDE\gdi32.inc
include \MASM32\INCLUDE\user32.inc
include \MASM32\INCLUDE\kernel32.inc
include \MASM32\INCLUDE\Comctl32.inc
include \MASM32\INCLUDE\comdlg32.inc

includelib \MASM32\LIB\gdi32.lib
includelib \MASM32\LIB\masm32.lib
includelib \MASM32\LIB\user32.lib
includelib \MASM32\LIB\kernel32.lib
includelib \MASM32\LIB\Comctl32.lib
includelib \MASM32\LIB\comdlg32.lib
;==========================================================================
WinMain      PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc      PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY        PROTO :DWORD,:DWORD
FillBuffer   PROTO :DWORD,:DWORD,:BYTE
Paint_Proc   PROTO :DWORD,:DWORD
EditWndProc  PROTO :DWORD,:DWORD,:DWORD,:DWORD
DoConversion PROTO
;==========================================================================
m2m MACRO M1, M2
push M2
pop  M1
ENDM

return MACRO arg
mov eax, arg
ret
ENDM
;==========================================================================
.const
IDR_MAINICON   equ 500
IDR_MAINMENU   equ 501
IDM_EXIT       equ 1000
IDM_ABOUT      equ 1001
ID_EDIT1       equ 2000
ID_RADIO1      equ 2001
ID_RADIO2      equ 2002
ID_STATIC1     equ 2003
ID_BUTTON1     equ 2004
.data
szClassName    db "BLClass",0
szProgramName  db "Kilo to Pound Converter",0
szAbout        db "Written by Brian Burns 2001",0
szUIFontName   db "MS Sans Serif",0
szToLbs        db "Convert to Pounds",0
szToKilos      db "Convert to Kilos",0
szConvert      db "&Convert Now",0
szLbs          db " Lbs.",0
szKilos        db " Kilos",0
szEditClass    db "EDIT",0
szButtonClass  db "BUTTON",0
szStaticClass  db "STATIC",0
ToLBS          QWORD 2.2046
ToKILO         QWORD 0.4536
lf LOGFONT<>
.data?
CommandLine    dd ?
hWnd           dd ?
hInstance      dd ?
hIcon          dd ?
hUIFont        dd ?
hEdit1         dd ?
hRadio1        dd ?
hRadio2        dd ?
hStatic1       dd ?
hButton1       dd ?
OldEditWndProc dd ?
;==========================================================================
.code
start:
invoke GetModuleHandle,NULL
mov    hInstance,eax
invoke InitCommonControls
invoke WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
invoke ExitProcess,eax
;==========================================================================
WinMain proc hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD

LOCAL wc   :WNDCLASSEX
LOCAL msg  :MSG
LOCAL Wwd  :DWORD
LOCAL Wht  :DWORD
LOCAL Wtx  :DWORD
LOCAL Wty  :DWORD

invoke LoadIcon,hInst,IDR_MAINICON
mov    hIcon,eax
mov    wc.cbSize,sizeof WNDCLASSEX
mov    wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov    wc.lpfnWndProc,offset WndProc
mov    wc.cbClsExtra,NULL
mov    wc.cbWndExtra,NULL
m2m    wc.hInstance,hInst
mov    wc.hbrBackground,COLOR_BTNFACE+1
mov    wc.lpszMenuName,NULL
mov    wc.lpszClassName,offset szClassName
m2m    wc.hIcon,hIcon
invoke LoadCursor,NULL,IDC_ARROW
mov    wc.hCursor,eax
m2m    wc.hIconSm,hIcon
invoke RegisterClassEx,addr wc
mov    Wwd,360
mov    Wht,160
invoke GetSystemMetrics,SM_CXSCREEN
invoke TopXY,Wwd,eax
mov    Wtx,eax
invoke GetSystemMetrics,SM_CYSCREEN
invoke TopXY,Wht,eax
mov    Wty,eax
invoke CreateWindowEx,WS_EX_LEFT,addr szClassName,addr szProgramName,
                      WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,NULL,NULL,
                      hInst,NULL
mov    hWnd,eax
invoke LoadMenu,hInst,IDR_MAINMENU
invoke SetMenu,hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
   invoke GetMessage,addr msg,NULL,0,0
   .break .if (!eax)
   invoke TranslateMessage,addr msg
   invoke DispatchMessage,addr msg
.endw
return msg.wParam

WinMain endp
;=========================================================================
Posted on 2001-03-20 11:22:00 by anon