News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

pointer usage

Started by Eric4ever, April 27, 2006, 03:13:49 AM

Previous topic - Next topic

Eric4ever

I came across a problem:

there are two buffer(buffer1,buffer2) which has predefinetion contents respectively. just like below:
buffer1  db  20 dup     (65h,02h,...,23h)
buffer2  db  10 dup   (45h,98h,...,88h)

and I want to do the xor operation like this:  88h ^ flag ^ buffer1[i*2] ^ buffer2    (flag  db  23h)
an last store the xor result into the szresult.

i let the esi,edi point to the buffer1,buffer2, so how can i store the xor result?

lea esi,buffer2
lea edi,buffer1
xor ecx,ecx
xor edx,edx
.while ecx < 10
  mov eax,ecx
  div 2             ; [b]not allowed immediate number!  the eax,ecx,edx are all used. is there a better methods?[/b]
  .if edx == 0
    mov al,byte ptr [edi+ecx*2]
    mov ah,byte ptr [esi+ecx]
    xor al,ah
    mov ah,flag
    xor al,ah
    xor al,13h
;; [b]how can i store the al into the szresult?[/b]


thx in advance.


Ratch

Eric4ever,

     How about including the ends of the conditional code and loops when you post your code next time?  Ratch


FLAG = 023H
B EQU BYTE PTR

.DATA?
SZRESULT BYTE 80 DUP (?)

.DATA
BUFFER1  DB  20 DUP   (65H,02H,23H)
BUFFER2  DB  10 DUP   (45H,98H,88H)

.CODE
START:
XOR ECX,ECX
.WHILE ECX < 10
   MOV EAX,ECX
   ROR EAX,1
   .IF !CARRY?
     MOV AL,[BUFFER1+ECX*2]
     XOR AL,[BUFFER2+ECX]
     XOR AL,FLAG OR 013H
     MOV [SZRESULT+ECX],AL
     INC ECX
   .ENDIF
.ENDW

Eric4ever

Quote from: Ratch on April 27, 2006, 04:51:27 AM
Eric4ever,

     How about including the ends of the conditional code and loops when you post your code next time?  Ratch


FLAG = 023H
B EQU BYTE PTR

.DATA?
SZRESULT BYTE 80 DUP (?)

.DATA
BUFFER1  DB  20 DUP   (65H,02H,23H)
BUFFER2  DB  10 DUP   (45H,98H,88H)

.CODE
START:
XOR ECX,ECX
.WHILE ECX < 10
   MOV EAX,ECX
   ROR EAX,1
   .IF !CARRY?
     MOV AL,[BUFFER1+ECX*2]
     XOR AL,[BUFFER2+ECX]
     XOR AL,FLAG OR 013H
     MOV [SZRESULT+ECX],AL
     INC ECX
   .ENDIF
.ENDW


thanks Ratch,

i'll have a try. :U