0

Because the address xxxx:yyyyyyyy is 32 bits in protected mode, I put a 48-bits address in a piece of memory and want to give indirect jmp, here is what I wrote:

mov eax,s1
mov [address],eax
mov ax,SelectorCode32
mov [address+4],ax
jmp  fword [address]

address:dd 0
        dw 0

But the nasm shows that jmp fword [address] is wrong, I've read some suggestions like this, but didn't help either, so what should I do?

Community
  • 1
  • 1
  • See [this](http://en.wikipedia.org/wiki/FWord),and in my situation,a method choose a right tss to jmp,so the address is unknown before it runs,so jmp xxxx:yyyyyyyy is useless. –  Apr 15 '13 at 09:53
  • @AkiSuihkonen You are wrong. What you're talking about is the `JMP ptr16:32` form, but there's also `JMP m16:32`. See your Intel or AMD manual. – Alexey Frunze Apr 15 '13 at 10:11
  • Nasm is a nice family assembler and doesn't know the fword. :) Just `jmp far [address]` should do it. Maybe `jmp far dword [address]` if it's not in 32-bit code. – Frank Kotler Apr 15 '13 at 10:17

1 Answers1

2

The NASM's syntax for near and far calls is different from those of TASM and MASM.

Here are the two options for indirect jumps:

jmp [fptr] ; jump to CS:0x12345678
jmp far [fptr] ; jump to 0xABCD:0x12345678

fptr dd 0x12345678
     dw 0xABCD

You can also always push the far address onto the stack and do retf.

Alexey Frunze
  • 61,140
  • 12
  • 83
  • 180
  • Did this mean that before program is running ,itself already know where to jump?what if i change the address after it is running ? –  Apr 15 '13 at 13:25
  • I do not understand the question. – Alexey Frunze Apr 15 '13 at 13:26
  • sorry my english is poor,let me ask in this way: if i change the [fptr] after it is running,will the program jump to the new address which i gave him? My purpose is that when the program is running ,i make cpu jmp a tss,than i change another tss2,will it jmp to the tss2? –  Apr 15 '13 at 13:34
  • If you change the pointer and then use it, you use the changed pointer, obviously. Is that what you're asking about? – Alexey Frunze Apr 15 '13 at 13:36
  • yeah,that's it.i just want to know whether cpu can jmp dynamically,thank you for your help. –  Apr 15 '13 at 13:41
  • Yep, that's the whole point of having pointers, you can change them to point to different things at different times. – Alexey Frunze Apr 15 '13 at 13:42