Hello Cruel, Cruel World.

An example Hello world program, written in Per...

Image via Wikipedia

Lots of people list programming languages that they "know" on their resumé. Since I think the whole process is "look at me! look at me!" pathetic, like code shown in the image, the following is one of many stupid examples of my knowledge. This particular program was an exercise I created to see if I could remember and recreate an entire program from my memory of Intel 386 processor instructions.

I did this mainly because the ability to elegantly hack a machine using a text editor would really scare the crap out of some people. Can you find the unnecessary instructions? Could you optimize this further? I sure could, but I'm not being paid and it's an extremely pointless example.

Select Start - Run - cmd.exe
Create a text file named hello_world.asm in the current directory by cutting and pasting the following code then typing debug < hello_world.asm


a 100
push bp
mov bp,sp
push di
push si
mov si,014c
xor bx,bx
xor ax,ax
mov ax,b800
mov es,ax
es:
cmp byte ptr [0449],07
jz 011e
cs:
mov ax,b800
jmp 0123
mov ax,b000
mov es,ax
mov di,0002
mov ax,di
mov cl,07
shl di,cl
mov cl,05
shl ax,cl
add di,ax
mov ax,0000
shl ax,1
add di,ax
mov ah,0c
cld
cmp byte ptr [si],ff
jz 0146
lodsb
stosw
jmp 013d
pop si
pop di
mov sp,bp
pop bp
ret

e 014c 'Hello World!' FF 00

n hello.com

r bx
0000

r cx
0159

w

Q

Reblog this post [with Zemanta]