Getting started with NBC on Apple OSX 39040

Posted by Tom Sat, 30 Sep 2006 21:20:00 GMT

NBC means NeXT Byte Code and is an assembler like programming language for the LEGO Mindstorms NXT programmable brick. It uses the default LEGO firmware. What follows is a tutorial on how to start programming using your Mac and NBC.

Writing and compiling the code

First download NBC (I’ve used version 1.0.1 b8) from the NBC homepage. This will usually download onto your desktop. The editor I use is TextMate, it’s not expensive and is very usable. Later I will publish a TextMate Bundle for NBC, so that it’ll become easier to start programming. Now type or cut-and-paste the following code (which I stole from here) in TextMate and save the file as helloworld.nbc:
#include "NXTDefs.h"
// Always include the above

// Segments declare variables or types
dseg segment 
  // Variables are always global.
  // Define variable dtArgs of type TDrawText
  dtArgs TDrawText /* see Syscall DrawText docs */
dseg ends 

// Code is organized in threads 
thread main
  // Set is to store scalar constants
  // For instance, set X location to 1
  // X is a member of the TDrawText struct
  set dtArgs.Location.X, 1
  set dtArgs.Location.Y, 1
  set dtArgs.Options, 1 /* erase previous text */
  // Mov is to copy more complex data
  mov dtArgs.Text, 'Hello World'

  // Write to the screen 
  // by calling the Lego firmware
  syscall DrawText, dtArgs

  // Wait forever so the user sees the screen
Endless:
  jmp Endless
endt

Okay now you need to start Terminal.app and run nbc:

Make sure the extension of your sourcecode is .nbc, the extension of the output file is .rxe and the command you type is: ./nbc helloworld.nbc -O=helloworld.rxe. For more command-line options type ./nbc -help.

Putting it on the brick

Currently the Mac version of the NBC program is not capable of downloading your program to the NXT brick, like the Windows version does, so we’ll need to use the Mindstorms NXT software which came with your kit:

First start the software and start you’re brick (press the orange button). Now we need to download to you’re brick, the simplest way of achieving this I think is by pressing the New program GO button:

Now click the NXT Window button and open the Memory tab:

Click the Download button and find your helloworld.rxe application:

Click the Ok button and … that’s it! Now start helloworld from your brick! Quit the Mindstorms NXT application and don’t save the program (as there isn’t any programming done in the LEGO Mindstorms application). Do save your helloworld.nbc program of course!

Afterthoughts and future

Some afterthoughts and something on the future on NXT and Mac:
  • In the near future NBC on Mac OSX will very likely support auto-downloading to your brick, which simplifies things drastically.
  • TextMate supports Bundles, which are helpers to simplify programming for you. In the near future I will create such a TextMate Bundle and publish it on this site
  • This site is built using Typo and uses NBC code syntax highlighting using the default plugin of Typo and a NBC specific class to do the highlighting. I will publish this later.
For any hints, suggestions and or tips mail me at: tom at degrunt dot nl

Comments

Leave a response

  1. ryan Tue, 31 Oct 2006 04:10:11 GMT

    Thanks. As an OS X user, I appreciate the tutorial.

  2. Derk Wed, 06 Dec 2006 20:19:42 GMT

    thanks for the info, looking forward to a textmate bundle :)

  3. NIK nikola3000@gmail.com Fri, 12 Jan 2007 08:43:41 GMT

    I have trouble compiling the the helloworld.nbc I type ./nbc helloworld.nbc -0=helloworld.rxe in the terminal. It seems to compile but there is no output file. Can you please help me

  4. Yama Sat, 13 Jan 2007 14:48:46 GMT

    Carsten Müller has a really cool universal binary called NXTBrowser. It’s superb for uploading files compiled using NBC.

    I had just started writing my own app – (you can have a look on nxtdev.org) but Carsten’s work meets my initial goals already.

    As for text editors, I am an old bbedit hack – though I also like Subethaedit for doing paired programming .. at a pinch, one can always use TextEdit .. and for the terminal diehards, there’s always vi.. (laughs quietly)

  5. Yama Sat, 13 Jan 2007 15:18:23 GMT

    NIK—You should be using a capital letter o, not a zero. It represents ‘Output’ . Also, Carsten’s website is at http://web.mac.com/carstenm/iWeb/Lego/NXT/

  6. yomana Sat, 20 Jan 2007 05:01:55 GMT

    the ./nbc -help doent do any thing or any thing else

  7. Yama Wed, 24 Jan 2007 14:40:22 GMT

    Yomana – (1) Create a new folder on your Desktop, called “nbc” (2) Download the latest version of nbc from http://bricxcc.sourceforge.net/nbc/beta/index.html (3) Put that file (nbc-1.0.1.*.osx.tgz) into the nbc folder above. (4) Open/Expand it (it will create a folder called nxt) (5) run Terminal.app (6) in Terminal window, type “cd ~/Desktop/nbc/nxt” and press return (7) in Terminal window, type ”./nbc -help” and press return

  8. Yama Wed, 24 Jan 2007 16:32:42 GMT

    You can also see my own tutorial at http://nxtdev.org/?p=52

  9. Stefan Thu, 12 Apr 2007 22:12:08 GMT

    Hi, is there anywhere a universal bin. version of the nbc compiler? Following this tutorial on an intel mac doesen’t work :/

  10. John Doe Mon, 09 Jun 2008 16:42:50 GMT

    3a8661777e069d596632bd650cc9c3f8

  11. phiwlc Thu, 12 Jun 2008 08:45:17 GMT

    xhshZT slcikaqnqdiy, [url=http://orlywjzmwejy.com/]orlywjzmwejy[/url], [link=http://yolelzkiacjn.com/]yolelzkiacjn[/link], http://mkhxejtivwor.com/

  12. Pussy would make you happy! http://google.net/group/cute-hd-films/web/">Pussy Sat, 14 Jun 2008 02:23:14 GMT
  13. Cumforcover | http://google.us/group/cumforcover/web/ ">CumForCover Wed, 25 Jun 2008 23:34:18 GMT
  14. Ass Porn | http://google.us/group/ass-porn-videos/web/ ">Ass Porn Thu, 26 Jun 2008 06:02:06 GMT
  15. Creampie | http://google.us/group/creampie-catchies/web/ ">Creampie Thu, 26 Jun 2008 14:01:37 GMT
  16. Hairy Porn | http://google.us/group/hairy-porn-videos/web/">Hairy Porn Thu, 26 Jun 2008 21:05:54 GMT
  17. Cunt | http://google.us/group/private-girls-photos/web/">Cunt Fri, 27 Jun 2008 02:25:36 GMT
  18. AssTraffic | http://google.us/group/asstraffic-girls/web/ ">Jack Fri, 27 Jun 2008 06:12:08 GMT
  19. GiveMePink | http://google.de/group/givemepink-girls/web/">GiveMePink Fri, 27 Jun 2008 11:24:16 GMT
  20. SpermSwap | http://google.us/group/spermswap-girls/web/">Spermswap Fri, 27 Jun 2008 18:53:28 GMT
  21. Primecups | http://google.us/group/primecups-girls/web/">Primecups Sat, 28 Jun 2008 01:55:09 GMT
  22. Double Penetration | http://google.us/group/double-penetration-movies/web/ ">Penetration Sat, 28 Jun 2008 08:49:12 GMT
  23. DP | http://google.us/group/dp-movies/web/">DP Sat, 28 Jun 2008 15:32:32 GMT
  24. Penetration | http://google.us/group/penetration-photos-and-movies/web/">Penetration Sat, 28 Jun 2008 22:05:11 GMT
  25. Squirt | http://google.us/group/squirt-movies/web/">Squirt Sun, 29 Jun 2008 03:33:50 GMT
  26. Levitra | http://google.us/group/order-levitra-pills/web/">Levitra Pills Sun, 29 Jun 2008 09:01:31 GMT
  27. Fioricet | http://google.us/group/order-fioricet-pills/web/">Fioricet Pills Sun, 29 Jun 2008 14:22:17 GMT
  28. Tramadol | http://google.us/group/order-tramadol-pills/web/">Tramadol Pills Sun, 29 Jun 2008 20:25:48 GMT
  29. Refinance | http://google.us/group/online-refinance/web/">Refinance Pills Mon, 30 Jun 2008 01:25:31 GMT
  30. Free Porn | http://google.us/group/free-porn-porntube-videos/web/">Free Porn Mon, 30 Jun 2008 05:52:12 GMT
  31. Latest News | http://google.us/group/tremendous-latest-news/web/">Latest News Mon, 30 Jun 2008 10:12:49 GMT
  32. News | http://google.us/group/recent-online-news/web/">News Mon, 30 Jun 2008 15:15:06 GMT
  33. Dildo | http://google.us/group/dildo-information/web/">Dildo Mon, 30 Jun 2008 20:51:17 GMT
  34. yomayonifigasebe Tue, 01 Jul 2008 00:25:50 GMT
  35. MILF | http://google.us/group/milf-online/web/">MILF Tue, 01 Jul 2008 02:18:03 GMT
  36. MilfThing | http://google.us/group/milfthing-girls/web/">MilfThing Tue, 01 Jul 2008 07:39:15 GMT

    MilfThing Models! All In One Place! :)

    MilfThing | http://google.us/group/milfthing-girls/web/

  37. Page 1 Tue, 01 Jul 2008 11:01:22 GMT
  38. Page 5 Tue, 01 Jul 2008 11:17:52 GMT
  39. Page 8 Tue, 01 Jul 2008 11:18:08 GMT
  40. Page 1 Tue, 01 Jul 2008 11:58:17 GMT
  41. Page 8 Tue, 01 Jul 2008 12:30:46 GMT
  42. Page 1 Tue, 01 Jul 2008 13:01:58 GMT
  43. Page 5 Tue, 01 Jul 2008 13:02:20 GMT
  44. PurePov | http://google.us/group/purepov-girls/web/">PurePov Tue, 01 Jul 2008 13:07:53 GMT

    PurePov Models! All In One Place! :)

    PurePov | http://google.us/group/purepov-girls/web/

  45. Page 8 Tue, 01 Jul 2008 13:50:35 GMT
  46. Page 1 Tue, 01 Jul 2008 14:05:46 GMT
  47. Page 5 Tue, 01 Jul 2008 14:33:45 GMT
  48. Page 8 Tue, 01 Jul 2008 15:04:01 GMT
  49. Page 1 Tue, 01 Jul 2008 15:08:48 GMT
  50. Page 1 Tue, 01 Jul 2008 16:11:47 GMT
  51. Page 8 Tue, 01 Jul 2008 16:19:26 GMT
  52. Page 1 Tue, 01 Jul 2008 17:07:57 GMT
  53. Page 5 Tue, 01 Jul 2008 17:23:29 GMT
  54. Page 8 Tue, 01 Jul 2008 17:32:19 GMT
  55. Page 1 Tue, 01 Jul 2008 18:10:57 GMT
  56. Page 5 Tue, 01 Jul 2008 18:26:38 GMT
  57. TamedTeens | http://google.us/group/all-tamedteens-girls/web/">TamedTeens Tue, 01 Jul 2008 18:40:34 GMT

    TamedTeens Models! All In One Place! :)

    TamedTeens | http://google.us/group/all-tamedteens-girls/web/

  58. Page 8 Tue, 01 Jul 2008 18:53:24 GMT
  59. Page 1 Tue, 01 Jul 2008 19:13:18 GMT
  60. Page 5 Tue, 01 Jul 2008 19:57:07 GMT
  61. Page 8 Tue, 01 Jul 2008 20:08:23 GMT
  62. Page 1 Tue, 01 Jul 2008 20:17:09 GMT
  63. Page 5 Tue, 01 Jul 2008 21:13:15 GMT
  64. Page 1 Tue, 01 Jul 2008 21:19:36 GMT
  65. Page 8 Tue, 01 Jul 2008 21:22:05 GMT
  66. Page 2 Tue, 01 Jul 2008 22:20:36 GMT
  67. Page 1 Tue, 01 Jul 2008 22:22:34 GMT
  68. Page 8 Tue, 01 Jul 2008 22:35:40 GMT
  69. Page 1 Tue, 01 Jul 2008 23:19:13 GMT
  70. Cute Vagina | http://google.us/group/cute-vagina/web/">Vagina Tue, 01 Jul 2008 23:33:50 GMT

    All Vagina Videos In One Place! :)

    Cute Vagina | http://google.us/group/cute-vagina/web/

  71. Page 2 Tue, 01 Jul 2008 23:42:04 GMT
  72. Page 8 Tue, 01 Jul 2008 23:49:04 GMT
  73. Page 1 Wed, 02 Jul 2008 00:15:50 GMT
  74. Page 2 Wed, 02 Jul 2008 01:03:38 GMT
  75. Page 8 Wed, 02 Jul 2008 01:09:01 GMT
  76. Page 1 Wed, 02 Jul 2008 01:18:29 GMT
  77. Page 1 Wed, 02 Jul 2008 02:21:22 GMT
  78. Page 8 Wed, 02 Jul 2008 02:29:39 GMT
  79. Page 1 Wed, 02 Jul 2008 03:25:27 GMT
  80. Page 8 Wed, 02 Jul 2008 03:43:49 GMT
  81. Page 2 Wed, 02 Jul 2008 03:50:27 GMT
  82. Page 1 Wed, 02 Jul 2008 04:21:33 GMT
  83. Huge Cumshot | http://google.us/group/power-cumshot/web/">Cumshot Wed, 02 Jul 2008 04:37:31 GMT

    All Cumshot Videos In One Place! :)

    Huge Cumshot | http://google.us/group/power-cumshot/web/

  84. Page 5 Wed, 02 Jul 2008 04:57:11 GMT
  85. Page 1 Wed, 02 Jul 2008 05:25:12 GMT
  86. Page 5 Wed, 02 Jul 2008 06:18:17 GMT
  87. Page 11 Wed, 02 Jul 2008 06:22:20 GMT
  88. Page 2 Wed, 02 Jul 2008 07:01:19 GMT
  89. Page 8 Wed, 02 Jul 2008 07:25:26 GMT
  90. Page 5 Wed, 02 Jul 2008 07:38:48 GMT
  91. Page 8 Wed, 02 Jul 2008 08:28:14 GMT
  92. Page 5 Wed, 02 Jul 2008 09:00:08 GMT
  93. Page 8 Wed, 02 Jul 2008 09:32:57 GMT
  94. Pissing Videos | http://google.us/group/pissing-videos/web/">Pissing Videos Wed, 02 Jul 2008 09:54:38 GMT

    All Pissing Videos In One Place! :)

    Pissing Videos | http://google.us/group/pissing-videos/web/

  95. Page 5 Wed, 02 Jul 2008 10:15:21 GMT
  96. Page 8 Wed, 02 Jul 2008 10:29:42 GMT
  97. Page 8 Wed, 02 Jul 2008 11:26:53 GMT