Author Topic: Turning a positive register into a negative one.  (Read 1257 times)

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Turning a positive register into a negative one.
« on: November 26, 2021, 04:46:16 AM »
    Hey. I'm trying to move the File Pointer back to it's beggining but am having a hard time. Shouldn't NEG eax do the trick? Could SetFilePointer,hFile,0,0,FILE_BEGIN do the trick? Thanks for helping me out in advance.

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Turning a positive register into a negative one.
« Reply #1 on: November 26, 2021, 07:58:25 AM »
Which value is in eax?
What does the manual say about SetFilePointer?

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: Turning a positive register into a negative one.
« Reply #2 on: November 26, 2021, 08:15:57 AM »
    Hi JJ. EAX has a variable positive number. Also i got over SetFilePointer. Thanks

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Turning a positive register into a negative one.
« Reply #3 on: November 26, 2021, 10:16:10 AM »
Using EAX will probably garrantee that it gets overwritten. Get used to using memory variables where you use EAX as transfer, NEG it then load it into a 32 bit variable.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: Turning a positive register into a negative one.
« Reply #4 on: November 26, 2021, 10:35:49 PM »
Using EAX will probably garrantee that it gets overwritten. Get used to using memory variables where you use EAX as transfer, NEG it then load it into a 32 bit variable.
I prefer the rv macro
Mov variable, rv(apicall,a,b,c)
Some api calls,like SetTextColor and SetBkColor works great with push return value= old RGB color and pop later to restore colors
my none asm creations
http://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Turning a positive register into a negative one.
« Reply #5 on: November 27, 2021, 12:20:35 AM »
That is not a distinction magnus, the rv macro simply feeds the return value (eax) into a variable. Its done as a notation convenience.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: Turning a positive register into a negative one.
« Reply #6 on: November 27, 2021, 01:00:01 AM »
   Thanks guys. You've benn helpful. ty