Assembly Code for Integer Multiplication

Well you all that familiar with C/C++ Programming must know that to multiply value we will use the syntax *, for example a * b, 5 * 4. Computer that has 32 bit register can do this process easily.


Well, back then I got an assignment to create a Assembly program using MCS-51 that is limited to 8 bit memory(max 255) to do the 4 byte multiplication(32 bit integer multiplication in computer). Here is the Assembly Code :

org 00h

byte1 equ 40h
byte2 equ 41h
byte3 equ 42h
byte4 equ 43h
byte1m equ 30h
byte2m equ 31h
byte3m equ 32h
byte4m equ 33h
temp1 equ 48h
temp2 equ 49h
temp3 equ 4ah
temp4 equ 4bh
temp5 equ 4ch
byte1r equ 60h
byte2r equ 61h
byte3r equ 62h
byte4r equ 63h
byte5r equ 64h
byte6r equ 65h
byte7r equ 66h
byte8r equ 67h
ptrbyte equ 68h
ptrres equ 69h
ptrtemp equ 6ah
ctr1 equ 6bh
ctr2 equ 6ch

start: mov r0,#byte1m
mov r1,#temp1
mov ctr1,#4
mov ctr2,#4
mov ptrbyte,#40h
mov ptrres,#60h
mov ptrtemp,#48h
clr c
mov byte1,#11h
mov byte2,#11h
mov byte3,#11h
mov byte4,#11h
mov byte1m,#11h
mov byte2m,#11h
mov byte3m,#11h
mov byte4m,#11h

mplybyte: mov r0,ptrbyte
mov a,@r0 ;a will be the byte that will be processed, start = byte at address 40h
mov r0,#byte1m
mov r1,#temp1
mainprocess: push 0
mov r0,ptrbyte
mov a,@r0
pop 0
mov b,@r0 ;b will the first byte multiplier at address 30h(byte1m)
mul ab
mov r3,a ;save a
mov r4,b ;save b
mov a,@r1 ;get the value of temp byte before that is pointed by r1,start 48h
addc a,r3
mov @r1,a ;store a to address pointed by r1
inc r1 ;add value to point the next temp byte
mov a,@r1
addc a,b
mov @r1,a
inc r0 ;add value of r0 to point the next byte multiplier
djnz ctr2,mainprocess ;counter loop 4 byte

addbyte: mov r0,ptrres ;set r0 to point byte result(start byte1r)
mov ctr2,#5 ;counter for add(5 byte multiplication = 1 byte x 4 byte)
mov r1,#temp1 ;set r1 with the address of first temporary byte, start 48h
addproses: mov a,@r0 ;get the value at address pointed by r0, store in acc
addc a,@r1
mov @r0,a ;store acc to address pointed by r0(start 60h)
inc r0 ;add r0 to point the next address
inc r1 ;add r1 to point the next address
djnz ctr2,addproses ;counter loop for add
nextbyte: inc ptrbyte ;point to next byte
inc ptrres ;shift 1 byte pointer byte result(multiplication properties)
mov ctr2,#4 ;reset parameter
mov temp1,#0
mov temp2,#0
mov temp3,#0
mov temp4,#0
mov temp5,#0
djnz ctr1,mplybyte ;do until 4 byte
end

Well, when I created this code I notice that I'm so lucky not to program like this when I develop my apllication :). Hope you get something from this post.

Best Regards,
Admin

Learning OpenCV Ebook

This is the Learning OpenCV E-book(O'Reilly).

I have uploaded this book into filesharing.

You can download it here :

Well, I will not explain the book, its all about OpenCV.


Open CV Build and Tutorial for Visual Studio 2008

Well, I have been trying OpenCV as a library for Computer Vision developed by Intel. This library can be used by Visual Studio 2005, 2008, Linux, etc.

We can use the OpenCV library for many application involving Image Processing, Machine Learning, Video Processing and others. It is a very good framework for faster development of Computer Vision Application.

To get OpenCV you can go to
http://opencv.willowgarage.com/wiki/


For Windows user you can just download the binary installer for OpenCV. Its size is 25MB. After that you just need to execute the installer, set the install path and OpenCV will be installed in your computer.

For VS2008 user, to use OpenCV library you need to create a new Visual C++ Win32 Console Application. You need to setup some things in the Project->Properties. First thing that you must to set is the properties of Additional include directories.

This will be ~OpenCVInstallPath\include\opencv,

Next, we must set the library object in the Linker->Input in properties. You must set the Additional Dependencies and insert all the file in ~openCVInstallPath\lib

This is the standard setting mode if you want to use the OpenCV library. The full documentation to use OpenCV Library in VS 2008 is in


Well, as a first time user back then, I found some problem when using standard setting. One of the most frustrating problem that is so hard to solve because lack of internet resource is "entrypoint not found in some dll" when I build my application using OpenCV. After searching in the internet, I found that to solve this we need to build OpenCV from Source using CMake.

You can use the OpenCV solution to build your project. I have uploaded all the build version of OpenCV using CMake. You can create new project in this solution and it will prevent you from Linker problem(as Entrypoint not found).

You can download the OpenCV release here, well I call this a framework so that you just to create a new project inside this solution :


You also need to do some standard linker setting that is listed in using OpenCV in VS 2008 in the link I provided above. Note that the linker input file is now located in :

~yourExtractedPath/lib/Debug/

With this way you can easily use the OpenCV Framework and will be prevented from having some trouble because of the linker.

Maybe, later time I will post a tutorial about OpenCV again to develop some application.

Best Regards,
Admin

Changing Styles

I think it has been so long that I haven't updated this blog. Haha, right now, I decide to get active again in this blog. Well the important thing is I will change my post topics regarding ASP.NET -> PHP, Linear Signal and System will be changed into FPGA Practical DSP using Nios II and MATLAB. I will also try to add an article about trends or issue that faced by the technology nowadays. Maybe I will get article from other source. I will also publish some paper and E-book that I downloaded and collected. There will be various topics including paper and E-book, but it will be related to Cryptography, DSP, Image Processing, and others.

Well I think it's enough information for now. Hope you visit my blog.

Best Regards,
Admin

C# Tutorial

I got a good tutorial about how to program with C#. This tutorial is not written by me, but this tutorial gave me a good reference when I was doing my project. This tutorial provides a basic understanding about how to program in C#. The example provided in this tutorial are using Console Application. You can download it here :

C# Tutorial

Best Regards
Admin

Inserting Data to a Table using ADO.NET in ASP.NET

I will share how to insert a row to a table using SQL Query in Microsoft SQL Server using ADO.NET and ASP.NET. In the previous course we learn about the basic of ADO.NET. We learn about how to query a data from a table in a database. The step can be summarized :

  1. Open a connection to database
  2. Specify the SQL Query to perform the operation
  3. Execute the command
To insert a row we need to change the SQL Query. The general expression of SQL Query to insert a row is :

INSERT INTO table_name(fld1,fld2,...) VALUES ('value1', 'value2','value3',...)


And to perform this query, we need to use the method of ExecuteScalar(). The namespaces that need to be added to do this task are :

using System.Data.Sql;
using System.Data.SqlClient;

To summarize it, the code should be like this.

string connectionString = "Your connection String";
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();

SqlCommand command = new SqlCommand();

command.Connection = conn;
command.CommandText = @"INSERT INTO table_name(fld1,fld2)"+
"VALUES ('value1', 'value2')";

command.ExecuteScalar();
conn.Close();

At last a post again...

For a long time, I haven't updated my blog. Maybe since 1 month ago. Now, I try to update it again. There are some things I want to inform you all. I have thought this for some time. Maybe I will change the style of my blog giving tutorial or course. The course and tutorial will be posted in a post and you don't need to download the file. I will try to change this blog as a reference or maybe you can call it a simple handbook so that you can browse this web to find your solution if you have a problem.

I will also post an e-book or article or paper more actively from now on. There are some interesting e-book I got from the internet and I will share it to you all.

I hope that my blog gave benefit to you all. Also I want to apologize for the bad English that this blog used since I'm trying to improve my English by blogging.

Best Regards

Lil' Gariel