flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem with procedures

Author
Thread Post new topic Reply to topic
||CyrUS||



Joined: 11 Mar 2006
Posts: 11
||CyrUS||
Helo everybody!!

I don't understand why fasm have an error, if I put [strout] the strout isn't correct. But if I put this routine on the main proc it will work.

Code:
proc hextostr,outstr,instr

Buf2Msg: 
  mov     ecx,16 
  mov edi,outstr  ; ERROR Invalid value

.anotherchar: 
  mov     al,byte[instr+ecx-1] 
  mov     ah,al 
  and     ax, 0FF0h 
  shr     al,4 
  cmp     al,10 
  jc      .num1 
  add     al,7+20h ;Remove +20h to get uppercase 
 .num1: 
  add     al,30h 
  cmp     ah,10 
  jc      .num2 
  add     ah,7+20h ;Remove +20h to get uppercase 
 .num2: 
  add     ah,30h 
  mov     word[edi+ecx*2-2],ax 
  loop    .anotherchar 
  ret
  endp      
    




main proc
....
invoke lstrlen,[adressemem]
push eax
push [adressemem]
push strhash
call _rwf_md5
push strhash
push md5hash
call hextostr
....
endp

can you help me?? plzz

sorry for my bad english Very Happy [/quote]
Post 13 Jun 2006, 15:19
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Use mov edi, [outstr] since you need to get the pointer you passed to the proc
Post 13 Jun 2006, 15:45
View user's profile Send private message Reply with quote
||CyrUS||



Joined: 11 Mar 2006
Posts: 11
||CyrUS||
Hello, yes I tried mov edi,[outstr]

but the outstr doesn't get the goob value, if I use this routine in the main proc with mov edi,outstr fasm will compile it.
Post 13 Jun 2006, 16:38
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
mov al,byte[instr+ecx-1] <- wrong too. You need to read the content of instr first.

Posible solution:

Code:
proc hextostr,outstr,instr

Buf2Msg:
  push ebx

  mov     ecx,16  
  mov edi, [outstr]
  mov ebx, [instr]

.anotherchar:  
  mov     al, byte[ebx+ecx-1]
.
.
.
pop ebx
ret
endp
    
Post 13 Jun 2006, 17:13
View user's profile Send private message Reply with quote
||CyrUS||



Joined: 11 Mar 2006
Posts: 11
||CyrUS||
hello, I have fond a solution

Code:
proc hextostr
Buf2Msg:
  mov     ecx,16  
  mov edi,md5hash

.anotherchar:  
  mov     al,byte[strhash+ecx-1]
  mov     ah,al  
  and     ax, 0FF0h  
  shr     al,4  
  cmp     al,10  
  jc      .num1  
  add     al,7+20h ;Remove +20h to get uppercase  
 .num1:  
  add     al,30h  
  cmp     ah,10  
  jc      .num2  
  add     ah,7+20h ;Remove +20h to get uppercase  
 .num2:  
  add     ah,30h  
  mov     word[edi+ecx*2-2],ax  
  loop    .anotherchar  
  ret 
  endp    


it works, but this procedure isn't generic , the name of the varibles have to be changed in the procedure.

Thanks Smile
Post 15 Jun 2006, 19:45
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
This works for me
Code:
include 'win32axp.inc'

.data 
  hash    dq $FEDCBA9876543210 
          dq $0123456789ABCDEF 

  strBuff rb 32 
  db 0 

.code 
start: 
  stdcall hextostr, strBuff, hash 
  invoke MessageBox, 0, strBuff, "Hash MD5", 0 
  invoke ExitProcess, 0 

proc hextostr uses ebx edi, strBuff, hash 

  mov     ecx,16 
  mov     edi, [strBuff] 
  mov     ebx, [hash] 

.anotherchar:    
  mov     al,byte[ebx+ecx-1] 
  mov     ah,al    
  and     ax, 0FF0h    
  shr     al,4    
  cmp     al,10    
  jc      .num1    
  add     al,7+20h ;Remove +20h to get uppercase    
 .num1:    
  add     al,30h    
  cmp     ah,10    
  jc      .num2    
  add     ah,7+20h ;Remove +20h to get uppercase    
 .num2:    
  add     ah,30h    
  stosw 
  loop   .anotherchar 

  ret   

endp

.end start    


Regards
Post 16 Jun 2006, 00:21
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.