Author Topic: ud2 opcode  (Read 886 times)

guga

  • Member
  • *****
  • Posts: 1451
  • Assembly is a state of art.
    • RosAsm
ud2 opcode
« 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 ?
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10005
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: ud2 opcode
« Reply #1 on: February 22, 2022, 12:08:36 PM »
Guga,

That opcode does not ring a bell, can you find it in an Intel manual ?
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13306
  • Assembly is fun ;-)
    • MasmBasic
Re: ud2 opcode
« Reply #2 on: February 22, 2022, 12:09:19 PM »
Just use db 0Fh, 0Bh (you'll see in the debugger what it does):
Code: [Select]
include \masm32\include\masm32rt.inc
.code
start:
  print "Hello World"
  db 0Fh, 0Bh
  inkey "That was ud2"
  exit
end start

guga

  • Member
  • *****
  • Posts: 1451
  • Assembly is a state of art.
    • RosAsm
Re: ud2 opcode
« Reply #3 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"

Code: [Select]
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.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

  • Member
  • *****
  • Posts: 1451
  • Assembly is a state of art.
    • RosAsm
Re: ud2 opcode
« Reply #4 on: February 22, 2022, 12:20:32 PM »
Ok, Worked after i remove the "large" command

Code: [Select]
fb_DevScrnRead_cold proc near
                mov     eax, ds:38h
db 0Fh, 0Bh
fb_DevScrnRead_cold endp

Tks, Steve and JJ :thumbsup: :thumbsup:
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10005
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: ud2 opcode
« Reply #5 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Gunther

  • Member
  • *****
  • Posts: 4117
  • Forgive your enemies, but never forget their names
Re: ud2 opcode
« Reply #6 on: February 22, 2022, 04:30:29 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.
You have to know the facts before you can distort them.