comparison annotqt.asm @ 2:eac01194cb9a tip

annotated qt variant (annotqt)
author C. Masloch <pushbx@38.de>
date Thu, 25 Oct 2012 18:40:16 +0200
parents
children
comparison
equal deleted inserted replaced
1:cc13c6671f25 2:eac01194cb9a
1 ;86dos/nasm/quine ; annotated qt variant! (but regular payload)
2 ;public-domain,20110613,20121025,ecm
3 ; a minimal header has been retained as a necessary
4 ; identifier, which is naturally present both in the
5 ; source and as the program's "sign-on" message
6 ; this includes the copyright status and change dates
7 cpu 8086 ; this variant is semantically valid and entirely
8 org 256 ; equivalent to the original, only shorter!
9 a: ; short for alpha, this replaces start
10 mov dx,d ; short for and replaces data
11 mov cx,D ; capital letters replace _size prefixed labels
12 call c ; short for converted, formerly disp_converted
13 mov di,d
14 l: ; all labels are short forms, including loop here
15 mov dx,p ; prefix and prefix_size here use the same convention
16 mov cx,P ; as described for data and data_size above
17 call u ; as d is already taken, this is short for unconverted
18 mov dx,di
19 mov al,10
20 mov cx,-1 ; note the lack of blanks after commas
21 repne scasb ; and of course all the indentation is also missing
22 mov cx,di
23 dec cx
24 dec cx
25 sub cx,dx
26 call u
27 mov dx,s ; formerly suffix
28 mov cx,S ; formerly suffix_size
29 call u
30 cmp di,o ; (see second-to-last line)
31 jne l
32 mov dx,e ; formerly end
33 mov cx,E ; formerly end_size
34 call u
35 mov ax,4C00h ; still not an 86-DOS 1.x (less reliable) call style
36 int 33 ; deeming some rather odd things acceptable here
37 c: ; (disp_)converted
38 mov si,dx
39 jcxz .d
40 .l: ; this could be shortened further to just . (dot)
41 lodsb
42 cmp al,64 ; same as the int 33, 64 is shorter than 40h
43 jne .n
44 push cx
45 push si
46 call .t
47 mov dx,q ; formerly doublequote
48 mov cx,Q ; formerly doublequote_size
49 call u
50 pop dx
51 pop cx
52 .n:
53 loop .l
54 .d:
55 inc si
56 .t:
57 lea cx,[si-1]
58 sub cx,dx
59 u:
60 mov bx,1 ; same as the original not using the CP/M-style call
61 mov ah,64 ; (again 40h written in decimal)
62 int 33 ; though it doesn't allow writing dollar signs anyway
63 retn ; this could use the ret alias but i dislike it
64 q:
65 db '"'
66 Q equ $-q
67 p:
68 db 'db "' ; such indirection could probably be simplified
69 P equ $-p
70 s:
71 db '",13,10',13,10
72 S equ $-s
73 e:
74 db "o:",13,10
75 db "D equ $-d",13,10
76 E equ $-e
77 d: ; here comes the qt payload in its full 700-byte glory
78 db ";86dos/nasm/quine",13,10
79 db ";public-domain,20110613,20121025,ecm",13,10
80 db "cpu 8086",13,10
81 db "org 256",13,10
82 db "a:",13,10
83 db "mov dx,d",13,10
84 db "mov cx,D",13,10
85 db "call c",13,10
86 db "mov di,d",13,10
87 db "l:",13,10
88 db "mov dx,p",13,10
89 db "mov cx,P",13,10
90 db "call u",13,10
91 db "mov dx,di",13,10
92 db "mov al,10",13,10
93 db "mov cx,-1",13,10
94 db "repne scasb",13,10
95 db "mov cx,di",13,10
96 db "dec cx",13,10
97 db "dec cx",13,10
98 db "sub cx,dx",13,10
99 db "call u",13,10
100 db "mov dx,s",13,10
101 db "mov cx,S",13,10
102 db "call u",13,10
103 db "cmp di,o",13,10
104 db "jne l",13,10
105 db "mov dx,e",13,10
106 db "mov cx,E",13,10
107 db "call u",13,10
108 db "mov ax,4C00h",13,10
109 db "int 33",13,10
110 db "c:",13,10
111 db "mov si,dx",13,10
112 db "jcxz .d",13,10
113 db ".l:",13,10
114 db "lodsb",13,10
115 db "cmp al,64",13,10
116 db "jne .n",13,10
117 db "push cx",13,10
118 db "push si",13,10
119 db "call .t",13,10
120 db "mov dx,q",13,10
121 db "mov cx,Q",13,10
122 db "call u",13,10
123 db "pop dx",13,10
124 db "pop cx",13,10
125 db ".n:",13,10
126 db "loop .l",13,10
127 db ".d:",13,10
128 db "inc si",13,10
129 db ".t:",13,10
130 db "lea cx,[si-1]",13,10
131 db "sub cx,dx",13,10
132 db "u:",13,10
133 db "mov bx,1",13,10
134 db "mov ah,64",13,10
135 db "int 33",13,10
136 db "retn",13,10
137 db "q:",13,10
138 db "db '@'",13,10
139 db "Q equ $-q",13,10
140 db "p:",13,10
141 db "db 'db @'",13,10
142 db "P equ $-p",13,10
143 db "s:",13,10
144 db "db '@,13,10',13,10",13,10
145 db "S equ $-s",13,10
146 db "e:",13,10
147 db "db @o:@,13,10",13,10
148 db "db @D equ $-d@,13,10",13,10
149 db "E equ $-e",13,10
150 db "d:",13,10
151 o: ; the first label being alpha this last one is omega
152 D equ $-d