Saturday, March 22, 2008

Qemu and Debian

After a few hiccups, I had a new debian machine running on Qemu in my Ubuntu Gutsy machine

1. sudo apt-get install qemu
2. wget http://cdimage.debian.org/debian-cd/4.0_r3/i386/iso-cd/debian-40r3-i386-CD-1.iso
Ensure the md5 check sum matches with the site(md5sum debian-40r3-i386-CD-1.iso of the file should match what is there on the server). This would save a lot of trouble. Don't skip it.
3. Create the image file
dd if=/dev/zero of=rootfile bs=1M count=2048
4. qemu -cdrom debian-40r3-i386-CD-1.iso -hda rootfile -net user -net nic -boot d
Install only the base system if you want to save time
5. If you complete the above step... Voila you can now boot into your brand new debian machine
qemu -hda rootfile -net user -net nic
Boot into it and get excited about seeing the shell prompt.

No wonder I soooooo love debian..

Saturday, March 15, 2008

New kubuntu system..

Here is something I have to brag out. I scrapped the default (only prescribed) OS on my office laptop and installed Kubuntu- gutsy... What a relief..

Must haves in no particular order
1. Amarok
2. Firefox
3. Compiz
4. Pidgin
5. KNetworkManager
6. Ktorrent (Yes in office laptop.. cant live without it..)
7. Kontact
8. AventailLinuxconnect..


Voila.. I am up and running (Running.. no flying high)...

Life has never been better..
apt-get... never ending list..

Wednesday, March 12, 2008

Torn between C and Java

I started my career 3 years back.. Fresh out of college, I stepped into the wonderful world of C and Linux with a great mentor. I dint realise how lucky I am. I have thrown all that away for a few more bucks and great company name. Tomorrow I shall be committing the sin of opening an Eclipse for the first time. Shame on me...

Sunday, February 24, 2008

Eternal love - Assembly lines

I decided to brush some of basics, before I get on with my life... I picked up random stuff and started reading from middle.

I. First stop
http://asm.sourceforge.net/articles/linasm.html
Assembly
1. AT & T syntax and Intel

a. AT & T prefix % for registers and $ for immeds
movl $1 %eax
movl $0xff %ebx
int $0x80
b. Intel does not use prefix for registers.. mark immeds with b (binary and hexa)
mov eax, 1
mov ebx, 0ffh
int 80h

Note: directions are opposite .. AT&T src dst .. Intel dst src

2. Memory operands
a. Intel
mov ebx, [ebx]
mov ebx, [ebx + 3]
b. AT&T
movl (%ebx), eax
movl 3(%ebx), eax

a. Intel
instr foo segreg:[base + index * scale + disp]
sub eax, [ebx + ecx * 4h - 20h]
b. AT&T
instr %segreg:disp(base, index, scale), foo
sub -0x20(%ebx, %ecx, 0x4), eax


3. Suffix indicate length of operands
l - long, w - word, b - byte

Intel
mov al, bl
mov ax, bx
mov eax, dword ptr [ebx]


AT&T
movb %bl %al
movw %bx, %ax
movl %eax, %ebx

I dint understand something here... free

II. Next stop
http://www.scribd.com/doc/6900/PC-Assembly-Tutorial

1.
6897 - In nibbles (bits) - 1 1010 1111 0001
6897 - In hex 1 a f 1
(Group from right.. This is why hex is important... Hex compresses bits and there is a direct conversion possible)


2. ASCII - Maps simple characters like A - 65 (I guess).. B-66
Uses 1 Byte

To accommodate more characters (many other languages) unicode is used
Uses 2 bytes
(Thats all there to unicode.. and the word sounded like a jargon to me all these days.. which stone was I living under)

3. Compilers convert high level language programs into machine specific instructions for that particular architecture (duh 4 years of education.. you should know it by now...)

4. I remember wagely, the joy of tying instructions in hex on a 8085 / 8086.. and getting the result. World was lot more simple atleast in college


8088 / 8086-
Must read - http://www.cpu-world.com/Arch/8088.html
16 bit registers - Hence segments of size 64 KB possible
Hence to access more than 64KB(1 MB), the special segment registers CS - code, DS - Data, SS - Stack, Extra ES
1. 8088 16 bits
(address) - Lower order byte
(address + 1) - Higher ordere byte
2. 80386 32 bits
(address) - segment lower order
(address + 1) - segment higher order
(address + 2) - offset lower order
(address + 3) - offset higher order
address (segment * 16) + offset
Code segment -
64KB segment, Jump can be short jump within the segment or long jump outside the segment

Reserved locations
0000h - 03ffh ( Interrupt vectors - 32 bit format segment:offset)
fff0h - ffffh (reset starting point)

Code segment: holds the code
All instructions that uses the IP (instruction pointer) retrieves the instruction using CS * 16 + IP

Stack segment:(address) -
All access to Base pointer (BP) and stack pointer(SP) are offsets in segment pointed to SS register.

Data segment:
All access by AX, BX, CX, DX, index registers (SI, DI) are offsets into segment pointed to be DS register

Extra Segment
DI by default is used with data segment. During string manipulation this might be used.. (not very clear - free)

AX (Accumulator)
BX (Base registers)
CX (Counters)
DX (Data)
SP (Stack pointer)
BP (Base pointer)
SI (Source Index)
DI (Destination index)
IP (Instruction pointer)

Flags
OF - Overflow
DF - Direction flag (For string manipulation)
IF - Interrupt enable flag
TF - Single-Step flag
SF - Sign flag
ZF - Zero flag
AF - Auxiliary flag
PF - Parity flag
CF - Carry flag

8086/ 8088 - 16 bit + segments
80286 - Protected mode
80386 - Extends registers 32 bit protected mode - Hence 4GB segments possible.. Bulb.. 4GB process space in linux..
80486/Pentium - MMX
AX - 16 bits EAX - 32 bits

Sunday, February 17, 2008

Career advice C or Java

For the past three years, I have been a hard core C programmer, working on a variety of open source technologies like qmail, netfilter... Six months back I got an offer from a highly respected company. Good company, nice pay, I couldn't resist the offer. Now only problem, everything is Java.. at least in my locale. I am probably the only person trying find my through Java code using vim, ctags and cscope. I cant bring myself to open a eclipse. So I don't know how it works. Anyways, now I am ready to re look at my decision. Should I let my interest in system programming, C, linux kernel pass and start taking up work in Java.. or should I stick to my interests.

If I take up Java.. I am scared I will loose touch with system side.. like how do I filter packets of a particular kind.. How many connections are going to server...


If I don't take up Java.. I might earn the wrath of management. Probably cost me the job, I am now used to the comforts provided here..


I badly want to learn assembly language programming... Work on those for my bread.. Am I living in a well... Do people have such cool jobs.. Am I asking for an non feasible job position. People around me are into Java.. Is this a problem specific to India.. Do these jobs don't get outsourced to India..



This is probably one helluva situation.. and I am not sure which way to go..