Skip to main content

Posts

Please Support My Android Game

Hey everyone, I wrote a game for android called Space Cosmos Defender. Please check it out here  or just type "Space cosmos adventure" on your Google/Play market. Thank you all in advance. Here are some of the the screen-shots of my game. Main menu In game action More Action

Important Lessons to Remember from Assembly Language programming

Okay, so I have been writing assembly language programs for a little bit now and to be honest with everyone, not like it is not obvious, assembly can be very frustrating especially when you write code and it seems to make logical sense.  However, when you run the program, it either says segmentation fault, memory corruption issues, or the program displays a bunch of random text to the screen. Okay so, recently I have been trying to write an application that does something simple using assembly.  The goal was to write a program with Nasm and have it display the number of arguments passed to our program. From my previous posts, we know that ebp+4 contains the return address after the main method is executed.  We also now that ebp+8 is the first parameter passed to main,  ebp+12 is the second parameter, and so on and so on with 4 added to each time.  This is because from the C programming language the main method has a header declaration that is of the following syntax: int main(in
I wrote, with the help of  The Art of Java by Herbert Schildt and James Holmes , a custom parser that evaluates a numerical expression like: "10+32/2".  So the following is the code:   package com.soliduscode.eleanya; import java.util.logging.Handler; /** * * * @author ukaku * */ public class Parser { final int NONE =0; final int DELIMITER =1; final int VARIABLE = 2; final int NUMBER = 3; final int SYNTAX = 0; final int UNBALPARENS=1; final int NOEXP = 2; final int DIVBYZERO=3; final String EOE = "\0"; /**the expression*/ private String exp; /** expression index */ private int expIndex; /**Current token*/ private String token; /**The token type*/ private int tokenType; /** * Return the next token in the expression */ private void getToken(){ //clear values initially tokenType = NONE; token = ""; //check for endl of expression if(expIndex == exp.length()){ token = EOE; return; } //ski

Creating local variables In Assembly

Lets go over how to create local variables inside of a pure assembly source code. Much like always, you will start with a *.asm file that looks like this: source code SECTION .data SECTION .bss SECTION .text global main ;make main available to operating system(os) main: ;create the stack frame push ebp push mov ebp, esp ;destroy the stack frame mov esp, ebp pop ebp ret So, the above is the general layout of an NASM source file.  Our goal here is to create a local variable inside of the main method.  The only way to create a local variable is by using the stack.  Why?  Because we can only declare variable in storage locations and the only available storage locations are: text, bss, and data.  However, text section is only for code, so it is out of the question.  The bss and data sections are appealing, but to declare our "local" variable in these sections will defeat the purpose of these variables being local, t