Many months ago, one listless Sunday afternoon, I crafted a stupidly inefficient program using the already long-winded
assembly language. This is quite possibly the dumbest way to print "Hello world!" to the
DOS standard output using
NASM...
segment code
..start mov ax,0B800h
mov es,ax
xor di,di
mov cx,2000
mov ah,7
mov al,0
rep stosw ;Clear the screen (just to be safe!)
mov dh,0
mov dl,0
xor bh,bh
mov ah,2
int 10h ;Reset cursor to 0,0
mov ax,data
mov ds,ax
mov ax,0B800h
mov es,ax
xor di,di
mov bx,0
findchar mov cl,0 ;Search every ASCII character from 0...
cmp byte cl,[ds:_message+bx]
je print
inc cl
jmp findchar ;Until required letter is found
print mov ah,7
mov byte al,cl
stosw ;Get char and store character in stdout...
cmp bx,12 ;Check for end of string...
je end
inc bx
jmp findchar ;Then do it all over again!
end mov ax,4C00h
int 21h
segment data
_message db "Hello world!"
A similar effect could probably be achieved in less than ten lines, although saying that, the above program would probably still be more efficient than cout << "Hello world!" (at least with my POS compiler)