view annotqt.asm @ 2:eac01194cb9a tip

annotated qt variant (annotqt)
author C. Masloch <>
date Thu, 25 Oct 2012 18:40:16 +0200
line wrap: on
line source
;86dos/nasm/quine       ; annotated qt variant! (but regular payload)
                ; a minimal header has been retained as a necessary
                ;  identifier, which is naturally present both in the
                ;  source and as the program's "sign-on" message
                ; this includes the copyright status and change dates
cpu 8086        ; this variant is semantically valid and entirely
org 256         ;  equivalent to the original, only shorter!
a:              ; short for alpha, this replaces start
mov dx,d        ; short for and replaces data
mov cx,D        ; capital letters replace _size prefixed labels
call c          ; short for converted, formerly disp_converted
mov di,d
l:              ; all labels are short forms, including loop here
mov dx,p        ; prefix and prefix_size here use the same convention
mov cx,P        ;  as described for data and data_size above
call u          ; as d is already taken, this is short for unconverted
mov dx,di
mov al,10
mov cx,-1       ; note the lack of blanks after commas
repne scasb     ;  and of course all the indentation is also missing
mov cx,di
dec cx
dec cx
sub cx,dx
call u
mov dx,s        ; formerly suffix
mov cx,S        ; formerly suffix_size
call u
cmp di,o        ; (see second-to-last line)
jne l
mov dx,e        ; formerly end
mov cx,E        ; formerly end_size
call u
mov ax,4C00h    ; still not an 86-DOS 1.x (less reliable) call style
int 33          ; deeming some rather odd things acceptable here
c:              ; (disp_)converted
mov si,dx
jcxz .d
.l:             ; this could be shortened further to just . (dot)
cmp al,64       ; same as the int 33, 64 is shorter than 40h
jne .n
push cx
push si
call .t
mov dx,q        ; formerly doublequote
mov cx,Q        ; formerly doublequote_size
call u
pop dx
pop cx
loop .l
inc si
lea cx,[si-1]
sub cx,dx
mov bx,1        ; same as the original not using the CP/M-style call
mov ah,64       ; (again 40h written in decimal)
int 33          ;  though it doesn't allow writing dollar signs anyway
retn            ; this could use the ret alias but i dislike it
db '"'
Q equ $-q
db 'db "'       ; such indirection could probably be simplified
P equ $-p
db '",13,10',13,10
S equ $-s
db "o:",13,10
db "D equ $-d",13,10
E equ $-e
d:              ; here comes the qt payload in its full 700-byte glory
db ";86dos/nasm/quine",13,10
db ";public-domain,20110613,20121025,ecm",13,10
db "cpu 8086",13,10
db "org 256",13,10
db "a:",13,10
db "mov dx,d",13,10
db "mov cx,D",13,10
db "call c",13,10
db "mov di,d",13,10
db "l:",13,10
db "mov dx,p",13,10
db "mov cx,P",13,10
db "call u",13,10
db "mov dx,di",13,10
db "mov al,10",13,10
db "mov cx,-1",13,10
db "repne scasb",13,10
db "mov cx,di",13,10
db "dec cx",13,10
db "dec cx",13,10
db "sub cx,dx",13,10
db "call u",13,10
db "mov dx,s",13,10
db "mov cx,S",13,10
db "call u",13,10
db "cmp di,o",13,10
db "jne l",13,10
db "mov dx,e",13,10
db "mov cx,E",13,10
db "call u",13,10
db "mov ax,4C00h",13,10
db "int 33",13,10
db "c:",13,10
db "mov si,dx",13,10
db "jcxz .d",13,10
db ".l:",13,10
db "lodsb",13,10
db "cmp al,64",13,10
db "jne .n",13,10
db "push cx",13,10
db "push si",13,10
db "call .t",13,10
db "mov dx,q",13,10
db "mov cx,Q",13,10
db "call u",13,10
db "pop dx",13,10
db "pop cx",13,10
db ".n:",13,10
db "loop .l",13,10
db ".d:",13,10
db "inc si",13,10
db ".t:",13,10
db "lea cx,[si-1]",13,10
db "sub cx,dx",13,10
db "u:",13,10
db "mov bx,1",13,10
db "mov ah,64",13,10
db "int 33",13,10
db "retn",13,10
db "q:",13,10
db "db '@'",13,10
db "Q equ $-q",13,10
db "p:",13,10
db "db 'db @'",13,10
db "P equ $-p",13,10
db "s:",13,10
db "db '@,13,10',13,10",13,10
db "S equ $-s",13,10
db "e:",13,10
db "db @o:@,13,10",13,10
db "db @D equ $-d@,13,10",13,10
db "E equ $-e",13,10
db "d:",13,10
o:              ; the first label being alpha this last one is omega
D equ $-d