Bob,

Hmmmmn.

Well, I'm using SMSQ and I get this ...

65537 DIV 65536 = 1
65537 MOD 65536 = 1

128000 DIV 65536 = 1
128000 MOD 65536 = 62464

It's academic, anyway.  This is just an example to show how you _could_ use
these facilities.  Thanks for pointing it out, though.


Adrian

-----Original Message-----
From: ql-users-boun...@lists.q-v-d.com
[mailto:ql-users-boun...@lists.q-v-d.com] On Behalf Of Bob Spelten
Sent: 13 February 2011 13:44
To: ql-us...@q-v-d.com
Subject: Re: [Ql-Users] Ser-USB Driver Update: External Command Interface
(and Progress Update)

Op Sun, 13 Feb 2011 13:10:41 +0100 schreef Adrian Ives
<adr...@acanthis.co.uk>:

> 250 REMark =======================================================
> 260 REMark :
> 270 DEFine FuNction GetDWordResponse$(Cmd%)
> 280 LOCal Response, High%, Low%
> 290 USB_PUTCMD Cmd%
> 300 Response= USB_GETCMD
> 310 High%= Response DIV 65536
> 320 Low%= Response MOD 65536
> 330 RETurn High% & '/' & Low%
> 340 END DEFine GetDWordResponse$
> 350 REMark :
> 360 REMark =======================================================
> 370 REMark :
> 380 DEFine FuNction Get32BitResponse$(Cmd%)
> 390 LOCal Response, High%, Low%
> 400 USB_PUTCMD Cmd%
> 410 Response= USB_GETCMD
> 420 High%= Response DIV 65536
> 430 Low%= Response MOD 65536
> 440 RETurn BIN$(High%,16) & "/" & BIN$(Low%,16)
> 450 END DEFine Get32BitResponse$
>
I think these functions need a little adjustment.
The DIV & MOD functions in S'Basic work on signed Integers and not on Longs.
Value DIV 65536 will always produce zero.
Value MOD 65536 will always produce value.
There probably are Long DIV/MOD functions in some toolkit out there, I just
happened to find one in an old Machine Code book.
Otherwise just use '/' and INT to extract the high% and low% parts.
high%=INT(response / 65536): low%=response -(high% * 65536)

Bob

--
The BSJR QL software site at: http://members.chello.nl/b.spelten/ql/
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to