Search found 4398 matches

by dodicat
Nov 15, 2017 1:31
Forum: General
Topic: Squares
Replies: 5509
Views: 304837

Re: Squares

Hi Albert 1000000 * 1000000 digits multiply: 64 bit compiler -O3 Difference = 0 Mul_loop Time = 22.80171670438722 Multiplier_7 Time = 40.93220921279863 32 bit compiler -O3 Difference = 0 Mul_loop Time = 60.44105964247137 Multiplier_7 Time = 55.05824228748679
by dodicat
Nov 14, 2017 23:15
Forum: General
Topic: Squares
Replies: 5509
Views: 304837

Re: Squares

Hi Albert Both 64 and 32 bit compilers. 64 bit compiler -Wc -O3 Difference = 0 Mul_loop Time = 0.2358976216055453 Multiplier_7 Time = 0.4173078187741339 Difference = 0 Mul_loop Time = 0.2348204045556486 Multiplier_7 Time = 0.4161710599437356 Difference = 0 Mul_loop Time = 0.2349849981255829 Multipli...
by dodicat
Nov 14, 2017 14:59
Forum: Tips and Tricks
Topic: LeapYear Function (Boolean eval.)
Replies: 126
Views: 1890

Re: LeapYear Function (Boolean eval.)

Here is cdecl naked. But I am not an asm member. Didn't test for speed though. Function LeapYearN naked cdecl(ByVal yea As ULong) As ULong Asm mov ecx, dword ptr [esp + 4] test ecx, 3 setz al jne 0f mov eax, ecx cdq push 100 idiv dword ptr [esp] ' 0, 4, 8, ..., 96, 0 test edx, edx ' mod 100=0 should...
by dodicat
Nov 13, 2017 20:19
Forum: General
Topic: passing strings to external functions
Replies: 23
Views: 293

Re: passing strings to external functions

A little tidy up: #include "win\winsock2.bi" sub GetSiteAddress(stuff as string) dim as WSADATA _wsadate dim as in_addr addr dim as hostent ptr res dim as integer i = 0 WSAStartup(MAKEWORD(2,2),@_wsadate) res = gethostbyname(stuff) if res then print stuff while (res->h_addr_list[i] <> 0) a...
by dodicat
Nov 13, 2017 19:32
Forum: General
Topic: passing strings to external functions
Replies: 23
Views: 293

Re: passing strings to external functions

Here is the C code translated somewhat: '#include <winsock.h> '#include <Windows.h> '#include <stdio.h> '#pragma comment (lib, "ws2_32.lib") '#include "windows.bi" #include "win\winsock2.bi" #include "crt.bi" Dim s as string s="www.freebasic.net" sub...
by dodicat
Nov 13, 2017 16:00
Forum: Beginners
Topic: 32 to 64
Replies: 38
Views: 478

Re: 32 to 64

integer goes to long
uinteger goes to ulong
(as suggested already)

also any pointers (uinteger ptr) to (ulong ptr), especially for graphics.
however things like screeninfo x,y -- x and y remain integers.
also imageinfo.
by dodicat
Nov 13, 2017 12:01
Forum: Tips and Tricks
Topic: LeapYear Function (Boolean eval.)
Replies: 126
Views: 1890

Re: LeapYear Function (Boolean eval.)

All in all I agree with Munair inasmuch that if then ~~ if then, chained is probably the fastest way to handle branching with several condition. Mr Swiss also supported this a while back. and/andalso/or/orelse have their place, but it is more difficult to place them in exactly the correct order. But...
by dodicat
Nov 12, 2017 20:33
Forum: Tips and Tricks
Topic: LeapYear Function (Boolean eval.)
Replies: 126
Views: 1890

Re: LeapYear Function (Boolean eval.)

Hi All Bingo , I've found the slowest. declare function IsDate alias "fb_IsDate"(byref s as zstring ptr ) as long function leapyear(n as long) as long return isdate("29-02-"+str(n)) end function dim as string s for n as long=2000 to 4020 s+= str(n) + iif(leapyear(n),!" -->le...
by dodicat
Nov 12, 2017 19:14
Forum: Tips and Tricks
Topic: LeapYear Function (Boolean eval.)
Replies: 126
Views: 1890

Re: LeapYear Function (Boolean eval.)

Josep Roca I thought you were a fan of andalso rather than and https://www.freebasic.net/forum/viewtopic.php?f=2&t=25976&p=236838&hilit=%2Aandalso%2A#p236838 Maybe orelse in the second bit? I tested gas and gcc (no optimisations) and it is slightly faster (By the way, I apologise for bei...
by dodicat
Nov 12, 2017 14:54
Forum: Beginners
Topic: Serial Com readline
Replies: 12
Views: 241

Re: Serial Com readline

"\n", if operating correctly is chr(10). "\r\n" if operating correctly is chr(13,10) Perhaps there is a char(13,10) at each line end. dim as string buffer buffer ="S1,4.18;"+chr(13,10) buffer+="B1,12.61;" + chr(13,10) buffer+="C1,0;" + chr(13,10) buf...
by dodicat
Nov 12, 2017 14:20
Forum: Tips and Tricks
Topic: LeapYear Function (Boolean eval.)
Replies: 126
Views: 1890

Re: LeapYear Function (Boolean eval.)

With option -O3 -Ofast I get errors: TEMP.asm: Assembler messages: TEMP.asm:199: Error: symbol `Lx2' is already defined TEMP.asm:208: Error: symbol `Lx1' is already defined (This is using Mr Swiss's snippet, derived from jj207) So there are label problems here. O1 and O2 are OK and the execution see...
by dodicat
Nov 12, 2017 11:24
Forum: Beginners
Topic: Serial Com readline
Replies: 12
Views: 241

Re: Serial Com readline

You could work around variable string/literal string by a Find and replace method if "\n" is embedded in the variable string. Maybe: Function FindAndReplace(Text As String,Find As String,Replacement As String) As String Dim s As String=Text var position=Instr(s,Find) While position>0 s=Mid...
by dodicat
Nov 12, 2017 10:43
Forum: Tips and Tricks
Topic: LeapYear Function (Boolean eval.)
Replies: 126
Views: 1890

Re: LeapYear Function (Boolean eval.)

I used the non optimised leap year function a few years ago for a calendar. 1899 is the earliest year, and I have completely forgotten why! 'CALENDAR #include "fbgfx.bi" Dim Shared As Integer xres,yres Screen 19,32,1,FB.GFX_ALPHA_PRIMITIVES Screeninfo xres,yres Windowtitle "FreeBASIC ...
by dodicat
Nov 12, 2017 1:50
Forum: Tips and Tricks
Topic: LeapYear Function (Boolean eval.)
Replies: 126
Views: 1890

Re: LeapYear Function (Boolean eval.)

Processor: Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz (2 CPUs), ~3.0GHz Memory: 4096MB RAM I ran the code on my little app, which is more or less direct shell. But -Ofast doesn't work with Ide Winfbe But OK with Poseidon ide (699 ms) Fbedit -- nothing works. All I can say is asm code seems very temp...
by dodicat
Nov 12, 2017 0:16
Forum: Tips and Tricks
Topic: LeapYear Function (Boolean eval.)
Replies: 126
Views: 1890

Re: LeapYear Function (Boolean eval.)

Here are my results using asm mov [Function], eax as return (From above) elapsed Asm: 593ms 24250000 leap years found (-gen gcc -Wc -O2) -O3 doesn't work elapsed Asm: 594ms 24250000 leap years found (-gen gcc -Wc -Ofast) elapsed Asm: 888ms 24250000 leap years found(-gen gcc only) elapsed Asm: 701ms ...

Go to advanced search