News:

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

code clarification

Started by shankle, February 03, 2012, 01:44:00 PM

Previous topic - Next topic

shankle

Can't find a good explanation for this code in the Microsoft Macro Assembler Programmer's guide.
fld1  db '01234',0
esi  value is 2

mov ah, byte ptr fld1[esi]
mov ah, byte ptr[fld1+esi]

I think they are the same - maybe wrong
My program is having fits because of this.
The greatest crime in my country is our Congress

qWord

FLD1 is an FPU-intruction - you can't use 'fld1' as label.
FPU in a trice: SmplMath
It's that simple!

shankle

It is just an example.
Call it bldf1
The greatest crime in my country is our Congress

hutch--

Jack,

What are you trying to do ?

The data,


  nums db "1234",0


is a byte sequence or string if you like.

What are you after, 1 byte in each register ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: shankle on February 03, 2012, 01:44:00 PM
My program is having fits because of this.

Your program is "having fits" because, as qWord rightly noted, you are using bad labels.

include \masm32\include\masm32rt.inc

.code
fldX  db '01234',0
start:
mov esi, 2
movzx eax, byte ptr fldX[esi]

MsgBox 0, str$(eax), "Test:", MB_OK
exit

end start

shankle

Thanks fellows for responding.
I wrote a little program to test the 2 versions as I should have done before belaboring
you all with my problems.
If you compile the program you will see that the two versions of the "mov"
give the same results.
So it is something else causing trouble in the program that I am writing which
I will have to solve.
See attached.
The greatest crime in my country is our Congress

mineiro

This are happening because you "xor esi" Sr shankle.
bldf1            db   '54321',0

     xor esi, esi
     mov ah, byte ptr bldf1[esi]        ;get byte at location zero of bldf1 (index 0)
     mov ah, byte ptr[bldf1+esi]       ;get byte at location esi of bldf1   (index 0)

     inc esi                                    ;index 1
     mov ah,byte ptr [bldf1+esi]      ;bldf1 + index 1

you can put displacement direct in expression too, like:
     mov ah, bldf1             ;ah = 5
     mov ah, [bldf1+1]       ;ah = 4
     mov ah, [bldf1+esi+2]  ;ah = 3
     inc esi
     mov ah, [bldf1+esi+2]  ;ah = 2



shankle

Thank you for responding Sr Mineiro.
That was just a sample to show that the 1st byte gave the same results
with both versions of the "mov" statement.
I f I put that code in a ".while" loop I would have to increment
esi to get to the rest of bldf1.
The greatest crime in my country is our Congress