flat assembler
Message board for the users of flat assembler.

Index > Main > How to do word ptr [200h] in Fasm?

Author
Thread Post new topic Reply to topic
peixe



Joined: 18 Oct 2004
Posts: 2
peixe 03 Nov 2004, 12:52
Hi, I´m trying to move a value stored in memory to a register. For example if the memory value is 200h, the value I´m interested in is word size and I want to store it in dx the code I use is the following:

mov dx, word ptr [200h]

Fasm gives this error: "error: invalid expression."

Is "word ptr" valid in Fasm?

[TopicEdit=from:"word ptr" to:"How to do word ptr [200h] in Fasm?" reason:"Better description of the problem"]Matrix[/TopicEdit]
Post 03 Nov 2004, 12:52
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 03 Nov 2004, 13:14
Code:
mov dx,[200]          ;same value moved
mov dx,word [200]   ;same value moved
mov bx,200
mov dx,[bx]            ;same value moved
mov dl,[bx]             ;move a byte to dl
    

don't need the ptr in fasm and the word is no need because dx is word already


Code:
-r
AX=0000  BX=0000  CX=000F  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1565  ES=1565  SS=1565  CS=1565  IP=0100   NV UP EI PL NZ NA PO NC
1565:0100 8B16C800      MOV     DX,[00C8]                          DS:00C8=0000
-t

AX=0000  BX=0000  CX=000F  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1565  ES=1565  SS=1565  CS=1565  IP=0104   NV UP EI PL NZ NA PO NC
1565:0104 8B16C800      MOV     DX,[00C8]                          DS:00C8=0000
-t

AX=0000  BX=0000  CX=000F  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1565  ES=1565  SS=1565  CS=1565  IP=0108   NV UP EI PL NZ NA PO NC
1565:0108 BBC800        MOV     BX,00C8
-t

AX=0000  BX=00C8  CX=000F  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1565  ES=1565  SS=1565  CS=1565  IP=010B   NV UP EI PL NZ NA PO NC
1565:010B 8B17          MOV     DX,[BX]                            DS:00C8=0000
-t

AX=0000  BX=00C8  CX=000F  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1565  ES=1565  SS=1565  CS=1565  IP=010D   NV UP EI PL NZ NA PO NC
1565:010D 8A17          MOV     DL,[BX]                            DS:00C8=00
-t
AX=0000  BX=00C8  CX=000F  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1565  ES=1565  SS=1565  CS=1565  IP=010F   NV UP EI PL NZ NA PO NC
1565:010F 0000          ADD     [BX+SI],AL                         DS:00C8=00

    

this thread http://board.flatassembler.net/topic.php?t=2158 contained examples coded in MASM translated to FASM
sincerely,
sulaiman chang
Post 03 Nov 2004, 13:14
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 03 Nov 2004, 16:40
You can use either:
Code:
mov dx, word ptr 200h    

ror
Code:
mov dx, word [200h]    

as the "ptr" in fasm does the same what enclosing the value in square brackets, you shouldn't use both at the same time.
Post 03 Nov 2004, 16:40
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 03 Nov 2004, 20:14
if you're a short hand converter from masm, you can do these: Smile
Code:
ptr equ
short equ byte
near equ word
far equ dword

mainloop:
mov bx,word ptr [vartest]
jmp short mainloop
vartest: 
    
Post 03 Nov 2004, 20:14
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.