CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account
You are here: Home / GizmoBlog / MMBasic Language / Language Constructs / Loadable Libraries

Loadable Libraries

The use of defined subroutines and functions should reduce the need to add specialized features to MMBasic. For instance, there have been a few requests to add bit shifting functions to the language. Now you can do that yourself… this is the right shift function:


1
2
3
4
Function RShift(nbr, bits)
  If nbr < 0 or bits < 0 THEN ERROR "Invalid argument"
  RShift = nbr\(2^bits)
End Function


You can now use this function as if it is a part of the language:


1
2
a = &b11101001
b = RShift(a, 3)


After running this fragment of code the variable b would have the binary value of 11101.

The defined subroutine and function is intended to be a portable lump of code that you can insert into any program. This is why MMBasic has the LIBRARY command which allows you to load files containing user defined subroutines and functions into memory. These functions/subroutines are then available to the running program and are indistinguishable from the built-in commands and functions.

So, it would be easy to create a library of bit manipulation functions like that described above and load them within any program that might need them. The same for specialized maths functions, drivers for special hardware and so on.

 

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2021 · Generate Pro Theme on Genesis Framework · WordPress · Log in