I can compile my code, but it's not starts.
I can't understand why.
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'