+ All Categories
Home > Documents > Td Win32asm 510.Asm

Td Win32asm 510.Asm

Date post: 10-Apr-2016
Category:
Upload: z4rm4r
View: 7 times
Download: 1 times
Share this document with a friend
Description:
TestDepartment assembly programming low level
35
td_win32asm_510.asm ;============================================================================== ; Test Department's WINDOWS 32 BIT x86 ASSEMBLY example 510 ;============================================================================== ;============================================================================== ; ==> Part 510 : ;------------------------------------------------------------------------------ ;Matrix, an experience of a tolerance database memory ... and crazyness ... ;This is my poor and very dilettante try to program a synthetic intelligence. ;And isn't that bad enough; it's a ported program from my ATARI 8 Bit computer. ;Believe me, it's highly enhanced. ;Well, for a proper work you MUST (!) respect the rules. ;I know it's hard for Anarchist's like us. ; ;LEARNING : ;----------- ; 1. Only standard letters are allowed, no space, no other signs. ; 2. One question - One answer (!), minimum 3 letters, maximum 10 letters. ; 3. No problem to enter the same Question / Answer pair again. ; 4. You can not (!) delete a previous entry, because memory organization. ; 5. Input Example: ; tree - plant ; first entry ; tree - plant ; reEnter is OK ; grass - plant ; OK ; plant - tree ; Ok ; tree - wood ; this is wrong, tree - plant before ; highway - traffic ; OK ; high - mountain ; Bad entry ; mercedes- automobile ; OK ; ; 6. Silly inputs like abcd - abfrt etc. will destroy the memory matrix ! ; highway-traffic / high-mountain (high in both questions, same location) ; do not work proper and could destroy parts of the memory matrix. ; Best results are avaible if your question words are maximum different ! ; The summary of 0 Bits in the matrix most used quadrant must be greater ; than the 1 Bits. ; 7. You see it's a poor program, take a look into the file theory.txt. ; 8. Memory increase as long as you insert more Question / Answer pairs. ; The drawback is that memory becomes more foggy for every pair you insert. ; 9. Please do not forget: One Question - One Answer !!! ; ;INQUIRY : ;---------- ;You can ask every question, if the answer was learned before. ;Because this memory is tolerance, also tolerance results are avaible. ;Tolerance means that you can ask for "gkass" and the answer will be ;also "plant" or something simular ! ; ;MENU : ;------- ;Clicking Matrix in the menu bar you can load and save the memory matrix. ;You can also RESET your baby, any memory is lost ... ; Page 1
Transcript
Page 1: Td Win32asm 510.Asm

td_win32asm_510.asm;==============================================================================; Test Department's WINDOWS 32 BIT x86 ASSEMBLY example 510;==============================================================================

;==============================================================================; ==> Part 510 :;------------------------------------------------------------------------------;Matrix, an experience of a tolerance database memory ... and crazyness ...;This is my poor and very dilettante try to program a synthetic intelligence.;And isn't that bad enough; it's a ported program from my ATARI 8 Bit computer.;Believe me, it's highly enhanced.;Well, for a proper work you MUST (!) respect the rules.;I know it's hard for Anarchist's like us.;;LEARNING :;-----------; 1. Only standard letters are allowed, no space, no other signs.; 2. One question - One answer (!), minimum 3 letters, maximum 10 letters.; 3. No problem to enter the same Question / Answer pair again.; 4. You can not (!) delete a previous entry, because memory organization.; 5. Input Example:; tree - plant ; first entry; tree - plant ; reEnter is OK; grass - plant ; OK; plant - tree ; Ok; tree - wood ; this is wrong, tree - plant before; highway - traffic ; OK; high - mountain ; Bad entry; mercedes- automobile ; OK;; 6. Silly inputs like abcd - abfrt etc. will destroy the memory matrix !; highway-traffic / high-mountain (high in both questions, same location); do not work proper and could destroy parts of the memory matrix.; Best results are avaible if your question words are maximum different !; The summary of 0 Bits in the matrix most used quadrant must be greater; than the 1 Bits.; 7. You see it's a poor program, take a look into the file theory.txt.; 8. Memory increase as long as you insert more Question / Answer pairs.; The drawback is that memory becomes more foggy for every pair you insert.; 9. Please do not forget: One Question - One Answer !!!;;INQUIRY :;----------;You can ask every question, if the answer was learned before.;Because this memory is tolerance, also tolerance results are avaible.;Tolerance means that you can ask for "gkass" and the answer will be;also "plant" or something simular !;;MENU :;-------;Clicking Matrix in the menu bar you can load and save the memory matrix.;You can also RESET your baby, any memory is lost ...;

Page 1

Page 2: Td Win32asm 510.Asm

td_win32asm_510.asm;Ideas:;-------;Read the file theory.txt.;Thinking about a 3D memory matrix which will be much more exact ...;Perhaps it's possible to use more vectors and create a 3D memory matrix.;Hm, yes with more (32) matrix layer's, bah forget it...;;Ou, I must go, my PC is talking to me ...

;==============================================================================; Assembler directives;------------------------------------------------------------------------------.386 ; specifies the processor our program want run on.Model Flat ,StdCall ; Flat for Win9x (32 Bit), Calling Conventionoption casemap:none ; case sensitive !

;==============================================================================; Include all files where API functins resist you want use, set correct path;------------------------------------------------------------------------------include D:\Masm32\include\windows.incincludelib kernel32.libincludelib user32.libincludelib gdi32.libincludelib comdlg32.lib

;==============================================================================; Declaration of used API functions,take a look into WIN32.HLP and *.inc files;------------------------------------------------------------------------------GetModuleHandleA PROTO :DWORDLoadIconA PROTO :DWORD,:DWORDLoadCursorA PROTO :DWORD,:DWORDCreateSolidBrush PROTO :DWORDRegisterClassExA PROTO :DWORDCreateWindowExA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD, :DWORD,:DWORD,:DWORD,:DWORD,:DWORDShowWindow PROTO :DWORD,:DWORDUpdateWindow PROTO :DWORDGetMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORDTranslateMessage PROTO :DWORDDispatchMessageA PROTO :DWORDPostQuitMessage PROTO :DWORDDefWindowProcA PROTO :DWORD,:DWORD,:DWORD,:DWORDExitProcess PROTO :DWORDSetFocus PROTO :DWORDDrawEdge PROTO :DWORD,:DWORD,:DWORD,:DWORDFillRect PROTO :DWORD,:DWORD,:DWORDLoadBitmapA PROTO :DWORD,:DWORDSendMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORDBeginPaint PROTO :DWORD,:DWORDSelectObject PROTO :DWORD,:DWORDSetBkColor PROTO :DWORD,:DWORDSetTextColor PROTO :DWORD,:DWORDTextOutA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD

Page 2

Page 3: Td Win32asm 510.Asm

td_win32asm_510.asmEndPaint PROTO :DWORD,:DWORDGetWindowTextA PROTO :DWORD,:DWORD,:DWORDSetWindowTextA PROTO :DWORD,:DWORDMessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD

GetOpenFileNameA PROTO :DWORDGetSaveFileNameA PROTO :DWORDCreateFileA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORDGetFileSize PROTO :DWORD,:DWORDReadFile PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORDWriteFile PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORDCloseHandle PROTO :DWORD

;==============================================================================; .const = the constants area starts here, constants are defined and fixed;------------------------------------------------------------------------------.const; - Parameter MAIN WINDOW CallBack Procedure ( API=RegisterClassExA ) -WP1_CallBack equ [ebp+4] ;return addressWP1_hWnd equ [ebp+8] ;handle of window who receives messageWP1_uMsg equ [ebp+12] ;the message numberWP1_wParam equ [ebp+16] ;extra info about the messageWP1_lParam equ [ebp+20] ;extra info about the message

;==============================================================================; .Data = the data area starts here, datas are defined but not fixed;------------------------------------------------------------------------------.DataIconName db "TDIcon",0 ;icon name in rc fileMenuName db "TDMenu",0 ;menu name in rc fileClass db "TDWinClass",0 ;name of window classTitel db "TDTitel",0 ;static titel bitmap in rcWindowName db "Test Department - http://surf.to/TestD",0 ;BUTTON_Class db "BUTTON",0 ;name of window classSTATIC_Class db "STATIC",0 ;name of window classEDIT_Class db "EDIT",0 ;name of window classMB1Titel db "INPUT ERROR",0 ;MB1Text db "1. only standard letters are allowed.",13,10 ; db "2. no space, no other signs.",13,10 ; db "3. input must contain 3-10 letters.",0 ;MB2Titel db "RESET MATRIX",0 ;MB2Text db "Sure to reset the matrix, any memory is lost ?",0;MB3Titel db "I/O ERROR",0 ;MB3Text db "Error while loading / saving the matrix.",0 ;HelpText db "Matrix, an example of tolerance database memory.",13,10; db "-----------------------------------------" db "-----------------------------------------",13,10; db "Learning:",13,10; db " - Only standard letters are allowed.",13,10; db " - Minimum 3 letters, maximum 10 letters.",13,10; db " - One question - One answer !!!",13,10; db " - Silly Inputs like abcdv - abfrtj destroy memory.",13,10; db " Also highway-traffic / high-mountain don't work.",13,10;

Page 3

Page 4: Td Win32asm 510.Asm

td_win32asm_510.asm db " 'high' in both pairs at the same location.",13,10; db " - The best results are avaible if your question",13,10; db " words are maximum different.",13,10; db " - Memory grows inserting Question / Answer",13,10; db " pairs. The drawback is that memory becomes",13,10; db " more foggy for every pair you insert.",13,10; db "Example:",13,10; db " - tree : plant ==> OK",13,10; db " - tree : plant ==> OK, ReEnter",13,10; db " - grass : plant ==> OK",13,10; db " - tree : wood ==> ERROR",13,10; db " - highway : traffic ==> OK",13,10; db " - high : mountain ==> BAD ENTRY",13,10; db " - mercedes : automobile ==> OK",13,10; db "Inquiry:",13,10; db " - You can ask any question if the answer was",13,10; db " learned before. Because memory is tolerance",13,10; db " also tolerance results are avaible.",13,10; db " - Tolerance means that you can ask for 'gkass'",13,10; db " and the answer will be also 'plant' or something",13,10; db " simular.",13,10; db "Matrix:",13,10; db " - Load, Save or Reset the Memory Matrix.",0; LearnTitel db "Learning",0InquiryTitel db "Inquiry",0Question db "Question",0Answer db "Answer",0QMark db 2EhQuestionBuffer db "0123456789",0AnswerBuffer db "0123456789",0Intelligence db " ",0 ;answer we are waiting forFileFilt db "Matrix Files",0,"*.mat",0,0 ;file filterFileDefExt db "mat",0 ;default file extensionLoadFileT db "LOAD File, choose a file",0 ;titelSaveFileT db "SAVE File, choose a file",0 ;titel

; - ASCII Sign ( INDEX, hex values of ascii characters ) -Sign_Index db 61h,62h,63h,64h,65h,66h,67h,68h,69h,6Ah,6Bh,6Ch,6Dh db 6Eh,6Fh,70h,71h,72h,73h,74h,75h,76h,77h,78h,79h,7Ah

; - ASCII Sign ( TABLE, coded ) -Sign_A db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,31h ;Sign_B db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,31h,20h ;Sign_C db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;

Page 4

Page 5: Td Win32asm 510.Asm

td_win32asm_510.asm db 20h,20h,20h,20h,20h,31h,20h,20h ;Sign_D db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,31h,20h,20h,20h ;Sign_E db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,31h,20h,20h,20h,20h ;Sign_F db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,31h,20h,20h,20h,20h,20h ;Sign_G db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,31h,20h,20h,20h,20h,20h,20h ;Sign_H db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 31h,20h,20h,20h,20h,20h,20h,20h ;Sign_I db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,31h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_J db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,31h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_K db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,31h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_L db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,31h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_M db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,31h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_N db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,31h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_O db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,31h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_P db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 31h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;

Page 5

Page 6: Td Win32asm 510.Asm

td_win32asm_510.asmSign_Q db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,31h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_R db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,31h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_S db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,31h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_T db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,31h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_U db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,31h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_V db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,31h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_W db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,31h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_X db 20h,20h,20h,20h,20h,20h,20h,20h ; db 31h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_Y db 20h,20h,20h,20h,20h,20h,20h,31h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;Sign_Z db 20h,20h,20h,20h,20h,20h,31h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ; db 20h,20h,20h,20h,20h,20h,20h,20h ;

align 4; - RECT Structure ( API=DrawEdge ) - Learning arearcLearn_left dd 160h ;RECT,x-coordinate upper-left cornerrcLearn_top dd 044h ;RECT,y-coordinate upper-left cornerrcLearn_right dd 272h ;RECT,x-coordinate lower-right cornerrcLearn_bottom dd 0A2h ;RECT,y-coordinate lower-right corner

align 4; - RECT Structure ( API=DrawEdge ) - Inquiry arearcInquiry_left dd 160h ;RECT,x-coordinate upper-left cornerrcInquiry_top dd 0ACh ;RECT,y-coordinate upper-left cornerrcInquiry_right dd 272h ;RECT,x-coordinate lower-right corner

Page 6

Page 7: Td Win32asm 510.Asm

td_win32asm_510.asmrcInquiry_bottom dd 20Ah ;RECT,y-coordinate lower-right corner

;==============================================================================; .Data? = the data? area starts here, not defined and not fixed;------------------------------------------------------------------------------.data?blackbrush dd ? ;background color (black)counter0 dd ? ;QALength dd ? ;Level dd ? ;leveltemp dd ? ;temp_ycoordinate dd ? ;temp_Result dd ? ;tolerance dd ? ;tolerance levelMatrix_RAM db 19000h dup(?);matrix ram, 320*320Load_Buffer db 19000h dup(?);temp load buffertemp_Question db 140h dup(?) ;question mask, 320temp_Answer db 140h dup(?) ;answer masktemp_Column db 280h dup(?) ;column bufferLoadFileN db 104h dup(?) ;buffer load filenameSaveFileN db 104h dup(?) ;buffer save filename

STATIC_HelphWnd dd ? ;handle, quick help windowSTATIC_TitelhWnd dd ? ;handle, title graphic windowEDIT1_WorkhWnd dd ? ;learning questionEDIT2_WorkhWnd dd ? ;learning answerBUTTON_LearnhWnd dd ? ;handle, learn button windowEDIT3_WorkhWnd dd ? ;inquiry questionBUTTON_InquiryhWnd dd ? ;handle, inquiry button windowSTATIC_Inquiry0hWnd dd ? ;inquiry answer±0 windowSTATIC_Inquiry1hWnd dd ? ;inquiry answer-1 windowSTATIC_Inquiry2hWnd dd ? ;inquiry answer-2 windowSTATIC_Inquiry3hWnd dd ? ;inquiry answer-3 windowSTATIC_Inquiry4hWnd dd ? ;inquiry answer-4 windowSTATIC_Inquiry5hWnd dd ? ;inquiry answer-5 windowSTATIC_Inquiry6hWnd dd ? ;inquiry answer-6 windowSTATIC_Inquiry7hWnd dd ? ;inquiry answer-7 windowBUTTON_LearnhObject dd ? ;handle, learn bitmapBUTTON_InquiryhObject dd ? ;handle, inquiry bitmapFileHandle dd ? ;file handle for read/write fileFileReturn dd ? ;needed for read/write fileErrorFlag dd ? ;

align 4; - WndClassEx Structure ( API=RegisterClassExA ) -cbSize dd ? ;size in bytes of this structurestyle dd ? ;window stylelpfnWndProc dd ? ;address of user proc functioncbclsExtra dd ? ;extra bytes to allocate set to 0cbWndExtra dd ? ;extra bytes class directive, rc filehInstance dd ? ;program handle(API=GetModuleHandleA)hIcon dd ? ;handle of icon (API=LoadIconA)hcursor dd ? ;handle of cursor (API=LoadCursor)

Page 7

Page 8: Td Win32asm 510.Asm

td_win32asm_510.asmhbrBackground dd ? ;background color, 0=transparentlpszMenuName dd ? ;name of menu class in resource filelpszClassName dd ? ;name of windows this window classhIconSm dd ? ;iconhandle 0=search in resource filehdcDest dd ? ;handle of dest. device context

align 4; - Msg Structure ( API=GetMessageA ) - member POINT = POINT structurehWnd dd ? ;handle of window who receives messagemessage dd ? ;the message numberwParam dd ? ;extra info about the messagelParam dd ? ;extra info about the messagetime dd ? ;time the message was postedxpt dd ? ;cursor x-position, POINT strucypt dd ? ;cursor x-position, POINT struc

align 4; - Paint Structure ( API=BeginPaint ) - member rcPaint = RECT structurehdc dd ? ;id, display DC used for painting fErase dd ? ;must background must be erasedrcPaint_left dd ? ;RECT,x-coordinate upper-left cornerrcPaint_top dd ? ;RECT,y-coordinate upper-left cornerrcPaint_right dd ? ;RECT,x-coordinate lower-right cornerrcPaint_bottom dd ? ;RECT,y-coordinate lower-right cornerfRestore dd ? ;reserved, used by Windows fIncUpdate dd ? ;reserved, used by Windows rgbReserved db 20h dup (?) ;reserved, used by Windows

align 4; - OPENFILENAME Structure ( API=GetOpenFileNameA / GetOpenSaveFileNameA ) -lStructSize dd ? ;the length in bytes of structure hWndOwner dd ? ;Id window that owns dialog box hInstance1 dd ? ;handle, our program idlpstrFilter dd ? ;pointer to string + filterlpstrCustomFilter dd ? ;pointer to user defined filternMaxCustFilter dd ? ;size bytes/characters of abovenFilterIndex dd ? ;filter index of lpstrFilter lpstrFile dd ? ;pointer initialize filename, 0=nonMaxFile dd ? ;size bytes/characters of abovelpstrFileTitle dd ? ;pointer title of the selected filenMaxFileTitle dd ? ;size of the lpstrFileTitle buffer lpstrInitialDir dd ? ;pointer string init file dir,0=defaultlpstrTitle dd ? ;pointer title of the box Flags dd ? ;the dialog box creation flags nFileOffset dw ? ;offset filename in string lpstrFile nFileExtension dw ? ;offset extension in string lpstrFile lpstrDefExt dd ? ;pointer default extension of file lCustData dd ? ;? lpfnHook dd ? ;? used if flag is OFN_ENABLETEMPLATElpTemplateName dd ? ;? used if flag is OFN_ENABLETEMPLATE

;==============================================================================; .CODE = our code area starts here Main = label of our program code

Page 8

Page 9: Td Win32asm 510.Asm

td_win32asm_510.asm;------------------------------------------------------------------------------.CodeMain:

;==============================================================================; Always get your program ID first (API=GetModuleHandleA);------------------------------------------------------------------------------push 0h ;lpModuleHandle, 0=get program handlecall GetModuleHandleA ;- API Function -mov hInstance,eax ;return value in eax=handle of program

;==============================================================================; Init the program variables.;------------------------------------------------------------------------------call My_InitPrg ;- Subroutine -

;==============================================================================; The API function "RegisterClassExA" registers a window class.; This API needs a "WNDCLASSEX" structure so we fill it with correct values.;------------------------------------------------------------------------------mov cbSize,30h ;size in bytes of WNDCLASSEX structuremov style,3h ;window stylemov lpfnWndProc,OFFSET WP1 ;address of user lpfnWndProc functionmov cbclsExtra,0h ;extra bytes to allocate set to 0mov cbWndExtra,0h ;class directive in rc file;------------------------------------------------------------------------------; API "CreateSolidBrush" creates a logical brush with the specified solid color;------------------------------------------------------------------------------push 00000000h ;crColor, brush color valuecall CreateSolidBrush ;- API Function -mov hbrBackground,eax ;background colormov blackbrush,eax ;store brush for future usemov lpszMenuName,OFFSET MenuName;menu name in resource file,0=no menumov lpszClassName,OFFSET Class ;name of windows classmov hIconSm,0h ;iconhandle 0=search in rc file;------------------------------------------------------------------------------; API "LoadIconA" loads an icon defined in the resource file and stores the; handle in the "WNDCLASSEX" structure;------------------------------------------------------------------------------push OFFSET IconName ;icon-string or icon resource idpush hInstance ;our program handlecall LoadIconA ;- API Function -mov hIcon,eax ;store handle of newly loaded icon;------------------------------------------------------------------------------; API "LoadCursorA" loads a default system cursor, in this case we must set; hInstance to 0 and lpCursorName to a default system cursor value, here 32512; Then we store the cursor handle in the "WNDCLASSEX" structure;------------------------------------------------------------------------------push 32512 ;lpCursorName, default value in dezimalpush 0h ;hInstance, 0=default system cursorcall LoadCursorA ;- API Function -mov hcursor,eax ;store handle of the cursor;------------------------------------------------------------------------------

Page 9

Page 10: Td Win32asm 510.Asm

td_win32asm_510.asm; Now, after filled the "WNDCLASSEX" structure we call API "RegisterClassEx";------------------------------------------------------------------------------push OFFSET cbSize ;pointer to WNDCLASSEX structurecall RegisterClassExA ;- API Function -

;==============================================================================; API "CreateWindowExA" creates an overlapped, pop-up, or child window with an; extended style. The return value in EAX is the handle of the new window.; This API sends a WM_CREATE message to the window procedure (WP1).;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 0h ;hMenu, handle window menu 0=class menupush 0h ;hWndParent, handle parent window 0=nopush 00000248h ;intnHeight, window height pixelpush 00000280h ;intnWidth, window width pixelpush 00000000h ;inty, vertical position windowpush 00000040h ;intx, horizontal position windowpush 04CA0000h ;dwStyle, look into WIN32.HLPpush OFFSET WindowName ;lpWindowName, pointer to window namepush OFFSET Class ;lpClassName, pointer to class namepush 300h ;dwExStyle, extra window style 0=nocall CreateWindowExA ;- API Function -mov hWnd,eax ;hwnd,return value=handle of window

;==============================================================================; API "ShowWindow" function sets the specified window's show state. ;------------------------------------------------------------------------------push 1h ;nCmdShow, show state 1=SW_SHOWNORMALpush hWnd ;hwnd, handle of windowcall ShowWindow ;- API Function -

;==============================================================================; API "UpdateWindow" updates the area of the specified window by sending a; WM_PAINT message to the window if the window's update region is not empty.;------------------------------------------------------------------------------push hWnd ;hwnd, handle of windowcall UpdateWindow ;- API Function -

LoopGetMessage:;==============================================================================; API "GetMessageA" retrieves a message + places it in the specified structure.;------------------------------------------------------------------------------push 0h ;wMsgFilterMax, highest message valuepush 0h ;wMsgFilterMin, lowest message valuepush 0h ;hWnd, handle of window who gets msg.push OFFSET hWnd ;lpMsg, pointer to MSG structurecall GetMessageA ;- API Function -cmp eax,0h ;check if return value=0 (exit)je ExitPrg ;if return value is 0 goto LABEL

;==============================================================================; API "TranslateMessage" translates virtual-key messages in character messages

Page 10

Page 11: Td Win32asm 510.Asm

td_win32asm_510.asm;------------------------------------------------------------------------------push OFFSET hWnd ;lpMSG, pointer to msg structurecall TranslateMessage ;- API Function - keyboard code

;==============================================================================; API "DispatchMessageA" function dispatches a message to a window procedure.;------------------------------------------------------------------------------push OFFSET hWnd ;lpMSG, pointer to msg structurecall DispatchMessageA ;- API Function -jmp LoopGetMessage ;check for message again, goto LABEL

ExitPrg:;==============================================================================; Next we terminate our program (API=ExitProcess);------------------------------------------------------------------------------push hInstance ;push our programm handle to exitcall ExitProcess ;- API Function -

;##############################################################################; The Window Procedure (API=RegisterClassExA) for this registered window.;------------------------------------------------------------------------------WP1:push ebp ;create stack framemov ebp,esp ;pushad ;push all register to the stack

mov eax,WP1_uMsg ;move the message number to eax;==============================================================================; WM_CREATE (value=01h) message received ?;------------------------------------------------------------------------------WP1_uMsg_01h:cmp eax,1h ;check if WM_CREATE message recievedjne WP1_uMsg_02h ;if not goto LABELcall My_WM_CREATE ;- Subroutine - init all windowscall My_SetFocus ;- Subroutine -jmp WP1_return ;

;==============================================================================; WM_DESTROY (value=02h) message received ?;------------------------------------------------------------------------------WP1_uMsg_02h:cmp eax,2h ;check if value=2h (WM_DESTROY)jne WP1_uMsg_0Fh ;if not 2h go to LABELcall My_CleanSystem ;- SubRoutine -;------------------------------------------------------------------------------; API "PostQuitMessage" indicates to Windows a request to terminate;------------------------------------------------------------------------------push 0h ;nExitCode, exit code=wParamcall PostQuitMessage ;- API Function -popad ;pop all register back from stackxor eax,eax ;set eax to 0 to exit our programmov esp,ebp ;delete stack framepop ebp ;

Page 11

Page 12: Td Win32asm 510.Asm

td_win32asm_510.asmret 10h ;return and clear stack

;==============================================================================; WM_PAINT (value=0Fh) message, used to repaint the window area.;------------------------------------------------------------------------------WP1_uMsg_0Fh:cmp eax,0Fh ;check if WM_PAINT message recievedjne WP1_uMsg_111h ;if not goto labelcall My_PaintWorkArea ;- Subroutine - paint working areajmp WP1_return ;

;==============================================================================; WM_COMMAND (value=111h) message recieved ?;------------------------------------------------------------------------------WP1_uMsg_111h:cmp eax,111h ;check if WM_COMMAND message recievedjne WP1_uMsg_112h ;if not goto labelWP1_wParam_20h:;------------------------------------------------------------------------------; "Reset Matrix" in the menu bar clicked ?;------------------------------------------------------------------------------mov eax,WP1_wParam ;extra info about the message in axcmp ax,20h ;check if "Reset Matrix" in menu clickedjne WP1_wParam_21h ;if not goto LABEL;------------------------------------------------------------------------------; API "MessageBoxA" creates a message box, are you sure to reset the matrix ?;------------------------------------------------------------------------------push 4h ;uType, style, 4=MB_YESNO Buttonpush OFFSET MB2Titel ;lpCaption,pointer to title textpush OFFSET MB2Text ;lpText,pointer to text message boxpush WP1_hWnd ;handle of owner window 0=no ownercall MessageBoxA ;- API Function -cmp eax,6h ;if return value=6h (IDYES) reset matrixjne WP1_return ;if return value=7h (IDNO) goto LABELcall My_ClearQA ;- Subroutine -call My_ResetMatrix ;- Subroutine -jmp WP1_return ;

WP1_wParam_21h:;------------------------------------------------------------------------------; "Load Matrix" in the menu bar clicked ?;------------------------------------------------------------------------------mov eax,WP1_wParam ;extra info about the message in axcmp ax,21h ;check if "Load Matrix" in menu clickedjne WP1_wParam_22h ;if not goto LABELcall My_LoadMatrix ;- Subroutine -cmp ErrorFlag,1h ;je IO_Error ;;------------------------------------------------------------------------------; This is my small test if the loaded file is a correct *.mat file.;------------------------------------------------------------------------------mov ecx,0h ;test data's in the load buffermov ebx,OFFSET Load_Buffer ;

Page 12

Page 13: Td Win32asm 510.Asm

td_win32asm_510.asmTestData:mov eax,3120h ;cmp [ebx],al ;je TestNext ;cmp [ebx],ah ;jne IO_Error ;TestNext:inc ebx ;inc ecx ;cmp ecx,19000h ;jne TestData ;mov ecx,0h ;copy datas from load buffer into matrixmov ebx,OFFSET Load_Buffer ;mov edx,OFFSET Matrix_RAM ;CopyNext:mov al,[ebx] ;mov [edx],al ;inc ebx ;inc edx ;inc ecx ;cmp ecx,19000h ;jne CopyNext ;call My_ClearQA ;- Subroutine -jmp WP1_return ;IO_Error:;------------------------------------------------------------------------------; API "MessageBoxA" creates a message box, we can only click OK;------------------------------------------------------------------------------push 0h ;uType, style, 0=MB_OK Buttonpush OFFSET MB3Titel ;lpCaption,pointer to title textpush OFFSET MB3Text ;lpText,pointer to text message boxpush WP1_hWnd ;handle of owner window 0=no ownercall MessageBoxA ;- API Function -jmp WP1_return ;

WP1_wParam_22h:;------------------------------------------------------------------------------; "Save Matrix" in the menu bar clicked ?;------------------------------------------------------------------------------cmp ax,22h ;check if "Save Matrix" in menu clickedjne WP1_wParam_500h ;if not goto LABELcall My_SaveMatrix ;- Subroutine -cmp ErrorFlag,1h ;je IO_Error ;jmp WP1_return ;

WP1_wParam_500h:;------------------------------------------------------------------------------; Learning button clicked ?;------------------------------------------------------------------------------cmp ax,500h ;check if button ID=0500h clickedjne WP1_wParam_501h ;if not 1h goto LABELcall My_ClearQA ;- Subroutine -

Page 13

Page 14: Td Win32asm 510.Asm

td_win32asm_510.asm;------------------------------------------------------------------------------; API "GetWindowTextA" copies the text of the specified window's title bar.;------------------------------------------------------------------------------push 0Bh ;nMaxCount, max number of chars to copypush OFFSET QuestionBuffer ;lpString, address of buffer for textpush EDIT1_WorkhWnd ;hWnd, handle of window or controlcall GetWindowTextA ;- API Function -mov QALength,eax ;cmp eax,3h ;jae LQLength_OK ;call My_MessageBoxA ;- Subroutine -jmp WP1_return ;LQLength_OK:mov esi,OFFSET QuestionBuffer ;mov edi,OFFSET temp_Question ;call My_GetQA ;- Subroutine -cmp eax,0h ;check flag, correct input ?je LQ_OK ;call My_MessageBoxA ;- Subroutine -jmp WP1_return ;LQ_OK:;------------------------------------------------------------------------------; API "GetWindowTextA" copies the text of the specified window's title bar.;------------------------------------------------------------------------------push 0Bh ;nMaxCount, max number of chars to copypush OFFSET AnswerBuffer ;lpString, address of buffer for textpush EDIT2_WorkhWnd ;hWnd, handle of window or controlcall GetWindowTextA ;- API Function -mov QALength,eax ;cmp eax,3h ;check string length, correct input ?jae LALength_OK ;call My_MessageBoxA ;- Subroutine -jmp WP1_return ;LALength_OK:mov esi,OFFSET AnswerBuffer ;mov edi,OFFSET temp_Answer ;call My_GetQA ;- Subroutine -cmp eax,0h ;check flag, correct input ?je LA_OK ;call My_MessageBoxA ;- Subroutine -jmp WP1_return ;LA_OK:call My_PutAnswer ;- Subroutine -jmp WP1_return ;

WP1_wParam_501h:;------------------------------------------------------------------------------; Inquiry button clicked ?;------------------------------------------------------------------------------cmp ax,501h ;check if button ID=0501h clickedjne WP1_return ;if not 1h goto LABELcall My_ClearQA ;- Subroutine -;------------------------------------------------------------------------------

Page 14

Page 15: Td Win32asm 510.Asm

td_win32asm_510.asm; API "GetWindowTextA" copies the text of the specified window's title bar.;------------------------------------------------------------------------------push 0Bh ;nMaxCount, max number of chars to copypush OFFSET QuestionBuffer ;lpString, address of buffer for textpush EDIT3_WorkhWnd ;hWnd, handle of window or controlcall GetWindowTextA ;- API Function -mov QALength,eax ;cmp eax,3h ;check string length, correct input ?jae IQLength_OK ;call My_MessageBoxA ;- Subroutine -jmp WP1_return ;IQLength_OK:mov esi,OFFSET QuestionBuffer ;mov edi,OFFSET temp_Question ;call My_GetQA ;- Subroutine -cmp eax,0h ;check flag, correct input ?je IQ_OK ;call My_MessageBoxA ;- Subroutine -jmp WP1_return ;IQ_OK:mov tolerance,0h ;call My_FindAnswer ;- Subroutine -;------------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.;------------------------------------------------------------------------------push OFFSET Intelligence ;lpsz, address of stringpush STATIC_Inquiry0hWnd ;hwnd, handle of window or controlcall SetWindowTextA ;- API Function -mov tolerance,1h ;call My_FindAnswer ;- Subroutine -;------------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.;------------------------------------------------------------------------------push OFFSET Intelligence ;lpsz, address of stringpush STATIC_Inquiry1hWnd ;hwnd, handle of window or controlcall SetWindowTextA ;- API Function -mov tolerance,2h ;call My_FindAnswer ;- Subroutine -;------------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.;------------------------------------------------------------------------------push OFFSET Intelligence ;lpsz, address of stringpush STATIC_Inquiry2hWnd ;hwnd, handle of window or controlcall SetWindowTextA ;- API Function -mov tolerance,3h ;call My_FindAnswer ;- Subroutine -;------------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.;------------------------------------------------------------------------------push OFFSET Intelligence ;lpsz, address of stringpush STATIC_Inquiry3hWnd ;hwnd, handle of window or controlcall SetWindowTextA ;- API Function -mov tolerance,4h ;

Page 15

Page 16: Td Win32asm 510.Asm

td_win32asm_510.asmcall My_FindAnswer ;- Subroutine -;------------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.;------------------------------------------------------------------------------push OFFSET Intelligence ;lpsz, address of stringpush STATIC_Inquiry4hWnd ;hwnd, handle of window or controlcall SetWindowTextA ;- API Function -mov tolerance,5h ;call My_FindAnswer ;- Subroutine -;------------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.;------------------------------------------------------------------------------push OFFSET Intelligence ;lpsz, address of stringpush STATIC_Inquiry5hWnd ;hwnd, handle of window or controlcall SetWindowTextA ;- API Function -mov tolerance,6h ;call My_FindAnswer ;- Subroutine -;------------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.;------------------------------------------------------------------------------push OFFSET Intelligence ;lpsz, address of stringpush STATIC_Inquiry6hWnd ;hwnd, handle of window or controlcall SetWindowTextA ;- API Function -mov tolerance,7h ;call My_FindAnswer ;- Subroutine -;------------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.;------------------------------------------------------------------------------push OFFSET Intelligence ;lpsz, address of stringpush STATIC_Inquiry7hWnd ;hwnd, handle of window or controlcall SetWindowTextA ;- API Function -jmp WP1_return ;

;==============================================================================; WM_SYSCOMMAND (value=112h) message recieved ?;------------------------------------------------------------------------------WP1_uMsg_112h:cmp eax,112h ;check if WM_COMMAND message recievedjne WP1_return ;if not goto labelmov eax,WP1_wParam ;extra info about the messagecmp eax,0F060h ;SC_CLOSE=0F060h received ?jne WP1_return ;call My_CleanSystem ;- SubRoutine -jmp WP1_return

;==============================================================================; API "DefWindowProcA" calls the window procedure to provide default processing; for any window messages that an application does not process.; This function ensures that every message is processed.; It is called with the same parameters received by the window procedure.;------------------------------------------------------------------------------WP1_return:popad ;pop all register from stack

Page 16

Page 17: Td Win32asm 510.Asm

td_win32asm_510.asmpush WP1_lParam ;extra info about the messagepush WP1_wParam ;extra info about the messagepush WP1_uMsg ;the message numberpush WP1_hWnd ;handle of window who receives messagecall DefWindowProcA ;- API Function -mov esp,ebp ;delete stack framepop ebp ;ret 10h ;return and clear stack;##############################################################################

;******************************************************************************; My own subroutine(s) for a compacter code resist here ...;------------------------------------------------------------------------------My_CleanSystem:

ret

My_InitPrg:;==============================================================================; Here I init the program.;------------------------------------------------------------------------------mov esi,0h ;init Matrix_RAMmov al,20h ;mov ebx,OFFSET Matrix_RAM ;Init1:mov [ebx],al ;inc ebx ;inc esi ;cmp esi,19000h ;jne Init1 ;mov esi,0h ;init buffer'smov ax,0020h ;mov ebx,OFFSET temp_Question ;mov ecx,OFFSET temp_Answer ;mov edx,OFFSET temp_Column ;Init2:mov [ebx],al ;mov [ecx],al ;mov [edx],ah ;mov [edx+1],ah ;inc ebx ;inc ecx ;inc edx ;inc edx ;inc esi ;cmp esi,140h ;jne Init2 ;ret ;

My_MessageBoxA:;==============================================================================; API "MessageBoxA" creates a message box, we can only click OK;------------------------------------------------------------------------------

Page 17

Page 18: Td Win32asm 510.Asm

td_win32asm_510.asmpush 0h ;uType, style, 0=MB_OK Buttonpush OFFSET MB1Titel ;lpCaption,pointer to title textpush OFFSET MB1Text ;lpText,pointer to text message boxpush WP1_hWnd ;handle of owner window 0=no ownercall MessageBoxA ;- API Function -ret ;

My_ClearQA:;==============================================================================; My routine to clear my temp Question / Answer buffer.;------------------------------------------------------------------------------mov edx,0h ;mov ah,20h ;Clear_QA:mov ebx,OFFSET temp_Question ;add ebx,edx ;mov ecx,OFFSET temp_Answer ;add ecx,edx ;mov [ebx],ah ;mov [ecx],ah ;inc edx ;cmp edx,140h ;jne Clear_QA ;ret ;

My_GetQA:;==============================================================================; My routine to get a Question / Answer and code it into a proper format.;------------------------------------------------------------------------------mov counter0,0h ;NextChar:mov edx,0h ;mov ebx,esi ;ESI = OFFSET Question / Answer bufferadd ebx,counter0 ;mov ecx,OFFSET Sign_Index ;hex values of characterdec ecx ;dec edx ;MaxSign:inc edx ;cmp edx,1Ah ;jae Input_Error ;ERRORadd ecx,1h ;mov al,[ebx] ;mov ah,[ecx] ;or al,20h ;convert all character's to small letterscmp al,ah ;jne MaxSign ;mov ebx,OFFSET Sign_A ;coded character tablecmp edx,0h ;je CheckTempQA ;PointCharBits:add ebx,20h ;dec edx ;

Page 18

Page 19: Td Win32asm 510.Asm

td_win32asm_510.asmjne PointCharBits ;CheckTempQA:mov ecx,edi ;EDI = OFFSET temp_Question / temp_Answermov eax,counter0 ;cmp eax,0h ;je FillTempQA ;PointTempQA:add ecx,20h ;dec eax ;jne PointTempQA ;FillTempQA:mov al,20h ;LoopFillTempQA: ;mov ah,[ebx] ;mov [ecx],ah ;inc ebx ;inc ecx ;dec al ;jne LoopFillTempQA ;inc counter0 ;mov eax,counter0 ;cmp eax,QALength ;jne NextChar ;mov eax,0h ;no error encountered, reset flagret ;Input_Error:mov eax,1h ;ERROR, set flagret ;

My_FindAnswer:;==============================================================================; Reset temp_Answer buffer.;------------------------------------------------------------------------------mov edx,0h ;mov ah,20h ;Clear_A:mov ecx,OFFSET temp_Answer ;add ecx,edx ;mov [ecx],ah ;inc edx ;cmp edx,140h ;jne Clear_A ;;------------------------------------------------------------------------------; Calculate Level ( summary of 1 in the question ).;------------------------------------------------------------------------------mov edx,0h ;count the number of 1 in the questionmov Level,0h ;mov ebx,OFFSET temp_Question ;mov ecx,OFFSET temp_Column ;CheckLevel:mov al,[ebx] ;cmp al,31h ;jne NextValue ;

Page 19

Page 20: Td Win32asm 510.Asm

td_win32asm_510.asminc Level ;store the summary in variable "Level"mov [ecx],dh ;store the founded column'smov [ecx+1],dl ;inc ecx ;inc ecx ;NextValue:inc ebx ;inc edx ;cmp edx,140h ;jne CheckLevel ;;------------------------------------------------------------------------------; Search for the answer in the matrix and store it in temp_Answer.;------------------------------------------------------------------------------mov esi,0h ;mov edi,OFFSET temp_Answer ;L00:mov temp_Result,0h ;mov ebx,OFFSET temp_Column ;mov ecx,OFFSET Matrix_RAM ;add ecx,esi ;mov eax,0h ;L01:mov edx,0h ;mov dh,[ebx] ;mov dl,[ebx+1] ;add ecx,edx ;push eax ;save EAXmov al,[ecx] ;sub ecx,edx ;cmp al,31h ;jne L02 ;inc temp_Result ;L02:pop eax ;restore EAXinc ebx ;inc ebx ;inc eax ;cmp eax,Level ;jne L01 ;mov bl,20h ;mov [edi],bl ;mov eax,Level ;sub eax,tolerance ;jc L03 ;cmp temp_Result,eax ;jb L03 ;mov bl,31h ;mov [edi],bl ;L03:inc edi ;add esi,140h ;cmp esi,19000h ;jne L00 ;

Page 20

Page 21: Td Win32asm 510.Asm

td_win32asm_510.asm;------------------------------------------------------------------------------; Reset output buffer;------------------------------------------------------------------------------mov ax,0h ;clear output buffermov ebx,OFFSET Intelligence ;Clear_Intelligence:mov [ebx],ah ;inc al ;inc ebx ;cmp al,0Ah ;jne Clear_Intelligence ;;------------------------------------------------------------------------------; Decode back into hex value of ascii character; if avaible.;------------------------------------------------------------------------------mov edx,0h ;mov edi,0h ;LX0:mov counter0,0h ;mov esi,0h ;LX10:mov ebx,OFFSET temp_Answer ;add ebx,edx ;mov ecx,OFFSET Sign_A ;add ecx,esi ;mov ah,0h ;LX1:mov al,[ebx] ;cmp [ecx],al ;je LX2 ;inc counter0 ;add esi,20h ;cmp esi,340h ;jne LX10 ;mov ebx,OFFSET QMark ;jmp LX3 ;LX2:inc ebx ;inc ecx ;inc ah ;cmp ah,20h ;jne LX1 ;mov ebx,OFFSET Sign_Index ;add ebx,counter0 ;LX3:mov ecx,OFFSET Intelligence ;add ecx,edi ;mov al,[ebx] ;mov [ecx],al ;add edx,20h ;inc edi ;cmp edi,0Ah ;jne LX0 ;ret ;

Page 21

Page 22: Td Win32asm 510.Asm

td_win32asm_510.asm

My_PaintWorkArea:;==============================================================================; API "BeginPaint" prepares the specified window for painting and fills a; PAINTSTRUCT structure with information about the painting;------------------------------------------------------------------------------push OFFSET hdc ;lpPaint, pointer to PAINTSTRUCTpush WP1_hWnd ;hwnd, handle of the windowcall BeginPaint ;- API Function -mov hdcDest,eax ;handle, display device (DC)=dest.;------------------------------------------------------------------------------; API "DrawEdge" draws one or more edges of rectangle.;------------------------------------------------------------------------------push 400Fh ;grfFlags, type of borderpush 5h ;edge, type inner + outer edge to draw ;BDR_RAISEDOUTER = 0001h ;BDR_RAISEDINNER = 0004hpush OFFSET rcLearn_left ;qrc, address of rectangle coordinatespush hdcDest ;hdc, handle of device contextcall DrawEdge ;- API Function -;------------------------------------------------------------------------------; API "SetBkColor" sets the current background color to the specified color; value, or to the nearest physical color if the device cannot represent the; specified color value. Parameter crColor = Null Blue Green Red (BGR).;------------------------------------------------------------------------------push 0h ;crColor, background color valuepush hdcDest ;hdc, handle of device contextcall SetBkColor ;- API Function -;------------------------------------------------------------------------------; API "SetTextColor" sets the text color for the specified device context to; the specified color. Parameter crColor = Null Blue Green Red (BGR).;------------------------------------------------------------------------------push 0000D6FFh ;crColor, text colorpush hdcDest ;hdc, handle of device contextcall SetTextColor ;- API Function -;------------------------------------------------------------------------------; API "TextOutA" writes a character string at the specified location, using; the currently selected font.;------------------------------------------------------------------------------push 08h ;cbString, number characters in stringpush OFFSET LearnTitel ;lpString, address of stringpush 48h ;nYStart, y-coord. of starting positionpush 1C0h ;nXStart, x-coord. of starting positionpush hdcDest ;hdc, handle of device contextcall TextOutA ;- API Function -;------------------------------------------------------------------------------; API "SetTextColor" sets the text color for the specified device context to; the specified color. Parameter crColor = Null Blue Green Red (BGR).;------------------------------------------------------------------------------push 00FFFFFFh ;crColor, text colorpush hdcDest ;hdc, handle of device contextcall SetTextColor ;- API Function -;------------------------------------------------------------------------------

Page 22

Page 23: Td Win32asm 510.Asm

td_win32asm_510.asm; API "TextOutA" writes a character string at the specified location, using; the currently selected font.;------------------------------------------------------------------------------push 08h ;cbString, number characters in stringpush OFFSET Question ;lpString, address of stringpush 64h ;nYStart, y-coord. of starting positionpush 170h ;nXStart, x-coord. of starting positionpush hdcDest ;hdc, handle of device contextcall TextOutA ;- API Function -;------------------------------------------------------------------------------; API "TextOutA" writes a character string at the specified location, using; the currently selected font.;------------------------------------------------------------------------------push 06h ;cbString, number characters in stringpush OFFSET Answer ;lpString, address of stringpush 84h ;nYStart, y-coord. of starting positionpush 170h ;nXStart, x-coord. of starting positionpush hdcDest ;hdc, handle of device contextcall TextOutA ;- API Function -;------------------------------------------------------------------------------; API "DrawEdge" draws one or more edges of rectangle.;------------------------------------------------------------------------------push 400Fh ;grfFlags, type of borderpush 5h ;edge, type inner + outer edge to draw ;BDR_RAISEDOUTER = 0001h ;BDR_RAISEDINNER = 0004hpush OFFSET rcInquiry_left ;qrc, address of rectangle coordinatespush hdcDest ;hdc, handle of device contextcall DrawEdge ;- API Function -;------------------------------------------------------------------------------; API "SetBkColor" sets the current background color to the specified color; value, or to the nearest physical color if the device cannot represent the; specified color value. Parameter crColor = Null Blue Green Red (BGR).;------------------------------------------------------------------------------push 0h ;crColor, background color valuepush hdcDest ;hdc, handle of device contextcall SetBkColor ;- API Function -;------------------------------------------------------------------------------; API "SetTextColor" sets the text color for the specified device context to; the specified color. Parameter crColor = Null Blue Green Red (BGR).;------------------------------------------------------------------------------push 0000D6FFh ;crColor, text colorpush hdcDest ;hdc, handle of device contextcall SetTextColor ;- API Function -;------------------------------------------------------------------------------; API "TextOutA" writes a character string at the specified location, using; the currently selected font.;------------------------------------------------------------------------------push 07h ;cbString, number characters in stringpush OFFSET InquiryTitel ;lpString, address of stringpush 0B0h ;nYStart, y-coord. of starting positionpush 1C0h ;nXStart, x-coord. of starting positionpush hdcDest ;hdc, handle of device context

Page 23

Page 24: Td Win32asm 510.Asm

td_win32asm_510.asmcall TextOutA ;- API Function -;------------------------------------------------------------------------------; API "SetTextColor" sets the text color for the specified device context to; the specified color. Parameter crColor = Null Blue Green Red (BGR).;------------------------------------------------------------------------------push 00FFFFFFh ;crColor, text colorpush hdcDest ;hdc, handle of device contextcall SetTextColor ;- API Function -;------------------------------------------------------------------------------; API "TextOutA" writes a character string at the specified location, using; the currently selected font.;------------------------------------------------------------------------------push 08h ;cbString, number characters in stringpush OFFSET Question ;lpString, address of stringpush 0CCh ;nYStart, y-coord. of starting positionpush 170h ;nXStart, x-coord. of starting positionpush hdcDest ;hdc, handle of device contextcall TextOutA ;- API Function -;------------------------------------------------------------------------------; API "TextOutA" writes a character string at the specified location, using; the currently selected font.;------------------------------------------------------------------------------push 06h ;cbString, number characters in stringpush OFFSET Answer ;lpString, address of stringpush 104h ;nYStart, y-coord. of starting positionpush 170h ;nXStart, x-coord. of starting positionpush hdcDest ;hdc, handle of device contextcall TextOutA ;- API Function -;------------------------------------------------------------------------------; API "EndPaint" marks the end of painting in the given window.; This function is required for each call to the BeginPaint function, but only; after painting is complete. ;------------------------------------------------------------------------------push OFFSET hdc ;lpPaint, pointer PAINTSTRUCTpush WP1_hWnd ;hwnd, handle of the windowcall EndPaint ;- API Function -ret ;

My_WM_CREATE:;==============================================================================; API "CreateWindowExA" creates a window with a predefined class name (STATIC).; The return value in EAX is the handle of the new window (Quick Help).;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 900h ;hMenu, the child-window IDpush WP1_hWnd ;hWndParent, handle parent window 0=nopush 200h ;intnHeight, window height pixelpush 153h ;intnWidth, window width pixelpush 0Ch ;inty, vertical position windowpush 04h ;intx, horizontal position windowpush 54000000h ;dwStyle, static window style ;WS_CHILD = 40000000h

Page 24

Page 25: Td Win32asm 510.Asm

td_win32asm_510.asm ;WS_VISIBLE = 10000000h ;WS_CLIBSIBLINGS = 4000000hpush OFFSET HelpText ;lpWindowName, pointer to window namepush OFFSET STATIC_Class ;lpClassName, pointer to class namepush 1h ;dwExStyle,look WIN32.HLP + windows.inccall CreateWindowExA ;- API Function -mov STATIC_HelphWnd,eax ;hwnd,return value=handle of window;------------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (STATIC).; The return value in EAX is the handle of the new window (Titel).;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 700h ;hMenu, the child-window IDpush WP1_hWnd ;hWndParent, handle parent window 0=nopush 30h ;intnHeight, window height pixelpush 112h ;intnWidth, window width pixelpush 0Ch ;inty, vertical position windowpush 160h ;intx, horizontal position windowpush 5400000Eh ;dwStyle, static window style ;WS_CHILD = 40000000h ;WS_VISIBLE = 10000000h ;WS_CLIBSIBLINGS = 4000000h ;SS_BITMAP = 0Ehpush OFFSET Titel ;lpWindowName, pointer to window namepush OFFSET STATIC_Class ;lpClassName, pointer to class namepush 0h ;dwExStyle,look WIN32.HLP + windows.inccall CreateWindowExA ;- API Function -mov STATIC_TitelhWnd,eax ;hwnd,return value=handle of window;------------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (EDIT).; The return value in EAX is the handle of the new window (Learning Question).;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 910h ;hMenu, the child-window IDpush WP1_hWnd ;hWndParent, handle parent window 0=nopush 18h ;intnHeight, window height pixelpush 80h ;intnWidth, window width pixelpush 60h ;inty, vertical position windowpush 1B0h ;intx, horizontal position windowpush 54010000h ;dwStyle, static window style ;WS_CHILD = 40000000h ;WS_VISIBLE = 10000000h ;WS_CLIBSIBLINGS = 4000000h ;WS_TABSTOP = 10000hpush 0h ;lpWindowName, pointer to window namepush OFFSET EDIT_Class ;lpClassName, pointer to class namepush 1h ;dwExStyle,look WIN32.HLP + windows.inccall CreateWindowExA ;- API Function -mov EDIT1_WorkhWnd,eax ;hwnd,return value=handle of window;------------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (EDIT).

Page 25

Page 26: Td Win32asm 510.Asm

td_win32asm_510.asm; The return value in EAX is the handle of the new window (Learning Answer).;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 920h ;hMenu, the child-window IDpush WP1_hWnd ;hWndParent, handle parent window 0=nopush 18h ;intnHeight, window height pixelpush 80h ;intnWidth, window width pixelpush 80h ;inty, vertical position windowpush 1B0h ;intx, horizontal position windowpush 54010000h ;dwStyle, static window style ;WS_CHILD = 40000000h ;WS_VISIBLE = 10000000h ;WS_CLIBSIBLINGS = 4000000h ;WS_TABSTOP = 10000hpush 0h ;lpWindowName, pointer to window namepush OFFSET EDIT_Class ;lpClassName, pointer to class namepush 1h ;dwExStyle,look WIN32.HLP + windows.inccall CreateWindowExA ;- API Function -mov EDIT2_WorkhWnd,eax ;hwnd,return value=handle of window;------------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (BUTTON).; The return value in EAX is the handle of the new child window (Go Learning).;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 500h ;hMenu, the child-window IDpush WP1_hWnd ;hWndParent, handle parent window 0=nopush 20h ;intnHeight, window height pixelpush 20h ;intnWidth, window width pixelpush 6Ch ;inty, vertical position windowpush 244h ;intx, horizontal position windowpush 54000080h ;dwStyle, button style ;WS_CHILD = 40000000h ;WS_VISIBLE = 10000000h ;WS_CLIBSIBLINGS = 4000000h ;WS_TABSTOP = 10000h ;BS_BITMAP = 80h ;BS_PUSHBUTTON = 0hpush 0h ;lpWindowName, pointer to window namepush OFFSET BUTTON_Class ;lpClassName, pointer to class namepush 0h ;dwExStyle,call CreateWindowExA ;- API Function -mov BUTTON_LearnhWnd,eax ;return value=handle of window;------------------------------------------------------------------------------; API "LoadBitmapA" loads a bitmap from the resource file;------------------------------------------------------------------------------push 80h ;lpBitmapName, bitmap resource IDpush hInstance ;hInstance, handle of modul instancecall LoadBitmapA ;- API Function -mov BUTTON_LearnhObject,eax ;hObject, handle of graphic object;------------------------------------------------------------------------------; API "SendMessageA" sends a message to the Window Procedure lpfnWndProc

Page 26

Page 27: Td Win32asm 510.Asm

td_win32asm_510.asm;------------------------------------------------------------------------------push eax ;lParam, handle of bitmappush 0h ;wParam, first message ( IMAGE_BITMAP )push 0F7h ;uMsg, message to send ( BM_SETIMAGE )push BUTTON_LearnhWnd ;hWnd, handle of destination windowcall SendMessageA ;- API Function -;------------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (EDIT).; The return value in EAX is the handle of the new window (Inquiry Question).;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 930h ;hMenu, the child-window IDpush WP1_hWnd ;hWndParent, handle parent window 0=nopush 18h ;intnHeight, window height pixelpush 80h ;intnWidth, window width pixelpush 0C8h ;inty, vertical position windowpush 1B0h ;intx, horizontal position windowpush 54010000h ;dwStyle, static window style ;WS_CHILD = 40000000h ;WS_VISIBLE = 10000000h ;WS_CLIBSIBLINGS = 4000000h ;WS_TABSTOP = 10000hpush 0h ;lpWindowName, pointer to window namepush OFFSET EDIT_Class ;lpClassName, pointer to class namepush 1h ;dwExStyle,look WIN32.HLP + windows.inccall CreateWindowExA ;- API Function -mov EDIT3_WorkhWnd,eax ;hwnd,return value=handle of window;------------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (STATIC).; The return value in EAX is the handle of the new window (Answer0-6).; Here we create the seven answer windows !;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 600h ;hMenu, the child-window IDpush WP1_hWnd ;hWndParent, handle parent window 0=nopush 18h ;intnHeight, window height pixelpush 80h ;intnWidth, window width pixelpush 100h ;inty, vertical position windowpush 1B0h ;intx, horizontal position windowpush 54000000h ;dwStyle, static window style ;WS_CHILD = 40000000h ;WS_VISIBLE = 10000000h ;WS_CLIBSIBLINGS = 4000000h ;SS_LEFT = 0hpush 0h ;lpWindowName, pointer to window namepush OFFSET STATIC_Class ;lpClassName, pointer to class namepush 1h ;dwExStyle,look WIN32.HLP + windows.inccall CreateWindowExA ;- API Function -mov STATIC_Inquiry0hWnd,eax ;hwnd, return value=handle of windowpush 0hpush hInstance

Page 27

Page 28: Td Win32asm 510.Asm

td_win32asm_510.asmpush 601hpush WP1_hWndpush 18hpush 80hpush 120hpush 1B0hpush 54000000hpush 0hpush OFFSET STATIC_Classpush 1hcall CreateWindowExAmov STATIC_Inquiry1hWnd,eaxpush 0hpush hInstancepush 602hpush WP1_hWndpush 18hpush 80hpush 140hpush 1B0hpush 54000000hpush 0hpush OFFSET STATIC_Classpush 1hcall CreateWindowExAmov STATIC_Inquiry2hWnd,eaxpush 0hpush hInstancepush 603hpush WP1_hWndpush 18hpush 80hpush 160hpush 1B0hpush 54000000hpush 0hpush OFFSET STATIC_Classpush 1hcall CreateWindowExAmov STATIC_Inquiry3hWnd,eaxpush 0hpush hInstancepush 604hpush WP1_hWndpush 18hpush 80hpush 180hpush 1B0hpush 54000000hpush 0hpush OFFSET STATIC_Classpush 1hcall CreateWindowExA

Page 28

Page 29: Td Win32asm 510.Asm

td_win32asm_510.asmmov STATIC_Inquiry4hWnd,eaxpush 0hpush hInstancepush 605hpush WP1_hWndpush 18hpush 80hpush 1A0hpush 1B0hpush 54000000hpush 0hpush OFFSET STATIC_Classpush 1hcall CreateWindowExAmov STATIC_Inquiry5hWnd,eaxpush 0hpush hInstancepush 606hpush WP1_hWndpush 18hpush 80hpush 1C0hpush 1B0hpush 54000000hpush 0hpush OFFSET STATIC_Classpush 1hcall CreateWindowExAmov STATIC_Inquiry6hWnd,eaxpush 0hpush hInstancepush 607hpush WP1_hWndpush 18hpush 80hpush 1E0hpush 1B0hpush 54000000hpush 0hpush OFFSET STATIC_Classpush 1hcall CreateWindowExAmov STATIC_Inquiry7hWnd,eax;------------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (BUTTON).; The return value in EAX is the handle of the new child window (Go Inquiry).;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 0501h ;hMenu, the child-window IDpush WP1_hWnd ;hWndParent, handle parent window 0=nopush 20h ;intnHeight, window height pixelpush 20h ;intnWidth, window width pixel

Page 29

Page 30: Td Win32asm 510.Asm

td_win32asm_510.asmpush 0C4h ;inty, vertical position windowpush 244h ;intx, horizontal position windowpush 54000080h ;dwStyle, button style ;WS_CHILD = 40000000h ;WS_VISIBLE = 10000000h ;WS_CLIBSIBLINGS = 4000000h ;WS_TABSTOP = 10000h ;BS_BITMAP = 80h ;BS_PUSHBUTTON = 0hpush 0h ;lpWindowName, pointer to window namepush OFFSET BUTTON_Class ;lpClassName, pointer to class namepush 0h ;dwExStyle,call CreateWindowExA ;- API Function -mov BUTTON_InquiryhWnd,eax ;return value=handle of window;------------------------------------------------------------------------------; API "LoadBitmapA" loads a bitmap from the resource file;------------------------------------------------------------------------------push 81h ;lpBitmapName, bitmap resource IDpush hInstance ;hInstance, handle of modul instancecall LoadBitmapA ;- API Function -mov BUTTON_InquiryhObject,eax ;hObject, handle of graphic object;------------------------------------------------------------------------------; API "SendMessageA" sends a message to the Window Procedure lpfnWndProc;------------------------------------------------------------------------------push eax ;lParam, handle of bitmappush 0h ;wParam, first message ( IMAGE_BITMAP )push 0F7h ;uMsg, message to send ( BM_SETIMAGE )push BUTTON_InquiryhWnd ;hWnd, handle of destination windowcall SendMessageA ;- API Function -ret ;

My_SetFocus:;==============================================================================; API "SetFocus" sets the keyboard focus to the specified window.;------------------------------------------------------------------------------push EDIT1_WorkhWnd ;hwnd, handle of window to receive focuscall SetFocus ;- API Function -ret ;

My_ResetMatrix:;==============================================================================; Reset matrix, clear memory, everything learned before is lost forever ...;------------------------------------------------------------------------------mov ecx,0h ;mov ebx,OFFSET Matrix_RAM ;Loop_ResetMatrix:mov al,20h ;mov [ebx],al ;inc ebx ;inc ecx ;cmp ecx,19000h ;jne Loop_ResetMatrix ;ret ;

Page 30

Page 31: Td Win32asm 510.Asm

td_win32asm_510.asm

My_LoadMatrix:mov ErrorFlag,0h ;reset error flag;==============================================================================; API "GetOpenFileName" creates a system-defined dialog box that enables the; user to select a file to open. ;------------------------------------------------------------------------------mov lStructSize,4Ch ;length in bytes of structuremov eax,WP1_hWnd ; mov hWndOwner,eax ;id window that owns dialog boxmov eax,hInstance ; mov hInstance1,eax ;handle, our program idmov lpstrFilter,OFFSET FileFilt ;pointer to string + filter, 0= nomov lpstrCustomFilter,0h ;pointer to user defined filtermov nMaxCustFilter,0h ;size bytes/characters of abovemov nFilterIndex,0h ;filter index of lpstrFilter mov lpstrFile,OFFSET LoadFileN ;pointer initialize filename, 0=nomov nMaxFile,104h ;max size bytes/characters of abovemov lpstrFileTitle,0h ;pointer title of the selected filemov nMaxFileTitle,0h ;size of the lpstrFileTitle buffer mov lpstrInitialDir,0h ;pointer init file dir,0=defaultmov lpstrTitle,OFFSET LoadFileT ;pointer title of the box mov Flags,00281804h ;the dialog box creation flags mov nFileOffset,0h ;offset filename in string lpstrFile mov nFileExtension,0h ;offset extension in string lpstrFile mov lCustData,0h ;? mov lpfnHook,0h ;? used if flag is OFN_ENABLETEMPLATEmov lpTemplateName,0h ;? used if flag is OFN_ENABLETEMPLATEmov eax,OFFSET FileDefExt ;mov lpstrDefExt,eax ;pointer default extension file, 0=nopush OFFSET lStructSize ;pointer to OPENFILENAME Structurecall GetOpenFileNameA ;- API Function -cmp eax,1h ;check for errorje GoOpenLoad ;mov ErrorFlag,1h ;ret ;GoOpenLoad:;------------------------------------------------------------------------------; API "CreateFileA" creates or opens a file.; It returns a handle that can be used to access the object.;------------------------------------------------------------------------------push 0h ;hTemplateFile,push 80h ;dwFlagsAndAttributes, 80h=normalpush 3h ;dwCreationDistribution, OPEN_EXISTINGpush 0h ;lpSecurityAttributes,push 0h ;dwShareMode,push 80000000h ;dwDesiredAccess, GENERIC_READpush OFFSET LoadFileN ;lpFileName, pointer to filenamecall CreateFileA ;- API Function -cmp eax,-1 ;error ? INVALID_HANDLE_VALUE = -1jne GoGetLoad ;mov ErrorFlag,1h ;ret ;

Page 31

Page 32: Td Win32asm 510.Asm

td_win32asm_510.asmGoGetLoad:mov FileHandle,eax ;store handle in variable;------------------------------------------------------------------------------; API "GetFileSize" retrieves the size, in bytes, of the specified file.;------------------------------------------------------------------------------push 0h ;lpFileSizeHigh, address file size highword push FileHandle ;hFile, handle of file to get size ofcall GetFileSize ;- API Function -cmp eax,0FFFFFFFFh ;check for errorjne GoCheck ;mov ErrorFlag,1h ;jmp GoCloseL ;GoCheck:cmp eax,19000h ;je GoLoad ;mov ErrorFlag,1h ;jmp GoCloseL ;GoLoad:;------------------------------------------------------------------------------; API "ReadFile" reads data from a file, starting at the position file pointer;------------------------------------------------------------------------------push 0h ;lpOverlapped, address data structure push OFFSET FileReturn ;lpNumberOfBytesRead, readed bytes push 19000h ;nNumberOfBytesToRead, bytes to read push OFFSET Load_Buffer ;lpBuffer, address buffer receives datapush FileHandle ;hFile, handle of file to read call ReadFile ;- API Function -cmp eax,0h ;check for errorjne GoCloseL ;mov ErrorFlag,1h ;GoCloseL:;------------------------------------------------------------------------------; API "CloseHandle" closes an open object handle. ;------------------------------------------------------------------------------push FileHandle ;hObject, handle of object to close call CloseHandle ;- API Function -cmp eax,0h ;check for errorjne GoLoadReturn ;mov ErrorFlag,1h ;GoLoadReturn:ret ;

My_SaveMatrix:mov ErrorFlag,0h ;reset error flag;==============================================================================; API "GetSaveFileName" creates a system-defined dialog box that enables the; user to select a file to save. ;------------------------------------------------------------------------------mov lStructSize,4Ch ;length in bytes of structuremov eax,WP1_hWnd ; mov hWndOwner,eax ;id window that owns dialog boxmov eax,hInstance ; mov hInstance1,eax ;handle, our program id

Page 32

Page 33: Td Win32asm 510.Asm

td_win32asm_510.asmmov lpstrFilter,OFFSET FileFilt ;pointer to string + filter, 0= nomov lpstrCustomFilter,0h ;pointer to user defined filtermov nMaxCustFilter,0h ;size bytes/characters of abovemov nFilterIndex,0h ;filter index of lpstrFilter mov lpstrFile,OFFSET SaveFileN ;pointer initialize filename, 0=nomov nMaxFile,104h ;max size bytes/characters of abovemov lpstrFileTitle,0h ;pointer title of the selected filemov nMaxFileTitle,0h ;size of the lpstrFileTitle buffer mov lpstrInitialDir,0h ;pointer init file dir,0=defaultmov lpstrTitle,OFFSET SaveFileT ;pointer title of the box mov Flags,00281804h ;the dialog box creation flags mov nFileOffset,0h ;offset filename in string lpstrFile mov nFileExtension,0h ;offset extension in string lpstrFile mov lCustData,0h ;? mov lpfnHook,0h ;? used if flag is OFN_ENABLETEMPLATEmov lpTemplateName,0h ;? used if flag is OFN_ENABLETEMPLATEmov eax,OFFSET FileDefExt ;mov lpstrDefExt,eax ;pointer default extension file, 0=no push OFFSET lStructSize ;pointer to OPENFILENAME Structurecall GetSaveFileNameA ;- API Function -cmp eax,1h ;check for errorje GoOpenSave ;mov ErrorFlag,1h ;ret ;GoOpenSave:;------------------------------------------------------------------------------; API "CreateFileA" creates or opens a file.; It returns a handle that can be used to access the object.;------------------------------------------------------------------------------push 0h ;hTemplateFile,push 80h ;dwFlagsAndAttributes, 80h=normalpush 2h ;dwCreationDistribution, CREATE_ALWAYSpush 0h ;lpSecurityAttributes,push 0h ;dwShareMode,push 40000000h ;dwDesiredAccess,GENERIC_WRITEpush OFFSET SaveFileN ;lpFileName,pointer to filenamecall CreateFileA ;- API Function -cmp eax,-1 ;error ? INVALID_HANDLE_VALUE = -1jne GoGetSave ;mov ErrorFlag,1h ;ret ;GoGetSave:mov FileHandle,eax ;store handle in variable;------------------------------------------------------------------------------; API "WriteFile" writes data to a file;------------------------------------------------------------------------------push 0h ;lpOverlapped, structure overlapped I/Opush OFFSET FileReturn ;lpNumberOfBytesWritten,push 19000h ;nNumberOfBytesToWrite, bytes to write push OFFSET Matrix_RAM ;lpBuffer, address data write to file push FileHandle ;hFile, handle of file to write to call WriteFile ;- API Function -cmp eax,0h ;check for error

Page 33

Page 34: Td Win32asm 510.Asm

td_win32asm_510.asmjne GoCloseS ;mov ErrorFlag,1h ;GoCloseS:;------------------------------------------------------------------------------; API "CloseHandle" closes an open object handle. ;------------------------------------------------------------------------------push FileHandle ;hObject, handle of object to close call CloseHandle ;- API Function -cmp eax,0h ;check for errorjne GoSaveReturn ;mov ErrorFlag,1h ;GoSaveReturn:ret ;

My_PutAnswer:;==============================================================================; This is my routine to insert the answer into the Matrix.;------------------------------------------------------------------------------mov esi,0h ;NextEntry:mov ebx,OFFSET temp_Question ;add ebx,esi ;mov al,[ebx] ;cmp al,31h ;jne QBitNotSet ;mov ecx,OFFSET Matrix_RAM ;add ecx,esi ;mov edx,0h ;mov ebx,OFFSET temp_Answer ;NextLine:mov al,[ebx] ;cmp al,31h ;jne ABitNotSet ;mov [ecx],al ;ABitNotSet:add ecx,140h ;inc ebx ;inc edx ;cmp edx,140h ;jne NextLine ;QBitNotSet:inc esi ;cmp esi,140h ;jne NextEntry ;ret ;;******************************************************************************

;==============================================================================; end Main = end of our program code;------------------------------------------------------------------------------end Main ;end of our program code, entry point

;==============================================================================

Page 34

Page 35: Td Win32asm 510.Asm

td_win32asm_510.asm; To create the exe file use this commands with your Microsoft Assembler/Linker;------------------------------------------------------------------------------; ml.exe /c /coff td_win32asm_510.asm ;asm command; rc.exe /v rsrc.rc ;rc command; cvtres.exe /machine:ix86 rsrc.res; link.exe /subsystem:windows td_win32asm_510.obj rsrc.obj ;link command;==============================================================================

Page 35


Recommended