* *

Coding

Welcome, Guest. Please login or register.
Did you miss your activation email?
November 19, 2017, 01:55:50 AM

Login with username, password and session length

Menu

Members
Stats
  • Total Posts: 12175
  • Total Topics: 1736
  • Online Today: 34
  • Online Ever: 195
  • (February 11, 2014, 01:46:08 PM)
Users Online
Users: 0
Guests: 33
Total: 45
Yahoo!
Baidu (11)

Author Topic: Trying to translate the (C) HIWORD macro ti IB Std  (Read 1553 times)

0 Members and 1 Guest are viewing this topic.

Offline TLaRoche

  • Newbie
  • *
  • Posts: 9
  • Bananas: 0
  • Gender: Male
  • Born to code ... doomed to fail...
Trying to translate the (C) HIWORD macro ti IB Std
« on: August 22, 2015, 04:04:39 AM »
Hello all,

I'm trying to implement the C language HIWORD macro to IBasic Std, and I'm not quite getting it...
Code: [Select]
' Emulated macro declaration
Declare HIWORD (dwValue:Int)

....

Sub HIWORD (dwValue)
Def ret:Word

ret = ((Val (Str$ (dwValue))) / 2^16) & 0x0FFFF
Return ret
As you can see with this latest version of the macro -- I'm converting the value to a string, then taking the "Val" of that, but it just isn't working right (I think at the Str$ statement).

Thanks in advance,
Tochillo
Just finished backing up to the ol' tape backup drive ... again. Maybe this time restore will work...

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Trying to translate the (C) HIWORD macro ti IB Std
« Reply #1 on: August 22, 2015, 07:48:13 AM »
if you are looking for the value of the high 16 bits then


Declare HIWORD (dwValue:Int)
def ret:int
 ret = (dwValue >> 16) && 0x0FFFF
return ret
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

Offline TLaRoche

  • Newbie
  • *
  • Posts: 9
  • Bananas: 0
  • Gender: Male
  • Born to code ... doomed to fail...
Re: Trying to translate the (C) HIWORD macro ti IB Std
« Reply #2 on: August 24, 2015, 08:53:04 PM »
Hi Larry,

Thank you for responding. I am not getting the right output from the proc you posted (which I tried to exhaustion before the version that I posted above.

I'm wondering if I should declare a UINT in the proc and see if I get the right output when the siign bit is high... I'll have to try it out later when I get back to my system. I'll try to post the results either way for the sake of sharing knowledge.

Thanks again for responding.
Just finished backing up to the ol' tape backup drive ... again. Maybe this time restore will work...

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Trying to translate the (C) HIWORD macro ti IB Std
« Reply #3 on: August 25, 2015, 01:14:42 AM »
my bad, this is really all you need
Code: [Select]
SUB HiWord(iWord as UINT),UINT
NewWord = iWord >> 16
RETURN NewWord
ENDSUB

Code: [Select]
SUB LoWord(iWord as UINT),UINT
NewWord = iWord & 0xFFFF
RETURN NewWord
ENDSUB
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

Offline TLaRoche

  • Newbie
  • *
  • Posts: 9
  • Bananas: 0
  • Gender: Male
  • Born to code ... doomed to fail...
Re: Trying to translate the (C) HIWORD macro ti IB Std
« Reply #4 on: August 28, 2015, 10:22:40 AM »
Would believe it ... my system fan blew I'm on one of my laptops for the moment. LOL  ::)

I will try it ASAP. Like I wrote in my last post, I suspected that I would need to declare a UINT. I was thinking a little more like this code (to make it a little more agreeable with the rest of the code:
Code: [Select]
Declare HIWORD (iWord:INT), WORD

......

Sub HIWORD (iWord)
Def NewWord:UINT
NewWord = (iWord / (2^16))
Return NewWord

Hopefully, this will allow my (INT) vars to pass through with ease.

Thanks again for your help with this problem.
Just finished backing up to the ol' tape backup drive ... again. Maybe this time restore will work...

 

To link to us use this code/button on your site

http://www.codingmonkeys.com/images/cm_link.gif

ShoutBox!

 

lurkalot

September 20, 2017, 01:57:54 PM
Hey that's my job. Didn't choose this username for nothing you know.  :)
 

Larry McCaughn

September 19, 2017, 12:24:13 AM
lurking in the shadows, lurkalot.
 

lurkalot

September 16, 2017, 04:39:43 PM
Good evening all.  Where is everyone?
 

lurkalot

September 12, 2017, 12:57:36 PM
Good to hear, it's nice to see a empty error log. ;)
 

Blue Steel

September 12, 2017, 05:04:25 AM
running sites log files overnight heres the result (I know mainly spiners) "There are currently no error log entries." :)
 

lurkalot

September 12, 2017, 03:19:33 AM
Morning all.  :)
 

Blue Steel

September 12, 2017, 01:12:33 AM
Let it all out ..
these are the things I can't do without  ;)

MikeHart

September 11, 2017, 11:14:22 PM
SHOUT SHOUT  :)
 

GWS

September 11, 2017, 08:16:02 PM
Shouting is Go !  ;D
 

Blue Steel

September 11, 2017, 06:54:02 PM
gradually getting there
 

lurkalot

September 11, 2017, 05:22:46 PM
Yay, you found it.  ;)
 

Larry McCaughn

September 11, 2017, 01:07:13 PM
looks like you're making good progress
 

Blue Steel

September 07, 2017, 10:34:19 PM
yay recent topics are working again in the center of the home page :)
 

Larry McCaughn

July 12, 2017, 05:46:33 PM
Blue Steel is back running the show.  Maybe he'll be able to build some steam in the ole place!
 

Blue Steel

June 26, 2017, 04:58:41 AM
hope i didn't scare too many of you
 

Blue Steel

June 26, 2017, 04:58:12 AM
Boo, i'm still here alive and well , see my post in introductions

MikeHart

July 25, 2016, 01:43:24 AM
That sounds cool. Have to chekc out IWBasic in the next days.
 

Larry McCaughn

July 22, 2016, 11:47:00 PM
I'm hoping to issue a new maintenance release to the IWBasic 3.x IDE in the next few weeks and Larry Sikes has released an update to the Linux version of IWBasic and is currently working on the 64bit version of IWBasic.  Progress should speed up since he has retired and has apparently resolved his m

MikeHart

July 19, 2016, 02:53:02 PM
Anything interesting going on around BASIC?
 

Larry McCaughn

July 18, 2016, 09:14:12 AM
Hello Mike

MikeHart

July 16, 2016, 04:33:25 PM
Hi there all!
 

pistol350

June 24, 2016, 03:41:10 AM
Hello all!
I'm still around although less active!
 

Blue Steel

September 08, 2013, 09:34:55 AM
first page of games in arcade are fixed. only 12 more pages to go
 

Blue Steel

September 08, 2013, 08:41:09 AM
Cleared all highscores on the games . i've been asked to see if i can fix them all. please PM me if you find a game in the arcade that doesn't work, there are way too many for me to go through each and every game.