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

xandaz

  • Member
  • ***
  • Posts: 468
  • 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: 11760
  • Assembler 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: 468
  • 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: 8727
  • 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: 1810
  • green elevator
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
SIMD fan and macro fan
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8727
  • 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: 468
  • 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