The MASM Forum

Projects => MASM32 => Topic started by: guga on February 22, 2022, 11:48:27 AM

Title: ud2 opcode
Post by: guga on February 22, 2022, 11:48:27 AM
Does masm support ud2 opcode ?

I´m trying to rebuild a Freebasic routine, and it uses this opcode, but when trying to assemble it mas, gives me this error:

FbRtl.asm(5538) : error A2008: syntax error : ud2

The function i´m trying to create is:

fb_DevScrnRead_cold proc near
                mov     eax, large ds:38h
                ud2
fb_DevScrnRead_cold endp


How to use this ud2 opcode ?
Title: Re: ud2 opcode
Post by: hutch-- on February 22, 2022, 12:08:36 PM
Guga,

That opcode does not ring a bell, can you find it in an Intel manual ?
Title: Re: ud2 opcode
Post by: jj2007 on February 22, 2022, 12:09:19 PM
Just use db 0Fh, 0Bh (you'll see in the debugger what it does):
include \masm32\include\masm32rt.inc
.code
start:
  print "Hello World"
  db 0Fh, 0Bh
  inkey "That was ud2"
  exit
end start
Title: Re: ud2 opcode
Post by: guga on February 22, 2022, 12:13:41 PM
Hi JJ. Tks, but this msg came up

"FbRtl.asm(5537) : error A2206: missing operator in expression"


fb_DevScrnRead_cold proc near
                mov     eax, large ds:38h
;                ud2
db 0Fh, 0Bh
fb_DevScrnRead_cold endp


Btw...the beginniong of the file i´,m using this:

    .686
    .model flat, stdcall
    .xmm
option casemap :none   ; case sensitive


Steve, this opcode is the same as Nop, with the only difference that it raises a opcode exception
https://mudongliang.github.io/x86/html/file_module_x86_id_318.html

I have no idea why Fb (FreeBasic) is using this, but since i´m testing to see if i can build in masm, a Runtime Library of FreeBasic, i chosen to keep the instructions as it is.
Title: Re: ud2 opcode
Post by: guga on February 22, 2022, 12:20:32 PM
Ok, Worked after i remove the "large" command

fb_DevScrnRead_cold proc near
                mov     eax, ds:38h
db 0Fh, 0Bh
fb_DevScrnRead_cold endp


Tks, Steve and JJ :thumbsup: :thumbsup:
Title: Re: ud2 opcode
Post by: hutch-- on February 22, 2022, 01:40:31 PM
Yes, that makes sense, LARGE is an old memory model that would not be compatible with FLAT memory model, I think its a left over from the DOS era.
Title: Re: ud2 opcode
Post by: Gunther on February 22, 2022, 04:30:29 PM
Quote from: hutch-- on February 22, 2022, 01:40:31 PM
... LARGE is an old memory model that would not be compatible with FLAT memory model, I think its a left over from the DOS era.

Yes this is an old left over from DOS, just like TINY, SMALL or MEDIUM for example. Under Win32 that's no longer needed.