|
From: | Frank Swarbrick |
Subject: | Re: [open-cobol-list] Internal compiler error |
Date: | Sun, 30 Jun 2013 23:55:24 -0600 |
User-agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 |
Are you sure wrt to floating-point
arithmetic?
>>SOURCE FORMAT IS FREE program-id. fract. data division. local-storage section. 77 double float-long. 77 decimal packed-decimal pic s9(3)v99. 77 bin-decimal binary pic s9(4)v99. 77 zoned-decimal display pic 9(3)v99. procedure division. move 1 to double decimal bin-decimal zoned-decimal divide 10 into double decimal bin-decimal zoned-decimal display double ' ' decimal ' ' bin-decimal ' ' zoned-decimal goback. C:\Users\Frank\src\cobol>fract 0.10000000000000001 +000.10 +0000.10 000.10 (float-long and comp-2 having the same meaning) Looks like floating point to me... (I didn't analyze the generated C code). As for 64-bit, you can push 64 bits on the stack. You must do call BY VALUE, ie: >>SOURCE FORMAT IS FREE program-id. pointer64. data division. working-storage section. 77 int64 comp-5 pic s9(18). procedure division. display int64 call static 'test64' using value int64 goback. This resolves to the following C code: #define cob_s64_t __int64 #define cob_s64_ptr cob_s64_t * static cob_u8_t b_5[8]; /* int64 */ (*(int *) (b_1)) = test64 ((unsigned cob_s64_t)((*(cob_s64_ptr)(b_5)))); Resolving the #defines we have (I believe): (*(int *) (b_1)) = test64 ((unsigned __int64)((*(__int64 *)(b_5)))); But as for returning 64 bits, I believe you are correct that it can't be done with OC 1.1, even the version that Sergey posted recently. The above probably needs to be: (*(__int64 *) (b_1)) = test64 ((unsigned cob_s64_t)((*(cob_s64_ptr)(b_5)))); or (*(cob_s64_t *) (b_1)) = test64 ((unsigned cob_s64_t)((*(cob_s64_ptr)(b_5)))); Frank On 6/30/2013 9:23 PM, Charles Anthony wrote: I am pretty sure that the issues that I couldn't solve in COBOL were related to passing doubles around. C wants to pass doubles by value pushing 64-bits on the stack, and allow 64-bit return values. I was unable to convince OpenCOBOL to push 64-bit values on the stack or deal with 65-bit return-codes. Also, I note that OpenCOBOL always does decimal math, even when the operands are comp-2. I don't know if this is a COBOL thing, or just something not handled because if you want to do that kind of math, go do some FORTRAN. Anyway, I had fun. |
[Prev in Thread] | Current Thread | [Next in Thread] |