Skip to main content

Posts

I am created in the image and likeness of God. I am divine. I am born of God. I am a child of God. Everything I have is God’s gift to me. I do not own anything. Everything comes from and returns to God. I am a child of God. Everyone is my brother. Everyone is my sister. I love each person the way I love myself. I am a child of God. God loves me. In Him alone, I place my faith. This was distributed during our junior’s recollection. I have this posted in my room. I know most of you reading my blog are busied by your jobs and other concerns. I hope this would lighten up your day. Remember, someone out there is ready to back us up especially in times of troubles.

Random number generator in 16-bit DOS assembly

Most code for randomizing is not as short as this one. Try to incorporate this procedure in your code and see how it works! randomize: in al, 40h ; read micro-clock for initial seed mov ah, al in al, 40h xchg al, ah or ax, 1 mov rnum, ax ret Random number will be stored in rnum. Fairly straightforward isn’t it? [Edit] Here’s another solution by sir Eugene Kanindot. This is a 3-digit random number generator. jmp start xxx: mov ah, 02ch int 21h and dl, 0fh cmp dl, 9 ja xxx add dl, 30h mov [di], dl ret delay: mov cx, 0 yyy: mov dx, 0a00h zzz: xor ax, ax dec dx cmp dx, 0 jne zzz loop yyy ret start: lea di, numb call xxx inc di call delay call xxx inc di call delay call xxx mov ah, 09h lea dx, numb int 21h int 20h numb db 4 dup('$')

Coding therapy

This is what I usually do whenever I am tired and hungry. #include <GL/glut.h> void disp(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3d(0.43, 0.12, 1.00); glBegin(GL_POLYGON); glVertex3f(-0.75, -0.75, 0.0); glVertex3f( 0.75, -0.75, 0.0); glVertex3f( 0.75, 0.75, 0.0); glVertex3f(-0.75, 0.75, 0.0); glEnd(); glFlush(); } void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); } void main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(300,300); glutInitWindowPosition(0, 0); glutCreateWindow(argv[0]); init(); glutDisplayFunc(disp); glutMainLoop(); }

Redesigned

[Thesis] Well, it was rejected as expected. Plan B was accepted. Do you know what Plan B is? Look for another project that is. [Redesigned] Got nothing to do right now. I tried redesigning my blog. I was executed in The Reincarnation . I failed to defend my country. I didn’t have any time for offensive moves. Opposing guilds were a step ahead. I had 5 fortresses left and 5 attacks went in. I had no choice. I guess it’s time to quit playing. Redesigning the blog as well as the attitude for a big blow.

Sad

Low grades. Time to say “good bye scholarship.” Anyway, I did my best but I failed. Now I don’t know how to explain this. I really do not want to add any more heartaches to my parents. They’ve spent so much already. I really want to help them. This is really sad. Now they would think again that I’m this irresponsible, careless, and mentally inefficient lad. It’s not too late though. Sad and painful because I did my best then I will just be tagged as irresponsible, careless, you name it.

A new air-soft rifle

So dad bought a new air-soft rifle. Weeee! Now I have two in my room. The new one can adapt a .22 caliber bullet with an improvised hammer. Its recoil kicks a little stronger than when fired with air. Now even if I will ran out of C02 gas tanks it will not stop the fun. Its far and near sights were calibrated perfectly. Unlike my 15-year old air-soft gun whose (0,0) sight lands at six o’ clock.

Flashback

Now I can update my Gentoo box even on a daily basis. Using my 30GB USB mass storage device, I can do so even if my prepaid internet account runs zero. Here’s a short guide for those who haven’t tried this one yet. An emerge –sync alternative would be downloading the latest snapshot on any Gentoo mirror site using a machine with a high-speed connection. You might want to salvage the /usr/portage/distfiles of your machine first before proceeding. kee ~ # rm -r /usr/portage/ kee ~ # tar -xvjf portage-latest.tar.bz2 -C /usr/ ... kee ~ # update-eix Reading Portage settings .. Building database (/var/cache/eix) from scratch .. [0] /usr/portage/ (cache: metadata) Reading 100% [1] /usr/local/portage (cache: none) Reading 100% Applying masks .. Database contains 11268 packages in 149 categories. kee ~ # env-update >>> Regenerating /etc/ld.so.cache... kee / # Now for downloading packages for emerge. kee ~ # emerge -fp package ... 2> somefilename.txt The li...

Bin to hex converter in 16-bit DOS assembly

Just a quick code like putting your keyboard where your brain is. There should be another way of doing this. I hate this code. start: xor al, al xor bl, bl xor cl, cl mov dl, 4 ; use dl as counter input: mov ah, 00 int 16h cmp ah, 1ch je exit cmp al, '0' jb input cmp al, '1' ja input convert: mov cl, dl dec cl ; dl - 1 sub al, 30h ; get original value shl al, cl ; place in the appropriate bit position or bl, al ; save in bl dec dl ; prepare for the next bit jnz input ; must be 4 bits cmp bl, 9 ja letter jbe number letter: add bl, 37h ; because 'A' - 37h is 0Ah jmp here number: add bl, 30h ; because '0' - 30h is 00h here: call display jmp start display: mov ah, 02h ...

Moving on

So I bought my self a 2.5″ hard drive enclosure for about 750 bucks. I wish I have my own tools for constructing a device as such. Instead of going for a 2GB USB flash drive, I chose to salvage the 30GB hard drive of an incapacitated laptop. Cool isn’t it? Though relatively slower than a typical USB flash drive, the storage capacity outweighs it. [To God] Thanks for being there always.

Hetero-stress experience

I didn’t make the CS 315 (Elementary Computer Graphics w/ OpenGL) midterm examination. Sad, but I have to admit that I am mentally, emotionally and physically disturbed these days. It seems that I am carrying a magnet attracting bad luck. I have turned out restless and confused with almost eveything. From waking up to lying down, I don’t know what to do, I don’t know how to start my day. This is the dullest day of my life. Stress, pressure. Some thrive on it, others find the spotlight and the responsibility to be too much for them. It distracts and scares them. The fear translates in to a physical stiffness. Mentally they become less focused and more self-conscious. Thus, their performance deteriorates.

Motion for brain rejuvenation

Confusion, defined by WordWeb as a mental state characterized by a lack of clear and orderly thought and behavior, is infesting my brain. Can someone help me? Is there a cure for that? If serenity is sold in the market then I would pack my self dozens of it. Being a computer science student demands a lot of concentration. I’m on a worst-case scenario. If anyone of you out there knows how to cast a spell for brain rejuvenation, count me as one of your targets.

Bit masking

I was thinking of the hex to bin converter in the previous post. The fun part there was the extraction of the desired bit. With the knowledge in mind, it resulted me to devise a function in C that uses a mask to print out the bit representation of an integer. void bitprint(int a) { int i; int n = sizeof(int) * CHAR_BIT; int mask = 1 << (n - 1); for (i = 1; i <= n; ++i) { putchar(((a & mask) == 0) ? '0' : '1'); a <<= 1; if (i % CHAR_BIT == 0 && i < n) putchar(' '); } } CHAR_BIT is defined in limits.h and holding a value of 8. Try it, it’s fun. I’m bored, just extending my thanks to beandog for enlisting me in Planet Larry: Gentoo Users’ Blogs .

Hex to bin converter in 16-bit DOS assembly

You can try this out, get the assembler here . This is just a simple hexadecimal to binary converter, a CS217 exercise and not supposed to be pasted here but just for the sake of having a post. Here it is: input: mov ah, 00h int 16h cmp ah, 1ch je exit number: cmp al, '0' jb input cmp al, '9' ja uppercase sub al, 30h call process jmp input uppercase: cmp al, 'A' jb input cmp al, 'F' ja lowercase sub al, 37h call process jmp input lowercase: cmp al, 'a' jb input cmp al, 'f' ja input sub al, 57h call process jmp input loop input process: mov ch, 4 mov cl, 3 mov bl, al convert: mov al, bl ror al, cl and al, 01 add al, 30h mov ah, 02h mov dl, al int 21h dec cl dec ch jnz convert mov dl, 20h int 21h ret exit: int 20h “And my God will meet all your needs according to His glorious riches in Christ Jesus.” - Philip 4:19