Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 511 512 [513] 514 515 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 908519 times)

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7680 on: August 21, 2015, 04:06:43 am »

well try first DIV 0x3FF0000000000000 and rax should be back to SP

Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7681 on: August 21, 2015, 12:46:32 pm »

well try first DIV 0x3FF0000000000000 and rax should be back to SP
I should mention that I haven't actually tried multiplying yet. I was trying to think my way through how DP float multiplication works. I have no idea how the CPU handles the instruction. The program still needs more work before I can actually assemble and test it. The vector registers just seem like a better idea with the amount of work I'd be doing otherwise.

I'm still curious how this works: http://x86asm.net/articles/working-with-big-numbers-using-x86-instructions/#Multiplication
Looking at it again, it appears to be handling a number "bignum" in memory in three pieces. 4 bytes at a time, if I'm understanding correctly. 8 bytes for the original number, 4 bytes of overflow.
« Last Edit: August 21, 2015, 01:07:42 pm by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7682 on: August 21, 2015, 01:12:12 pm »

multiplication is distributive so you can perform the double float operation accumulating the carry over to emulate the double float 128bit

that's not necessary if you are on a 64bit cpu (notice that the sample is using eax, and you rax) because you can fit a single 128bit double in two floats and the cpu has all the instruction needed to support the ?dx:?sx double word operations already

you should start however from your actual program requirement. what's the precision the assignment requires? then you select the appropriate path
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7683 on: August 21, 2015, 01:28:08 pm »

multiplication is distributive so you can perform the double float operation accumulating the carry over to emulate the double float 128bit

that's not necessary if you are on a 64bit cpu (notice that the sample is using eax, and you rax) because you can fit a single 128bit double in two floats and the cpu has all the instruction needed to support the ?dx:?sx double word operations already

you should start however from your actual program requirement. what's the precision the assignment requires? then you select the appropriate path
The precision requirement is 15 decimal places of accuracy (double precision.) The difficulty I'm facing is that I'm trying to multiplying several 64-bit floats together for an accurate 64-bit result. I don't really know how one goes about properly storing and utilizing the intermediate values. In other words, how do I multiply my resultant 128-bit number by the next 64-bit number?

Edit: "In this assignment floating point data must be stored in the SSE component in 64-bit floating point format and floating point arithmetic must be performed in the SSE."
I take it this means xmm registers are mandatory? Didn't know what SSE meant when I first read the assignment. Probably would have saved some time.
« Last Edit: August 21, 2015, 01:32:19 pm by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7684 on: August 21, 2015, 01:40:20 pm »

yep
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7685 on: August 23, 2015, 09:01:17 am »

I think I'm almost done. Just a few errors to sort out.

Code: [Select]
nasm -f elf64 -l sphere.lis -o sphere.o sphere.asm
sphere.asm:115: warning: register size specification ignored
sphere.asm:97: error: invalid combination of opcode and operands
sphere.asm:104: error: invalid combination of opcode and operands
sphere.asm:105: error: invalid combination of opcode and operands
sphere.asm:110: error: invalid combination of opcode and operands
sphere.asm:115: error: invalid combination of opcode and operands

Here's the full assembly program: http://pastebin.com/rG9whDHf
The format is messed up a bit, but I've pointed out the offending lines. Here are the problematic instructions on their own:
Code: [Select]
movsd rbx, [rsp] ;Line 97 Error

movsd xmm0, rax ;Line 104 Error
movsd xmm1, rbx ;Line 105 Error

mulsd xmm1, rax ;Line 110 Error
push qword xmm0 ;Line 115 Error & Warning

Do I need to do something to the data in the rx registers first (i.e., use a convert function or move to memory) before I can use them with the xmm registers? Am I just using the wrong functions?
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7686 on: August 23, 2015, 11:58:49 am »

now, to be honest I haven't worked in assembly since 1997, I could stretch my 32bit knowledge to 64bit world because AMD x64 is just that nice.

however

movsd only works to/from simd register and memory, you can't use immediate values from registers
http://www.jaist.ac.jp/iscenter-new/mpc/altix/altixdata/opt/intel/vtune/doc/users_guide/mergedProjects/analyzer_ec/mergedProjects/reference_olh/mergedProjects/instructions/instruct32_hh/vc202.htm

so store rax in memory then load the value in xmm0 or since it's already there skip the reference altogheter:

movsd xmm0, [rsp]


also avoid mixed mulsd: best is to mulsd two xmm register; acceptable is multiply one register and one location, but you cannot multiply a xmm register with a normal register (see above)

relevant doc
http://www.jaist.ac.jp/iscenter-new/mpc/altix/altixdata/opt/intel/vtune/doc/users_guide/mergedProjects/analyzer_ec/mergedProjects/reference_olh/mergedProjects/instructions/instruct32_hh/vc211.htm
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7687 on: August 23, 2015, 12:17:07 pm »

Thanks, I suspected as much. Apparently the register sets are all separate from each other and can only interact through memory except in a few small cases.

How would you suggest I go about converting the 128-bit surface area into a 64-bit double for the return value? The warning tells me it's ignoring the qword part of "push qword xmm0". I'm not entirely sure what'll happen when I attempt to pop the resulting data into rax.
« Last Edit: August 23, 2015, 12:20:59 pm by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7688 on: August 23, 2015, 12:36:27 pm »

I have some interest of myself of looking into assembler, more specifically z80 assembler (so I can program my calculator :V). Not sure where to begin or find guides, though.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7689 on: August 23, 2015, 12:40:11 pm »

as I said yesterday cvtsd2ss :P
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7690 on: August 23, 2015, 12:44:47 pm »

as I said yesterday cvtsd2ss :P
Will that work? I thought single precision was 32-bit?

I mean, it says 64-bit memory location, but I'm not sure if I'll be losing extra precision down to a regular float.
« Last Edit: August 23, 2015, 12:47:00 pm by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7691 on: August 23, 2015, 12:48:21 pm »

well single and duoble are relative to your instruction set, so that'd be single precision but 64bit, comparable to a double 32bit precision


I think
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7692 on: August 23, 2015, 12:50:12 pm »

well single and duoble are relative to your instruction set, so that'd be single precision but 64bit, comparable to a double 32bit precision


I think
The link seems to suggest otherwise: "The result is stored in the low doubleword of the destination operand, and the upper 3 doublewords are left unchanged."

In addition, it says the destination operand must be a xmm register. Not sure how to store that result in memory properly.
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7693 on: August 23, 2015, 12:50:48 pm »

yeah but the destination operand defines what a word and doubleword is in size. double world should be .dx:.ax independently from word size because backcomp

well, I think this is the boundary of my knowledge. have a pleasant journey ahead and report back your discoveries!
« Last Edit: August 23, 2015, 12:53:06 pm by LoSboccacc »
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7694 on: August 23, 2015, 12:52:08 pm »

I thought a double word was always 4 bytes?
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?
Pages: 1 ... 511 512 [513] 514 515 ... 796