Skip to main content

Posts

NASM Assembly - Hello World

Whenever you start programming, there is usually the first program that prints the phrase "Hello world" to the screen.  Well, let us keep that tradition and write an entire assembly program that print that message to the screen. ;Our Assembly Program file SECTION .data SECTION .bss SECTION .text The preceding is the standard file format of an assembly program using the Netwide assembler, or NASM. To write something to the screen, we first need to store the value of what we want to render to the screen by declaring variables. ;Our Assembly Program file SECTION .data ourHelloMsg: db "Hello world, we are in assembly", 10, 0 ;our simple message SECTION .bss SECTION .text Next, we want to use some real world practical assembly coding to print this message to the screen.  We could simple using the Linux int80h instruction to tell the operating system to print this message (if you aren't sure what I mean by this, do not worry), however we will use the printf

NASM Programming

Many of you, if you are like me, might be interested in how assembly works.  You will be very surprised that assembly is very very easy, especially after you write a couple of simple programs.  But don't get me wrong, you will be frustrated at first, however that frustration, if you channel it right, will lead to serious life long learning and will give you a deeper appreciation of the beauty of assembly. For more tutorial on assembly and visualization of these information, visit my youtube channel . Okay so lets get started. We will be using Netwide Assembler (NASM) to write our program. The general format of NASM file is this: ;This is a comment SECTION .data ;declare variable here SECTION .bss ;declare actual, dynamic variable SECTION .text ;where your program code/assembly code lives ; Working with Data Section In your .data section, you can declare variables like this: nameOfVariable: db 32 ;this declares a variable names nameOfVariable with byte valu

C++ Smart Pointer

The following is the finalized code for a simple C++ smart pointer as demonstrated by my youtube video:  here Usage: void main(){      ...     Pointer<ObjectType> pointer(new ObjectType);     ... } /*  * Pointer.h  *  *  Created on: Mar 16, 2012  *      Author: ukaku  */ #ifndef POINTER_H_ #define POINTER_H_ #include <iostream> using namespace std ; /**  * Reference represents a counter that will be incremented or decremented as  * the number of references to a pecticular pointer is made;  *  * where data means: a symbol used to point to, or associate to another object  */ class ReferenceCounter { private :     int counter ; public :     ReferenceCounter ( ) {         counter = 0 ;   //initially set to zero     }     void increase ( ) {         counter ++;   //increase it     }     int decrease ( ) {         -- counter ;   //decrease it         if ( counter < 0 ) {             cout << "ReferenceCouner is <

SAT Collision Part 2

In this collision tutorial, we will take more in detail with how exact we get the normals and how we get the intervals.  However, I will not be going in detail regarding vector math needed to understand this, although it is simple and I will eventually post blogs regarding them. Down to business.  Our shape is composed of vertices.  In the case of this rectangle, there is four vertices, in red, and four normals, in brown.  The vertices are self explanatory and the normals describe the orientation or the way a side of the triangle is facing.  Take note that the vertices are defined such that the center of the triangle, not indicated in the picture, is at position(0,0) and all vertices defining the vertex is relative to this location; just like in a normal coordinate system. Now, to get the normal for a side of the rectangle we take two vertices defining an edge of the rectangle and subtract them.  Further, we swap the x, and y components and negate the new y component.  Then we norma

Introduction to SAT

When writing games, collision detection is important, especially one that is fast and robust.  True, you can get away with having a simple rectangular collision detection where your checking if two squares overlay, but that becomes less reliable when objects in your application/game are moving fast and many I good collision detection system is SAT or  Separating axis theorem.  It says that if two convex shapes' (shapes that do not invaginate) projections along their respective normals does not overlap then the shapes do not overlay.  More clearly, if there is any project that separates the two shapes, then there is a collision. That is it. However, this requires further explanation.  A convex shape is like a rectangle, an octagon, or any shape that does not fold into itself.  When using SAT, we use its normals, denoted by brown lines, to project two convex shapes while comparing to see if the two's intervals overlap. If an overlap exist, then a collision is occurring. Her

C++ Interface

In this tutorial we will discuss interfaces in C++ and why one would be of benefit.  First off, an interface serves as a means to have a commonality of usage for varies objects.  What I mean by that is that say you have a class representing a basketball and a class that represents a soccer ball, it is understood that both are used for playing but how they are played with is different.  That difference of how they are used for playing is where interfaces come in. An Interface provides a common way of using a class of type basketball and a class of type soccer ball without having will being able to refer to each different object(basketball or soccer ball) with the same interface. Okay okay, this is confusing so let us take a couple of examples. Without an interface, to have an object of basketball and soccer ball perform the same behavior, playing, you could do this: class BasketBall{ public:      void play(){           cout << "playing with basketball" << end