News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Need Help on Menu

Started by ayao, March 25, 2014, 09:35:03 PM

Previous topic - Next topic

ayao

Hello Everyone Im Trying to Make Simple Menu But When I Add My Program that are not print Chr$

INVOKE ClearScreen
print chr$("                     **************************************************"),0Ah
print chr$("                              PREFINAL  ACTIVITIES:"),0Ah
print chr$("                        *****************************************"),0Ah
print chr$("                           1.Pratice 1"),0Ah
print chr$("                           2.Pratice 2"),0Ah
print chr$("                           3.Main Menu"),0Ah,0Ah
print chr$("                           4.Exit"),0Ah,0Ah
mov choice, sval(input("              Enter Your Choice: "))

cmp choice,1
je case1
cmp choice,2
je case2
cmp choice,3
je case3
cmp choice,4


case1:
    Call pf1
    jmp endswitch
case2:
    Call pf2
    jmp endswitch
case3:
    Call main
    jmp endswitch
case4:
    Call xit
    jmp endswitch

endswitch:



ret
exit

prefi endp ; END OF THE PROCEDURE OF THE PREFINAL

pf1
local choice:sdword

mov choice,sval(input("Press Enter to continue: ")) 
   Call prefi


ret
exit
pf1 endp
; END OF THE PREFINAL ACTIVITY 1


pf2 proc
local choice:sdword

   mov choice,sval(input("Press Enter to continue: "))         
   Call prefi
   ret
exit
pf2 endp
; END OF THE PREFINAL ACTIVITY 2

xit proc
exit
xit endp
;exittttttttt
trap proc
;INVOKE ClearScreen
   print chr$("         Please Enter the options  correctly!!!")
   
      Call main
      ret
trap endp
   
end start


When i tried to add my pratice 1 code  i got this error A2133 register value overwritten by INVOKE what just happen ?
and i add this as well local choice:sdword, local num:sdword,  local lfd:sdword and how should i fix this ?
.386
.model flat, stdcall
option casemap :none

include c:\masm32\include\windows.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\masm32.inc

includelib c:\masm32\lib\masm32.lib
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\user32.lib

.data
    num db "1",0
   
    message1 db " Enter to Start ",0

   message2 db " I have reached the end of practice 1 ",0
     
.data?

    lfd db 2 dup(?)
   
.code
start:

    invoke StdOut, addr message1
    invoke StdIn, addr lfd, 10
    jmp FORLOOP



FORLOOP:

    invoke StdOut, addr num
    invoke StdOut, addr lfd
    invoke atodw, addr num
    inc eax
    invoke dwtoa, eax, addr num
    invoke atodw, addr num
    cmp eax,11
    je DONE
    jmp FORLOOP
   
DONE:

   
    invoke StdOut, addr message2
    invoke StdIn, addr num, 10
    invoke ExitProcess, 0

end start

MichaelW

Your code as posted does not trigger A2133 or any other error, but I can guess what the problem was. If in your dwtoa invoke you left off the ADDR, since num is defined as a byte, and arguments are passed to procedures by pushing them onto the stack, and a byte cannot be pushed directly, ML would use AL as a "scratch" register, and this would overwrite the value in EAX, before the EAX argument is pushed onto the stack (arguments are pushed in right to left order). At least for the older versions ML will do this for any byte argument other than AL. The older versions of ML have bugs that prevent them from doing this all correctly, but basically the goal is something like this:

    mov al, bytearg
    movzx eax, al
    push eax
    ...
    call someprocedure

Well Microsoft, here's another nice mess you've gotten us into.