line 47 and 50 have an 'or' statement, is it possible to use jmp or cmp instead?
Title flipTest
INCLUDE Irvine32.inc
;################################################
SwapIt PROTO :DWORD,:DWORD
stringLengthProc PROTO :DWORD
;################################################
.data
mes1 BYTE "Enter a 5 digit string: ",0
inName DWORD 3 dup(0)
math1 BYTE 2
lpString:DWORD
dwLength:DWORD
;################################################
.code
;************************************************
getNameProc PROC
push edx
mov edx,offset mes1
call WriteString
mov edx,offset inName
mov ecx, sizeof inName
call ReadString
pop edx
ret
getNameProc ENDP
;************************************************
stringLengthProc PROC lpString:DWORD
;returns the string length in EAX
push ecx
push edi
mov al,0
or ecx,-1
mov edi,lpString
repnz scasb
or eax,-2
sub eax,ecx
pop edi
pop ecx
call SwapIt offset inName,eax
ret
stringLengthProc ENDP
;************************************************
SwapIt PROC
push ecx
push edx
mov ecx,dwLength
mov edx,lpString
dec ecx
add ecx,edx
jmp short SwpIt1
SwpIt0: mov al,[edx]
mov ah,[ecx]
mov [ecx],al
mov [edx],ah
dec ecx
inc edx
SwpIt1: cmp ecx,edx
ja SwpIt0
pop edx
pop ecx
ret
SwapIt ENDP
;************************************************
main PROC
call getNameProc
INVOKE stringLengthProc,offset inName
; INVOKE SwapIt,offset inName,eax
mov edx,offset inName
call WriteString
call Crlf
exit
main ENDP
;################################################
END main
actually, they are shortcuts for MOV
i should not have used those shortcuts for a beginner - sorry about that
;************************************************
stringLengthProc PROC lpString:DWORD
;returns the string length in EAX
push ecx
push edi
mov al,0
mov ecx,-1
mov edi,lpString
repnz scasb
mov eax,-2
sub eax,ecx
pop edi
pop ecx
ret
stringLengthProc ENDP
;************************************************
and please - remove the call to swapit from the stringlength routine :P
Assembling: flipTest2.asm
flipTest2.asm(16) : error A2108: use of register assumed to ERROR
flipTest2.asm(16) : error A2008: syntax error : dword
flipTest2.asm(17) : error A2108: use of register assumed to ERROR
flipTest2.asm(17) : error A2008: syntax error : dword
flipTest2.asm(40) : error A2005: symbol redefinition : lpString
flipTest2.asm(40) : error A2111: conflicting parameter definition
flipTest2.asm(54) : error A2008: syntax error : ,
flipTest2.asm(61) : error A2111: conflicting parameter definition
Press any key to continue . . .
c:\Users\WUZAMA~1\Desktop\asm\ASM-PR~1>make16 flipTest2
Assembling: flipTest2.asm
flipTest2.asm(16) : error A2108: use of register assumed to ERROR
flipTest2.asm(16) : error A2008: syntax error : dword
flipTest2.asm(17) : error A2108: use of register assumed to ERROR
flipTest2.asm(17) : error A2008: syntax error : dword
flipTest2.asm(40) : error A2005: symbol redefinition : lpString
flipTest2.asm(40) : error A2111: conflicting parameter definition
flipTest2.asm(54) : error A2008: syntax error : ,
flipTest2.asm(61) : error A2111: conflicting parameter definition
Press any key to continue . . .
In stringLengthProc you have defined lpString as a parameter, you also define it as a global in your data section, you can't do that. You must also declare some value for it in the .DATA section, you can't just use lpString :dword. Also, I'm not sure what the rules for CALL are in MASM but I'm sure this is not allowed:
call SwapIt offset inName,eax
Well the program was working as it should before, we just change the 'or's too mov?
http://pastebin.com/JzdzQfNs
I removed one of the lpstring definition and not erroring wildly.
:(
Assembling: flipTest2.asm
flipTest2.asm(16) : error A2108: use of register assumed to ERROR
flipTest2.asm(16) : error A2008: syntax error : dword
flipTest2.asm(17) : error A2108: use of register assumed to ERROR
flipTest2.asm(17) : error A2008: syntax error : dword
flipTest2.asm(54) : error A2008: syntax error : ,
flipTest2.asm(57) : fatal error A1010: unmatched block nesting : stringLengthPro
c
Press any key to continue . . .
Quote from: bcddd214 on December 24, 2011, 03:52:37 AM
Well the program was working as it should before, we just change the 'or's too mov?
I doubt that it worked the way it is written above, the "error A2108: use of register assumed to ERROR" and "error A2008: syntax error : dword" are directly caused by the improper declaration of the lpString and dwLength global variables. The symbol redefinition is directly caused by redefining lpString as a parameter of stringLengthProc. The "call SwapIt offset inName,eax" is the line where you get the "syntax error : ,". Pretty much covers all of the errors I took the time to find, there may be more.
i went over this program again and again
i write it - then you rearrange it and make a mess out of it - lol
then, you ask all kinds of questions about the messed up code
and - let me tell you a secret.....
QuoteWell the program was working as it should before
and the secret is....
when you assemble with errors, the PREVIOUS EXE file is there - so you think it works
you can write your assembly batch files so that the old EXE is deleted
at the end of many of the batch files, they use something like this...
dir %1.*
i like to change it to
dir %1.* /o-d
that way, when the assembly is done - the newest files show up in the DIR list first
if your EXE isn't at the top of the list, you know right away you had an error
http://pastebin.com/tiNKEPzx
I took the 2 variable out of .data and it did clean up some but everywhere I try to redefine them I get nasty errors. Where should I declare them?
Found another error in the first code. You have declared SwapIt PROTO :DWORD,:DWORD (2 parameters) however the procedure is defined as SwapIt PROC (no parameters) this will also throw an error, perhaps MASM exited before the error was encountered though.
Quote from: dedndave on December 24, 2011, 04:07:08 AM
i went over this program again and again
i write it - then you rearrange it and make a mess out of it - lol
then, you ask all kinds of questions about the messed up code
and - let me tell you a secret.....
QuoteWell the program was working as it should before
and the secret is....
when you assemble with errors, the PREVIOUS EXE file is there - so you think it works
you can write your assembly batch files so that the old EXE is deleted
at the end of many of the batch files, they use something like this...
dir %1.*
do I add that @ the command line or in my asm file?
i like to change it to
dir %1.* /o-d
that way, when the assembly is done - the newest files show up in the DIR list first
if your EXE isn't at the top of the list, you know right away you had an error
Quote from: dedndave on December 24, 2011, 04:07:08 AM
i went over this program again and again
i write it - then you rearrange it and make a mess out of it - lol
then, you ask all kinds of questions about the messed up code
and - let me tell you a secret.....
QuoteWell the program was working as it should before
I know it was working and since I changed the or's to mov, it's been all downhill from there
Quote from: donkey on December 24, 2011, 04:10:14 AM
Found another error in the first code. You have declared SwapIt PROTO :DWORD,:DWORD (2 parameters) however the procedure is defined as SwapIt PROC (no parameters) this will also throw an error, perhaps MASM exited before the error was encountered though.
should I remove or add parameter to match them up?
i am not sure what you are doing there, buddy
it looks as though you are mixing win32 code in a dos16 program
oh yeah, dword. duh!
It looks like I just have to fix defining lpString:WORD correctly.
http://pastebin.com/CYJnLm0h
this is a 32 bit program, I forgot. dword is correct. Hmmmm?
I think I am almost there. getting a syntax error but I think I am now defining correctly.
http://pastebin.com/JuWiUe30
Assembling: flipTest2.asm
flipTest2.asm(40) : error A2008: syntax error : dwLength
flipTest2.asm(54) : error A2008: syntax error : ,
flipTest2.asm(57) : fatal error A1010: unmatched block nesting : stringLengthPro
c
Press any key to continue . . .
it is a dword
however you still have a line that is messing you up - line 54
1) that line does not belong in the string length function
i think the SwapIt function calls StringLength or is passed the length - i forget
2) CALL cannot pass parameters - just the name of the routine is allowed
you have that all screwed up
SwapIt PROTO :DWORD,:DWORD
;
;
;
SwapIt PROC
stringLengthProc PROTO :DWORD
;
;
;
stringLengthProc PROC lpString:DWORD dwLength:DWORD
the prototype, PROC line, and the function must match parms :P
for the string length proc, there is only 1 parm - a pointer (lp) to the string
for the SwapIt proc, there are 2 parms, a pointer to the string and the string length
this also means that you do not want to call the swapit function from inside the length function
you want to call the string length function to get the length and use that as one of the parms for SwapIt
oh - one more thing...
parms on the PROC line are seperated by commas
SwapIt PROC lpString:DWORD,dwLength:DWORD
It doesn't seem to like that either my friend.
http://pastebin.com/TnUrJWwP
I think I made your requested changes correctly?
Assembling: flipTest2.asm
flipTest2.asm(40) : error A2111: conflicting parameter definition
flipTest2.asm(61) : error A2008: syntax error : PROTO
flipTest2.asm(65) : error A2008: syntax error : offset
flipTest2.asm(85) : fatal error A1010: unmatched block nesting : SwapIt
Press any key to continue . . .
no
you have the PROTOtypes correct - leave those as they are
for SwapIt
SwapIt PROC lpString:DWORD,dwLength:DWORD
for stringLengthProc
stringLengthProc PROC lpString:DWORD
last one. It doesn't like my line 64. I moved that off the proc definition and tried to bring it into the proc. It's telling me I am stoopid. :(
http://pastebin.com/u7AfuFKq
Assembling: flipTest2.asm
flipTest2.asm(64) : error A2001: immediate operand not allowed
Press any key to continue . . .
remove the line completely, it doesn't appear to do anything anyway. FYI, an offset can be treated as an immediate, you can't change it's value (its calculated at compile time as an RVA then fixed up by the loader). Trying to mov the value in EAX into it is like trying to do a mov 1, eax, the assembler will throw the error you've indicated.
no compile error but she freezes and then crashes out...?
http://pastebin.com/ZB0Fqhwz
i don't know how many times i have told you to remove line 53
also uncomment line 92 and it should work
Here is what I have left.
Assembling: flipTest2.asm
flipTest2.asm(16) : error A2008: syntax error : ConsoleScreen
Press any key to continue . . .
http://pastebin.com/R5q6pa4N
no error but she doesn't flip.
http://pastebin.com/1HBR4TtN
that's because you have line 94 commented out
remove the semicolon from that line
once you have changed that...
remove line 66
remove line 55
not commented out - delete the lines altogether :bg
Thank you.
She works!