Sunday, August 10, 2008

Free Online 8085 Assembler and Simulator

Free Online 8085 Assembler and Simulator
I just made this long back, just put it online for anyone that might be interested in using it.

Quick Start

  • Enter the code as shown in the sample in the code view,
  • Click Compile and Simulate.
  • Click HexView to see the hex code of the program
  • Click SimView and Click Step or Exec to simulate the program.


There is a built in special function call for keyboard reads : CALL KBINPUT
Displays a prompt for directly entering into the Accumulator.

In addition memory locations can be assigned in code using
ORG Hex Address
AA BB CC DD
EE FF 00 11
22 33 44 55
66 77
etc

Assembly Source CodeView


HexView


SimView


The SimView Screen is divided into 4 Sections:
  • The extreme left shows the code and highlights the current section being executed.
  • The middle box shows the registers and flags
  • The extreme right shows the stack.
  • The bottom box prints values of memory locations.


More features would be posted as memory comes to me
;)

Friday, August 1, 2008

nVidia Core Temperature too high on my Compaq Presario Lappy

LAPtops as the name stands, conventionally meant to be on the LAP. But in my case not only can it be kept on a lap, it fries everything underneath !
Check out the screenshot!

nVidia GPU Core Temperature Screenshot


This is kinda normal, it gets to 110+ when connected to TV or playing a game!.

The nVidia GeForce card is suspected to do the overheating.
I am using a Compaq Presario V3000 Notebook.
Does any one having a similar series face the problem?
Any Solutions?
Has anyone tried cooking with this lappy? !
Please do comment.

:D

Saturday, July 26, 2008

T9 Dictionary Implementation in C, BASH

/*
t9.c
Dependency : t9.dic
A file with lots of words to populate our t9 trie structure.
All in small letter no spaces no other characters
Terminated by a line with only a 0 (zero)
=================
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct t9
{
struct t9 * node[27];
};

struct t9 * t9_new()
{
struct t9 * r = (struct t9 *)malloc(sizeof(struct t9));

int i=0;
for(;i<27;i++) r->node[i] = (struct t9 *)0;

return r;
}

void t9_free(struct t9 * root)
{
if(root)
{
int i=0;
for(;i<27;i++)
t9_free(root->node[i]);
free(root);
}
}

struct t9 * t9_insert(struct t9 * root ,char *val)
{

if(!root){ root = t9_new(); }

if(!*val) return root;
*val |= ('A' ^ 'a');
char c = *val - 'a';
root->node[c] = t9_insert(root->node[c] ,++val);

return root;
}

void t9_print(char *pre, struct t9 * root,int depth)
{
int i=0,flag=0;
for(;i<27;i++)
{
if(root->node[i])
{
pre[depth]='a'+i;flag=1;
t9_print(pre,root->node[i],depth+1);
pre[depth]=0;
}
}
if(flag == 0)
{
pre[depth]=0;
printf("%s\n",pre);
}
}

int in_mob_ks(struct t9 * root,char val,int o)
{

int a[]={0,3,6,9,12,15,19,22,26};
/* 2=>0 1 2
3=>3 4 5
4=>6 7 8
5=>9 10 11
6=>12 13 14
7=>15 16 17 18
8=>19 20 21
9=>22 23 24 25
*/
if(o && o>=a[val+1]) return -1;


int s=o?o:a[val];
int e=a[val+1];
//printf("From %d-%d",s,e);
for(;s<e;s++)
if(root->node[s])
return s;
return -1;
}

void t9_search_mob(char *pre, struct t9 * root,int depth,char *val)
{

if(*(val+depth)==0)
{
pre[depth]=0;
t9_print(pre,root,depth);
return;
}

int i=in_mob_ks(root,*(val+depth)-'2',0);
if(i==-1)
{
pre[depth]=0;
//printf("%s\n",pre);
}
while(i>=0)
{
pre[depth]=i+'a';
t9_search_mob(pre,root->node[i],depth+1,val);
pre[depth]=0;
i=in_mob_ks(root,*(val+depth)-'2',i+1);
}
}


struct t9 * t9_search(struct t9 * root, char *val)
{
while(*val)
{
if(root->node[*val-'a'])
{
root = root->node[*val-'a'];
val++;
}
else return NULL;
}
return root;
}

int main()
{
struct t9 * root = (struct t9 *) 0;
char a[100],b[100];int i;
FILE *fp = fopen("t9.dic","r");
while(!feof(fp))
{
fscanf(fp,"%s",&a);
if(a[0]=='0')break;
root=t9_insert(root,a);
}

while(1)
{
printf("mob keys 2-9:");
scanf("%s",&a);
if(a[0]=='0')break;
t9_search_mob(b,root,0,a);
}
t9_free(root);
}



V2
Nothin's changed except for the input method and output limited:

/*
t9.c
Dependency : t9.dic
A file with lots of words to populate our t9 trie structure.
All in small letter no spaces no other characters
Terminated by a line with only a 0 (zero)
Input :
2-9 mobile keys
0 for a new word
q to quit
=================
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <termios.h>
#include <unistd.h>

int getch( )
{
struct termios oldt,newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}

int maxdepth = 0;

struct t9
{
struct t9 * node[27];
};

struct t9 * t9_new()
{
struct t9 * r = (struct t9 *)malloc(sizeof(struct t9));

int i=0;
for(;i<27;i++) r->node[i] = (struct t9 *)0;

return r;
}

void t9_free(struct t9 * root)
{
if(root)
{
int i=0;
for(;i<27;i++)
t9_free(root->node[i]);
free(root);
}
}

struct t9 * t9_insert(struct t9 * root ,char *val)
{

if(!root){ root = t9_new(); }

if(!*val) return root;
*val |= ('A' ^ 'a');
char c = *val - 'a';
root->node[c] = t9_insert(root->node[c] ,++val);

return root;
}

void t9_print(char *pre, struct t9 * root,int depth)
{
int i=0,flag=0;

if(depth < maxdepth)
for(;i<27;i++)
{
if(root->node[i])
{
pre[depth]='a'+i;flag=1;
t9_print(pre,root->node[i],depth+1);
pre[depth]=0;
}
}
if(flag == 0)
{
pre[depth]=0;
printf("%s\n",pre);
}
}

int in_mob_ks(struct t9 * root,char val,int o)
{

int a[]={0,3,6,9,12,15,19,22,26};
/* 2=>0 1 2
3=>3 4 5
4=>6 7 8
5=>9 10 11
6=>12 13 14
7=>15 16 17 18
8=>19 20 21
9=>22 23 24 25
*/
if(o && o>=a[val+1]) return -1;


int s=o?o:a[val];
int e=a[val+1];
//printf("From %d-%d",s,e);
for(;s<e;s++)
if(root->node[s])
return s;
return -1;
}

void t9_search_mob(char *pre, struct t9 * root,int depth,char *val)
{

if(*(val+depth)==0)
{
pre[depth]=0;
t9_print(pre,root,depth);
return;
}

int i=in_mob_ks(root,*(val+depth)-'2',0);
if(i==-1)
{
pre[depth]=0;
//printf("%s\n",pre);
}
while(i>=0)
{
pre[depth]=i+'a';
t9_search_mob(pre,root->node[i],depth+1,val);
pre[depth]=0;
i=in_mob_ks(root,*(val+depth)-'2',i+1);
}
}


struct t9 * t9_search(struct t9 * root, char *val)
{
while(*val)
{
if(root->node[*val-'a'])
{
root = root->node[*val-'a'];
val++;
}
else return NULL;
}
return root;
}

int main()
{
struct t9 * root = (struct t9 *) 0;
char a[100],b[100];int i;
FILE *fp = fopen("t9.dic","r");
while(!feof(fp))
{
fscanf(fp,"%s",&a);
if(a[0]=='0')break;
root=t9_insert(root,a);
}

i=0;
while((a[i]=getch()) != 'q')
{
if(a[i]=='0'){i=0;continue;}
if(a[i] >= '2' && a[i] <= '9')
{
i++;
a[i]=0;
maxdepth = i;
printf("%s:\n",a);
t9_search_mob(b,root,0,a);
fflush(stdout);
}
}
t9_free(root);
}


t9.dic

T9 Dictionary sample file

Now in BASH!

#!/bin/bash
# bash script does something outrageous.
# It attempts to reproduce the T9 capability of the Mobile Phones !

# And does it in fewer commands than before!
# Adapted from Rahul's Original T9.sh

umask 077
NUMN=/tmp/numn.$$
trap "exit 1" HUP INT PIPE QUIT TERM
trap "rm -f $DICTN $NUMN" EXIT

cat t9.dic | tr a-z 22233344455566677778889999 > $NUMN

if [ $# -eq 0 ] ; then
echo "Usage : t9.sh "
exit 1;
else
paste -d: $NUMN t9.dic | grep "^$1" | cut -d":" -f2 | sort
fi

Sunday, July 20, 2008

Server Not Found, Fix DNS Problems.

Sometimes wierd things happen,
Server Not Found www.google.com
Or you can get www.kitiyo.com but not rgb.kitiyo.com
Or you cannot get www.somesite.com but your friend can!
Silly DNS Problems.

When we browser and enter a url in the browser's address bar, one of the first step is to resolve the domain name. ie convert the www.server-name.com to the IP address.

If our dns server settings are wrong or if the dns server does not respond, we get the familiar
Server Not Found page.

There are some ways to resolve this.

  1. Get the correcet DNS IP address from the ISP, and get more than one.
  2. Get some free DNS IP address, some of which are given below
    67.138.54.100
    207.225.209.66
    208.67.220.220
    208.67.222.222
  3. Install a local caching dns server that caches servernames and ip address so that subsequent visits can be made faster since resolving is done locally.
    like Ubuntu debian package dnsmasq


Adding name servers
Windows :

  • Click TCP/IP and then click Properties.
  • Add Primary and Secondary DNS Servers.


Linux:
Add the lines to /etc/resolv.conf
nameserver IP.ADD.RES.SSS
nameserver 67.138.54.100


Any more ideas ?

Wednesday, July 16, 2008

Fix the Brightness up/down Button on ubuntu 8.04 running on Compaq Presario V3000

Replace the contents in the following files given by the code given below.

Replace /etc/acpi/video_brightnessup.sh with the following code


#!/bin/bash

CURRENT=$(grep "current:" /proc/acpi/video/VGA/LCD/brightness |awk '{print $2}')


case "$CURRENT" in

100)
echo -n 100 > /proc/acpi/video/VGA/LCD/brightness;
;;
92)
echo -n 100 > /proc/acpi/video/VGA/LCD/brightness;
;;
84)
echo -n 92 > /proc/acpi/video/VGA/LCD/brightness;
;;
76)
echo -n 84 > /proc/acpi/video/VGA/LCD/brightness;
;;
68)
echo -n 76 > /proc/acpi/video/VGA/LCD/brightness;
;;
60)
echo -n 68 > /proc/acpi/video/VGA/LCD/brightness;
;;
52)
echo -n 60 > /proc/acpi/video/VGA/LCD/brightness;
;;
44)
echo -n 52 > /proc/acpi/video/VGA/LCD/brightness;
;;
36)
echo -n 44 > /proc/acpi/video/VGA/LCD/brightness;
;;
28)
echo -n 36 > /proc/acpi/video/VGA/LCD/brightness;
;;
20)
echo -n 28 > /proc/acpi/video/VGA/LCD/brightness;
;;

*) #default case
echo -n 68 > /proc/acpi/video/VGA/LCD/brightness ;
;;
esac


Replace /etc/acpi/video_brightnessdown.sh with

#!/bin/bash

CURRENT=$(grep "current:" /proc/acpi/video/VGA/LCD/brightness |awk '{print $2}')


case "$CURRENT" in

100)
echo -n 92 > /proc/acpi/video/VGA/LCD/brightness;
;;
92)
echo -n 84 > /proc/acpi/video/VGA/LCD/brightness;
;;
84)
echo -n 76 > /proc/acpi/video/VGA/LCD/brightness;
;;
76)
echo -n 68 > /proc/acpi/video/VGA/LCD/brightness;
;;
68)
echo -n 60 > /proc/acpi/video/VGA/LCD/brightness;
;;
60)
echo -n 52 > /proc/acpi/video/VGA/LCD/brightness;
;;
52)
echo -n 44 > /proc/acpi/video/VGA/LCD/brightness;
;;
44)
echo -n 36 > /proc/acpi/video/VGA/LCD/brightness;
;;
36)
echo -n 28 > /proc/acpi/video/VGA/LCD/brightness;
;;
28)
echo -n 20 > /proc/acpi/video/VGA/LCD/brightness;
;;
20)
echo -n 20 > /proc/acpi/video/VGA/LCD/brightness;
;;

*) #default case
echo -n 68 > /proc/acpi/video/VGA/LCD/brightness ;
;;
esac


for other laptops
run as root
 grep "levels:" /proc/acpi/video/VGA/LCD/brightness


And replace the brightness values in the files above.

:)