flat assembler
Message board for the users of flat assembler.

Index > Windows > Program do not start on windows

Author
Thread Post new topic Reply to topic
fluttyoyo



Joined: 11 May 2016
Posts: 1
fluttyoyo 11 May 2016, 20:01
I can compile my code, but it's not starts.
I can't understand why.
Please, help me to know what is wrong.

Program should make a number and user should guess it.

Code:
format PE console
include 'win32a.inc'

entry start

section '.code' code executable
start:

proc    strToInt lpStr:word
        push    bx dx si
 
        xor     ax,ax
        mov     si,[lpStr]
.strToInt_loop:
        movsx   bx,byte [si]
        sub     bl,'0'
        cmp     bl,10
        jnb     .strToInt_ret
        imul    ax,10
        add     ax,bx
        inc     si
        jmp     .strToInt_loop
 
.strToInt_ret:
        pop     si dx bx
        ret
endp

board1 dw ?
board2 dw ?
number dw ?
myNumber dw ?
interval dw ?
counter db 0
lenght db 0


;begin game
begin:
       cinvoke printf,enterInviting

       cinvoke gets, buff2
       stdcall strToInt, buff2
       mov [board1], ax

       cinvoke gets, buff3
       stdcall strToInt, buff3
       mov [board2], ax
;---------------

;random number
        mov ax, [board2]
        sub ax, [board1]
        mov [interval], ax

        cmp [counter], 0
        je D
        jne E
E:
        mov bx, [board2]

        mov ax, [board1]
        mov cx, [myNumber]
        mul cx
        add ax, bx
        mov cx, [interval]
        div cx
        add dx, [board1]
        mov [myNumber], dx;
        jmp metka2

D:
        mov ax, [board2]
        mov [myNumber], ax
        mov al, [counter]
        inc al
        mov [counter], al
        jmp metka2
;----------------
;makes step
metka2:
        cinvoke printf, enterNumber

        cinvoke gets, buff1
        stdcall strToInt, buff1
        mov [number], ax
;-------------

;compare
metka1:
        mov ax, [myNumber]
        cmp   ax, [number]
        jl L
        jg K
        je M
M:
        cinvoke printf, guess
        mov al, [lenght]
        mov [buff1], al
        cinvoke printf, buff1
        cinvoke printf, newTry
        cinvoke gets, buff
        mov al, [buff]
        cmp   al, 0
        je exit
        jne begin
L:
        mov al, [lenght]
        inc al
        mov [lenght], al
        cinvoke printf, more
        jmp metka2
K:
        mov al, [lenght]
        inc al
        mov [lenght], al
        cinvoke printf, less
        jmp metka2
;-----------------
exit:
        invoke ExitProcess,0
        int 21h
;------------------
section '.data' data readable writeable
enterInviting:
        db  'Enter a range of numbers: ', 0
enterNumber:
        db  'Enter a number: ', 0
buff:
        dw ?
buff1:
        dw ?
buff2:
        dw ?
buff3:
        dw ?
guess:
        db 'You are right, steps: ', 0
newTry:
        db ', do you want to try again(0/1): ', 0
more:
        db 'My number is bigger, try again. ', 0
less:
        db 'My number is smaller, try again', 0
section '.idata' import data readable writeable
  library kernel32,'kernel32.dll',\
          crtdll,'crtdll.dll'
  import kernel32,\
         ExitProcess,'ExitProcess'
  import crtdll,\
         printf,'printf',\
         gets,'gets'
    
Post 11 May 2016, 20:01
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 12 May 2016, 01:54
When you use a Win32 exe then you need to use the full size 32-bit registers for addressing and for data transfer to/from the OS. You won't be able to access the lower regions of memory at <64kB.
Post 12 May 2016, 01:54
View user's profile Send private message Visit poster's website Reply with quote
badc0de02



Joined: 25 Nov 2013
Posts: 215
Location: %x
badc0de02 17 May 2016, 14:33
LOL you use 16 bit registers
Post 17 May 2016, 14:33
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.