"Curabitur lectus felis, dapibus non, congue et ultrices et ipsum ultrices et ipsum Integer ligula sed dolor purus"

Home

This website serves as the platform for my professional work, and includes my resume and samples of previous accomplishments, it also serves as a blog. Hdelossantos. com outlines my professional and life experience as I try to adapt to life in the mid-west. Additionally, it also serves to give insight into my interests and hobbies.

read more

Writing a *NIX Shell in C

The shell will take in a maximum line length of 512 characters. Additionally it will support batch execution of commands specified in an input file. To call the shell in batch execution mode execute as:

./shell <input file>

The shell will fork and execute each process as a child process so that in the event of an infinite loop the terminal can still respond to the SIGTERM command. Output can be piped to an external file using the “>” operator. In the event that the destination file is not found, it is created with the permissions 755. The permissions and line length can be changed in the parameters in the header file below.

Creating a Register File using Behavioral Verilog

Behavioral Verilog is the most abstract style of Verilog code. The code looks very similar to C, but one has to remember that in hardware operations occur in parallel, and everything is running at once.

This sample register file will be a 16 entries by 8-bits per entry. It will have 2 synchronous write ports, and an asynchronous read port as well as an active low asynchronous reset.

Mean Median and Mode in C++

Yesterday I had to complete a programming exercise as part of a research internship I will be starting Nov. 2nd. I had to create a simple C++ program which would take the mean, median, and mode of a set of numbers of unknown length. I was free to implement it any which way, with the exception of using arithmetic libraries to do my mean, median, and mode computations.

Verilog SyntaxHighlighter Brush

I was trying to add some sample Verilog code on my website, but the code syntax highlighter I use did not have a brush. I made my own Verilog brush for Alex Gorbatchev’s SyntaxHighlighter. Feel free to modify and improve the code. The only thing that I ask is that you share the modifications.

Using a SQLite Database in Android

This tutorial will demonstrate how to use the database adapter created in “Creating a SQLite Database in Android” to add and get data to and from the database to populate a ListView.

Quick and easy Android HTTP POST of JSON string

There are several ways to send data across the internet to a server on the Android. I was recently working on a project and needed to send a JSON string to the server to add data to a database. Additionally in certain cases I wanted to receive data back from the server. The fastest and easiest way to do this was to use HTTP POST android library and capture the response from the server using a response handler. On the server side the response was simply generated by echoing a JSON string.

Creating a SQLite database in Android

This example will show you how to create a somewhat abstracted SQLite adapter on Android. This adapter can then be utilized by your program to do common database functions such as, querying and searching. I start by creating the class DBAdapter in my Android project and declaring the variable data necessary to create the database.

EDIT: The code has been modified since it originally assumed that a key option would be passed for every key. It will now work if no key options are passed. Additionally, “null” can also be passed to it if no key options are desired.

I’ve earned my Android Badge :)

After having been developing Android applications for 2 months I like to think that I have earned my Android badge. Last week at the SHPE conference I was given an android sticker at the Google booth, which now adorns my laptop.

My Laptop's Android

Of course calling myself a developer makes me think of:

Talking Twitter

A week ago, for my mobile device programming class, I had to add text-to-speech and speech-to-text capabilities to a freely available Android program called Twitta. The features I added were very crudely superimposed on the Twitta interface, therefore this edit is by no means polished or intended for production usage.

There are 3 button “S”, “X”, and “R”. “S” starts the playback of all of the tweets which are currently displayed on the screen. Once the user scrolls down and new tweets appear on the screen the button can be pressed again and only the new ones will be read. “X” stops the playback of the messages. “R” prompts the user to speak their tweet. The google speech to text engine converts it to text and is displayed on the edit bar. If the message was wrong, pressing “R” again clears it and prompts for new speech. The message can also be edited with the keyboard. Below is a video of the application in action:

Powers of base 2 between 2 values using array in MIPS

Program requests and reads in exactly one character, which represents an exponent. If the value is acceptable, then the program reads in another value. The program calculates the base 2 power between the user input values, and then stores the calculated values in an array. It then prints the values in the array.

# Assignment 3: Powers of 2 Assembly utilizing Array
# by Hanly De Los Santos
# Copyright ©2009, Hanly De Los Santos. All Rights Reserved.
# http://www.hdelossantos.com
#
# Program requests and reads in exactly one character,
# which represents an exponent. If the value is acceptable, then the
# program reads in another value. The program calculates
# the base 2 power between the user input values, and then
# stores the calculated values in an array. It then prints the
# values in the array.
#
		.text
		.globl __start 

# Load acceptable ascii decimal value for number ranges
# since input is read in as a character.
__start: 	li	$8, 48		# This is the decimal equivalent of 0
		li	$9, 57		# This is the decimal equivalent of 9

# Prompt the user for input.
		la	$11, prompt
		puts	$11

# Grab user input and store value in register 10
		getc	$10
		la	$11, newline	# Create new line
		lb	$17, ($11)
		putc	$17
		add	$15, $10, 0	# Make copy of contents of r10 in r15.
		sub	$15, $15, 48	# Convert char from first input to int.

# Test to determine whether or not the user input value is acceptable.
# If user input is less than 48 and greater than 57, branches to
# exit_donothing, where the user is told the input is wrong.
		bgt	$10, $9, exit_donothing
		blt	$10, $8, exit_donothing
		sub	$10, $10, 48	# After check, convert char to int.

# Prompt user for additional input
		la	$11, prompt2
		puts	$11

# Grab user input and store in r12
		getc	$12
		la	$11, newline	# Create new line
		lb	$17, ($11)
		putc	$17
		add	$18, $10, 0	# Make copy of contents of r12 in r18.
		sub	$18, $18, 48	# Convert char to int.

# Test to determine whether or not the user input value is acceptable.
# If user input is less than 48 and greater than 57, branches to
# exit_donothing, where the user is told the input is wrong.
		bgt	$12, $9, exit_donothing
		blt	$12, $8, exit_donothing
		sub	$12, $12, 48	# After check, convert char to int.

# Determine if the difference between the two user input values is 0
		bnez	$10, neqz
		beqz	$12, special_zero

# Determine difference between 2 values
neqz:		sub	$21, $12, $10	#Store diff of the two values in r21
		bltz	$21, exit_printgtr
		add	$21, $21, 1

# If the value was acceptable, proceed to calculate the power.
		li	$11, 2		# Load multiplier value into $11.
		li	$17, 2		# Initialize 17 to multiplier value

# Check to see if the second usr input is > 1, if it is modify r10 so that
# the calculations can be made properly. This sets r10 = 2. If the second
# input is == 1, then print the results. Must also load 2 into 2nd array
# location here in case the seond input is 1.
		la	$16, powers
		li	$22, 1
		mult	$11, $22
		mflo	$11
		sw	$11, 4($16)
		li	$23, 1
		beq	$23, $12, print_result
		bgt	$10, $23, cont_gtn
		li	$10, 2

# Multiplication loop. While $10 != 0 keep multiplying $17 by 2, and
# decrement $10 by 1 every time this is done. Once $10 == 0, store
# the result.
cont_gtn:	sub	$10, $10, 1	# Since 2^1 has been taken care of
		add	$14, $10, 0
		add	$24, $10, 0
		add	$24, $24, 1

multiply_for:	mult	$17, $11	# Loop to determine the power val
		mflo	$17
		sub	$10, $10, 1
		bnez	$10, multiply_for

# The result is stored in the location of the user input * 4, which would
# give the matching address location on the array. This loops to
# multiply_for while the $10 is != $12.
nextval:	add	$10, $14, 0	# Restores r10 from copy
		mul	$14, $24, 4	# Calculation to determine the
		add	$23, $16, $14	#  location in which to place the
		sw	$17, ($23)	#  resulting power in the array.
		add	$10, $10, 1	# Increment the counters for next
		add	$24, $24, 1	#  iteration.
		add	$14, $10, 0
		li	$17, 2		# restore the multiplier value
		blt	$10, $12, multiply_for
		beq	$10, $12, print_result

# Display the value of the exponential function. This loops through the
# values in the array starting at the first user input until the
# difference between the first and last user input is 0.
print_result:	la	$14, str3
		puts	$14		# Print out "2^"
		li	$v0, 1
		move	$a0, $15
		syscall			# Print out value of user input.
		la	$16, str4
		puts	$16		# Print out '='
		li	$v0, 1
		la	$20, powers	# Calculation to determine the
		mul	$19, $15, 4	#  location of the power value.
		add	$23, $20, $19
		lw	$17, ($23)
		move	$a0, $17
		syscall			# Print out result.
		la	$13, newline	# Create new line
		lb	$12, ($13)
		putc	$12
		sub	$21, $21, 1
		add	$15, $15, 1
		bnez	$21, print_result
		b	endofline

# Print out the result for 2 to the power of 0 if teh two user
# inputs are 0 (special case).
special_zero:	la	$14, str3
		puts	$14		# Print out "2^"
		li	$v0, 1
		move	$a0, $15
		syscall			# Print out value of user input.
		la	$16, str4
		puts	$16		# Print out '='
		li	$v0, 1
		la	$20, powers
		lw	$17, ($20)	# Print first value of array.
		move	$a0, $17
		syscall
		la	$13, newline	# Create new line
		lb	$12, ($13)
		putc	$12
		b	endofline

# If second input is less than or not equal to first input, print mbgtrthan.
exit_printgtr:	la	$13, mbgtrthan
		puts	$13

# If the input is not appropriate, print str2 and exit.
exit_donothing:	la	$13, str2
		puts	$13
		b	endofline

# This is the exit statement.
endofline:	done		# END OF PROGRAM

# Define strings which will be used throughout program
		.data
prompt:		.asciiz "Enter a digit '0'-'9': "
prompt2:	.asciiz "Enter another digit '0'-'9': "
mbgtrthan:	.asciiz "Second digit must be greater than or equal to the first digit.\n"
str2:		.asciiz "Bad user input.  Quitting.\n"
str3:		.asciiz "2^"
str4:		.asciiz " = "
newline:  	.byte  '\n'
		.align 4
powers:		.word	1:10		# Create a 10-element int array.