### Author Topic: dq arrays usage  (Read 8460 times)

#### Joao Batista

• Guest
##### Re: dq arrays usage
« Reply #15 on: November 29, 2012, 11:04:40 AM »
ok so this worked:

Code: [Select]
`array dq 5 dup(1.5)i dd 8result dq 2.5pos dd ?avalue dq 0.0sum dq 1.0.codestart:mov ebx,offset arrayadd ebx, iFLD qword ptr [ebx]FSTP avalue FLD avalueFLD sumFADDFSTP qword ptr[ebx]mov ebx,offset arrayadd ebx, iFLD qword ptr [ebx]FSTP avalue FLD avalueFLD resultFCOMfstsw ax sahfJE PRINTOKJMP PRINTNAK`

i'm still not sure if i can get i as a dd from the user (cause it may be double result from another arithmetic expression) .. so .. in case i can't .. is there a way i can use a dq as a dd ?

something like dword ptr[dqvar] ?

#### qWord

• Member
• Posts: 1473
• The base type of a type is the type itself
##### Re: dq arrays usage
« Reply #16 on: November 29, 2012, 11:09:59 AM »
(cause it may be double result from another arithmetic expression) .. so .. in case i can't .. is there a way i can use a dq as a dd ?
you can convert the double value to an integer using FIST[P] (as long as the value is in range of an integer).
MREAL macros - when you need floating point arithmetic while assembling!

#### dedndave

• Member
• Posts: 8825
• Still using Abacus 2.0
##### Re: dq arrays usage
« Reply #17 on: November 29, 2012, 11:13:31 AM »
the ADD EBX,1 doesn't look right
and - if you did want that, you could just use MOV EBX,offset Array+1
but - you don't - lol

this part looks ok, but i would suggest REAL8 PTR
Code: [Select]
`FLD qword ptr [ebx]`
Code: [Select]
`FLD real8 ptr [ebx]`it helps the readability - now, you know at a glance that you are loading a REAL8

generally, i might use QWORD PTR if i were loading an integer
Code: [Select]
`FILD qword ptr [ebx]`loads an 8-byte integer

#### Joao Batista

• Guest
##### Re: dq arrays usage
« Reply #18 on: November 29, 2012, 12:14:04 PM »
mm yeah.. apparently i can't scape of the fact that i need a dd at some point, so i'll just modify my java code, i think it will be easier.

Thanks again guys.. thanks for your help!