Noob just finished one program and requires few clarifications

Started by sydetys, October 21, 2008, 11:33:10 PM

Previous topic - Next topic

sydetys

Hi

My code is thus:



.686p                                   ; create 32 bit code
.mmx
.xmm
.model flat, stdcall                    ; 32 bit memory model
option casemap :none                    ; case sensitive

    include \masm32\include\windows.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\masm32.inc
    include \masm32\macros\macros.asm
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
   
 
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
   


.data
       
        s1      db "*******************************", 10,9,9,9
        w1      db "*                             *", 10,9,9,9
        w2      db "**                           **", 10,9,9,9
        med     db "***       LASKULUUPPI       ***", 10,9,9,9
        w3      db "****                       ****", 10,9,9,9
        w4      db "*****                     *****", 10,9,9,9
        s2      db "*******************************", 10,9,9,9
        e1      db "                               ", 10,9,9,9
        e2      db "                               ", 10,9,9,9,0

.data?

        nro     dd  ?
        nro2    dd  ?

.code

start:

call number
call jako
jmp counter

SetTextColor proc fore:DWORD,back:DWORD

    LOCAL hStdOut:DWORD

    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov   hStdOut,eax
    mov   eax,back
    shl   eax,4
    or    eax,fore
    invoke SetConsoleTextAttribute,hStdOut,eax
    ret

SetTextColor endp

number proc

cls

invoke SetTextColor, 10, 0

invoke StdOut, addr e2     
invoke StdOut, addr s1

    mov nro, sval(input("Anna jaettava luku : ",9))
    print chr$(9,9,9)
    mov nro2, sval(input("Anna jakaja : ",9,9))

ret
number endp

jako proc

    LOCAL osam:DWORD
   
    xor edx, edx
    mov eax, nro
    cdq                 ;Sign-extend EAX into EDX:EAX.
    mov ecx, nro2
    idiv ecx            ; eax = quotient, edx = remainder
             

    mov osam, eax
   
    xor ebx, ebx
    mov ebx, edx
   
    print chr$(10,9,9,9)
    print chr$("Osamaara: ",9,9)
    print str$(osam)
    print chr$(".")
   
ret
jako endp

vastaluku:

    neg esi
    print str$(esi)
    dec edi
    jnz jaannos
    invoke ExitProcess, NULL

counter:

    xor edi, edi
    mov edi, 4

jaannos:
   
    xor eax, eax
    mov eax, 10
    mul ebx

    xor ebx, ebx
   
desimaali:

    xor ecx, ecx
    xor edx, edx
    cdq
    mov ecx, nro2
    idiv ecx

    xor esi, esi
    xor ebx, ebx

    mov esi, eax
    mov ebx, edx

    test esi, -1
    jle vastaluku
    print str$(esi)
    dec edi
    jnz jaannos   


invoke ExitProcess, NULL

end start



As you can see this just divides few numbers and gives result with 4 decimals

anyway to increase input number precision?
I thought it would nice to have 0.1 precision for numbers to input,  it shouldn´t require so much extra work to add.

How about this: I checked assembled .exe file with "dumpbin" and noticed that header is closed 32bit, no large address awareness, how can I add that directly in source code? I don´t want everytime go to editbin to add over 2GB memory allocation possibility....that will be LATER an issue when I am able to make greater programs.

thanx

BasilYercin

Quote from: sydetys on October 21, 2008, 11:33:10 PM

How about this: I checked assembled .exe file with "dumpbin" and noticed that header is closed 32bit, no large address awareness, how can I add that directly in source code? I don´t want everytime go to editbin to add over 2GB memory allocation possibility....that will be LATER an issue when I am able to make greater programs.

thanx



C:\masm32\bin>link
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

usage: LINK [options] [files] [@commandfile]

   options:

      /ALIGN:#
      /BASE:{address|@filename,key}
      /COMMENT:comment
      /DEBUG
      /DEBUGTYPE:{CV|COFF}
      /DEF:filename
      /DEFAULTLIB:library
      /DLL
      /DRIVER[:{UPONLY|WDM}]
      /ENTRY:symbol
      /EXETYPE:DYNAMIC
      /EXPORT:symbol
      /FIXED[:NO]
      /FORCE[:{MULTIPLE|UNRESOLVED}]
      /GPSIZE:#
      /HEAP:reserve[,commit]
      /IMPLIB:filename
      /INCLUDE:symbol
      /INCREMENTAL:{YES|NO}
      /LARGEADDRESSAWARE[:NO]
      /LIBPATH:dir
      /MACHINE:{ALPHA|ARM|IX86|MIPS|MIPS16|MIPSR41XX|PPC|SH3|SH4}
      /MAP[:filename]
      /MAPINFO:{EXPORTS|FIXUPS|LINES}
      /MERGE:from=to
      /NODEFAULTLIB[:library]
      /NOENTRY
      /NOLOGO
      /OPT:{ICF[,iterations]|NOICF|NOREF|NOWIN98|REF|WIN98}
      /ORDER:@filename
      /OUT:filename
      /PDB:{filename|NONE}
      /PDBTYPE:{CON[SOLIDATE]|SEPT[YPES]}
      /PROFILE
      /RELEASE
      /SECTION:name,[E][R][W][D][K][L][P][X]
      /STACK:reserve[,commit]
      /STUB:filename
      /SUBSYSTEM:{NATIVE|WINDOWS|CONSOLE|WINDOWSCE|POSIX}[,#[.##]]
      /SWAPRUN:{CD|NET}
      /VERBOSE[:LIB]
      /VERSION:#[.#]
      /VXD
      /WARN[:warninglevel]
      /WINDOWSCE:{CONVERT|EMULATION}
      /WS:AGGRESSIVE

sydetys

So it is LINKER setting? ok, that´s clear.

S0? is FPU programming that only way to input and  easiest way to get precision numbers? no other way? I noticed that this is hard work to get decimals, if I think about precision of windows calculator, huh huh..

That´s why my plans has changed. No windows programming before FPU programming.

Any good links to sites where are examples and tutorials about FPU programming? from basic calculus to advanced calculus.

thank you very much

PS. nevermind I found few links...now some learning..