Author Topic: TASM32, MASM32, MASM64 Quines  (Read 8393 times)

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 68
  • Country: ph
    • Webpage
TASM32, MASM32, MASM64 Quines
« on: February 27, 2023, 07:01:58 PM »
Code: [Select]
; Benu

; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]

; 2/27/2023 NYC

; tasm32 benu.asm

; tlink32 ~Tpe ~ap benu.obj,benu.exe,,tmsvcrt.lib,,

.686

.model flat,stdcall

extrn _printf:proc

.code

start:

enter 0,0

mov al,0Dh

mov bl,2Dh

z:lea edx,a

mov cx,1318

r:cmp byte ptr[edx],bl

je s

jmp u

s:mov byte ptr[edx],al

cmp al,2Dh

je c

mov byte ptr[edx+1],0Ah

jmp u

c:mov byte ptr[edx+1],2Dh

u:inc edx

dec cx

cmp cx,0

jnz r

cmp bl,0Dh

je td

push offset a

push offset i

call _printf

jmp ll

td:

lea edi,n

lea esi,a

mov cx,1374

sn:mov al,byte ptr[esi]

mov byte ptr[edi],al

inc esi

inc edi

dec cx

cmp cx,1224

je t

cmp cx,1074

je t

cmp cx,924

je t

cmp cx,774

je t

cmp cx,624

je t

cmp cx,474

je t

cmp cx,324

je t

cmp cx,174

je t

cmp cx,24

je t

jmp sts

t:mov byte ptr[edi],27h

mov byte ptr[edi+1],0Dh

mov byte ptr[edi+2],0Ah

mov byte ptr[edi+3],64h

mov byte ptr[edi+4],62h

mov byte ptr[edi+5],20h

mov byte ptr[edi+6],27h

add edi,7

jmp sts

sts:cmp cx,0

jne sn

push offset n

push offset i

call _printf

ll:mov al,0Dh

cmp bl,2Dh

xchg al,bl

je z

push offset x

push offset i

call _printf

leave

ret

.data

d db 27h,0Dh,0Ah,64h,62h,20h,27h,0

x db 2Ch,32h,37h,68h,2Ch,30h,0Dh,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,0

i db 25h,73h,0

n db 1380 DUP(0)

a db '; Benu--; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]--; 2/27/2023 NYC--; tasm32 benu.asm--; tlink32 ~Tpe ~ap benu.obj,benu.exe,,tmsvcrt.lib,,--'

db '.686--.model flat,stdcall--extrn _printf:proc--.code--start:--enter 0,0--mov al,0Dh--mov bl,2Dh--z:lea edx,a--mov cx,1318--r:cmp byte ptr[edx],bl--je '

db 's--jmp u--s:mov byte ptr[edx],al--cmp al,2Dh--je c--mov byte ptr[edx+1],0Ah--jmp u--c:mov byte ptr[edx+1],2Dh--u:inc edx--dec cx--cmp cx,0--jnz r--cmp'

db ' bl,0Dh--je td--push offset a--push offset i--call _printf--jmp ll--td:--lea edi,n--lea esi,a--mov cx,1374--sn:mov al,byte ptr[esi]--mov byte ptr[edi]'

db ',al--inc esi--inc edi--dec cx--cmp cx,1224--je t--cmp cx,1074--je t--cmp cx,924--je t--cmp cx,774--je t--cmp cx,624--je t--cmp cx,474--je t--cmp cx,32'

db '4--je t--cmp cx,174--je t--cmp cx,24--je t--jmp sts--t:mov byte ptr[edi],27h--mov byte ptr[edi+1],0Dh--mov byte ptr[edi+2],0Ah--mov byte ptr[edi+3],64'

db 'h--mov byte ptr[edi+4],62h--mov byte ptr[edi+5],20h--mov byte ptr[edi+6],27h--add edi,7--jmp sts--sts:cmp cx,0--jne sn--push offset n--push offset i--'

db 'call _printf--ll:mov al,0Dh--cmp bl,2Dh--xchg al,bl--je z--push offset x--push offset i--call _printf--leave--ret--.data--d db 27h,0Dh,0Ah,64h,62h,20h'

db ',27h,0--x db 2Ch,32h,37h,68h,2Ch,30h,0Dh,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,0--i db 25h,73h,0--n db 1380 DUP(0)--a db ',27h,0

end start
; ###########################

; Firebird

; by alCoPaUL[GIMO][As][aBrA][NPA][b8][BCVG][rRlf]

; 2/27/2023 NYC

; ml64.exe firebird.asm /link /subsystem:console /defaultlib:64mscrt.lib /entry:main

; ############

;

extrn printf:proc

.code

main proc

sub rsp,28h

mov al,13

mov bl,95

z:lea r9,a

mov dx,1329

r:cmp byte ptr[r9],bl

je s

jmp u

s:mov byte ptr[r9],al

cmp al,95

je kcl

mov byte ptr[r9+1],10

jmp u

kcl:mov byte ptr[r9+1],95

u:inc r9

dec dx

cmp dx,0

jnz r

cmp bl,0Dh

je otd

lea rdx,a

lea rcx,i

call printf

jmp ll

otd:

lea rdi,n

lea rsi,a

mov cx,1380

son:mov al,byte ptr[rsi]

mov byte ptr[rdi],al

inc rsi

inc rdi

dec cx

cmp cx,1224

je t

cmp cx,1074

je t

cmp cx,924

je t

cmp cx,774

je t

cmp cx,624

je t

cmp cx,474

je t

cmp cx,324

je t

cmp cx,174

je t

cmp cx,24

je t

jmp sts

t:mov byte ptr[rdi],27h

mov byte ptr[rdi+1],0Dh

mov byte ptr[rdi+2],0Ah

mov byte ptr[rdi+3],64h

mov byte ptr[rdi+4],62h

mov byte ptr[rdi+5],20h

mov byte ptr[rdi+6],27h

add rdi,7

jmp sts

sts:cmp cx,0

jne son

lea rdx,n

lea rcx,i

call printf

ll:mov al,13

cmp bl,95

xchg al,bl

je z

lea rdx,x

lea rcx,i

call printf

add rsp,28h

ret

main endp

.data

d db 27h,0Dh,0Ah,64h,62h,20h,27h,0

x db 2Ch,32h,37h,68h,2Ch,30h,0Dh,0Ah,65h,6eh,64h,0

i db 25h,73h,0

n db 1380 DUP(0)

a db '; ###########################__; Firebird__; by alCoPaUL[GIMO][As][aBrA][NPA][b8][BCVG][rRlf]__; 2/27/2023 NYC__; ml64.exe firebird.asm /link /subsystem:con'

db 'sole /defaultlib:64mscrt.lib /entry:main__; ############__;__extrn printf:proc__.code__main proc__sub rsp,28h__mov al,13__mov bl,95__z:lea r9,a__mov d'

db 'x,1329__r:cmp byte ptr[r9],bl__je s__jmp u__s:mov byte ptr[r9],al__cmp al,95__je kcl__mov byte ptr[r9+1],10__jmp u__kcl:mov byte ptr[r9+1],95__u:inc r'

db '9__dec dx__cmp dx,0__jnz r__cmp bl,0Dh__je otd__lea rdx,a__lea rcx,i__call printf__jmp ll__otd:__lea rdi,n__lea rsi,a__mov cx,1380__son:mov al,byte pt'

db 'r[rsi]__mov byte ptr[rdi],al__inc rsi__inc rdi__dec cx__cmp cx,1224__je t__cmp cx,1074__je t__cmp cx,924__je t__cmp cx,774__je t__cmp cx,624__je t__cm'

db 'p cx,474__je t__cmp cx,324__je t__cmp cx,174__je t__cmp cx,24__je t__jmp sts__t:mov byte ptr[rdi],27h__mov byte ptr[rdi+1],0Dh__mov byte ptr[rdi+2],0A'

db 'h__mov byte ptr[rdi+3],64h__mov byte ptr[rdi+4],62h__mov byte ptr[rdi+5],20h__mov byte ptr[rdi+6],27h__add rdi,7__jmp sts__sts:cmp cx,0__jne son__lea '

db 'rdx,n__lea rcx,i__call printf__ll:mov al,13__cmp bl,95__xchg al,bl__je z__lea rdx,x__lea rcx,i__call printf__add rsp,28h__ret__main endp__.data__d db '

db '27h,0Dh,0Ah,64h,62h,20h,27h,0__x db 2Ch,32h,37h,68h,2Ch,30h,0Dh,0Ah,65h,6eh,64h,0__i db 25h,73h,0__n db 1380 DUP(0)__a db ',27h,0

end

;FengHuang

;by alCoPaUL[GIMO][As][aBrA][NPA][b8]

;2/27/2023

;ml fh.asm /link /subsystem:console /defaultlib:32mscrt.lib /entry:main

.686

.model flat,stdcall

extern printf:proc

.code

start:

main proc

enter 0,0

mov al,0Dh

mov bl,2Dh

z:lea edx,a

mov cx,1329

r:cmp byte ptr[edx],bl

je s

jmp u

s:mov byte ptr[edx],al

cmp al,2Dh

je g

mov byte ptr[edx+1],0Ah

jmp u

g:mov byte ptr[edx+1],2Dh

u:inc edx

dec cx

cmp cx,0

jnz r

cmp bl,0Dh

je td

push offset a

push offset i

call printf

jmp ll

td:

lea edi,n

lea esi,a

mov cx,1374

sn:mov al,byte ptr[esi]

mov byte ptr[edi],al

inc esi

inc edi

dec cx

cmp cx,1224

je t

cmp cx,1074

je t

cmp cx,924

je t

cmp cx,774

je t

cmp cx,624

je t

cmp cx,474

je t

cmp cx,324

je t

cmp cx,174

je t

cmp cx,24

je t

jmp sts

t:mov byte ptr[edi],27h

mov byte ptr[edi+1],0Dh

mov byte ptr[edi+2],0Ah

mov byte ptr[edi+3],64h

mov byte ptr[edi+4],62h

mov byte ptr[edi+5],20h

mov byte ptr[edi+6],27h

add edi,7

jmp sts

sts:cmp cx,0

jne sn

push offset n

push offset i

call printf

ll:mov al,0Dh

cmp bl,2Dh

xchg al,bl

je z

push offset x

push offset i

call printf

leave

ret

main endp

.data

d db 27h,0Dh,0Ah,64h,62h,20h,27h,0

x db 2Ch,32h,37h,68h,2Ch,30h,0Dh,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,0

i db 25h,73h,0

n db 1380 DUP(0)

a db ';FengHuang--;by alCoPaUL[GIMO][As][aBrA][NPA][b8]--;2/27/2023--;ml fh.asm /link /subsystem:console /defaultlib:32mscrt.lib /entry:main--.686--.model f'

db 'lat,stdcall--extern printf:proc--.code--start:--main proc--enter 0,0--mov al,0Dh--mov bl,2Dh--z:lea edx,a--mov cx,1329--r:cmp byte ptr[edx],bl--je s--'

db 'jmp u--s:mov byte ptr[edx],al--cmp al,2Dh--je g--mov byte ptr[edx+1],0Ah--jmp u--g:mov byte ptr[edx+1],2Dh--u:inc edx--dec cx--cmp cx,0--jnz r--cmp bl'

db ',0Dh--je td--push offset a--push offset i--call printf--jmp ll--td:--lea edi,n--lea esi,a--mov cx,1374--sn:mov al,byte ptr[esi]--mov byte ptr[edi],al-'

db '-inc esi--inc edi--dec cx--cmp cx,1224--je t--cmp cx,1074--je t--cmp cx,924--je t--cmp cx,774--je t--cmp cx,624--je t--cmp cx,474--je t--cmp cx,324--j'

db 'e t--cmp cx,174--je t--cmp cx,24--je t--jmp sts--t:mov byte ptr[edi],27h--mov byte ptr[edi+1],0Dh--mov byte ptr[edi+2],0Ah--mov byte ptr[edi+3],64h--m'

db 'ov byte ptr[edi+4],62h--mov byte ptr[edi+5],20h--mov byte ptr[edi+6],27h--add edi,7--jmp sts--sts:cmp cx,0--jne sn--push offset n--push offset i--call'

db ' printf--ll:mov al,0Dh--cmp bl,2Dh--xchg al,bl--je z--push offset x--push offset i--call printf--leave--ret--main endp--.data--d db 27h,0Dh,0Ah,64h,62'

db 'h,20h,27h,0--x db 2Ch,32h,37h,68h,2Ch,30h,0Dh,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,0--i db 25h,73h,0--n db 1380 DUP(0)--a db ',27h,0

end start

Ready to assemble and link sources and respective Essential Libraries Attached..

~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 68
  • Country: ph
    • Webpage
Re: TASM32, MASM32, MASM64 Quines
« Reply #1 on: February 27, 2023, 08:27:17 PM »
Notes:

1.) Adjust your text viewer (e.g. Notepad) to open with Windows CRLF formatting.
2.) Adjust your console upto the 169th column for the artsy view of the quine..
3.) For the first quine, replace the tilde (~) with the minus (-) sign.
4.) To get the proper source code output, do the birdquine.exe > birdquine.txt and assemble/link birdquine.txt for the roundtrip, proving that it is indeed a quine.


Build Tools:
a.) Use Visual Studio 2010 x86/win64 build tools. The libs should be compatible but I included the exact libs as a separate download just in case.
b.) Obtain TASM 5 and update it with the necessary .exe patches coz assembling the TASM32 source code with the vanilla/rtm version leads to error. You can download the LATEST TASM32.EXE from Embarcadero's C++ Builder 10.4 Suite, which is free to try. I used TLINK32.EXE (updated/update file together with TASM32 update file) from TASM 5 suite+updates. You can use any of the 2 C Runtime libs (the one with "t" and the other one with "latest") that I provided with no error.

~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
« Last Edit: March 01, 2023, 09:40:21 PM by alCoPaUL »

Offline debs3759

  • Global Moderator
  • Full Member
  • *****
  • Posts: 221
  • Country: gb
    • GPUZoo
Re: TASM32, MASM32, MASM64 Quines
« Reply #2 on: February 27, 2023, 09:08:36 PM »
You do realise that this is a NASM forum? I imagine it assembles and executes fine, but just saying...
My graphics card database: www.gpuzoo.com

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 68
  • Country: ph
    • Webpage
Re: TASM32, MASM32, MASM64 Quines
« Reply #3 on: February 27, 2023, 10:02:49 PM »
that's why it's in the off-topic section.

but if you think of it, this is related to "Source Code Portability".

you can use this as an EXTERNAL reference as a comparison to the NASM quine i made for WINDOWS and MacOS.

if you insist that this belongs to its own appropriate forum, what they use there is old assembly syntax and also they are not using ML64.EXE there.

idk why people here are coming so hard everytime i post.

lelz.

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 68
  • Country: ph
    • Webpage
Re: TASM32, MASM32, MASM64 Quines
« Reply #4 on: March 02, 2023, 08:57:41 PM »
it is customary to include the link/lineage to the first ever assemblers in the biz.

POPULAR / Famous assemblers in the biz, i must say..

MASM was first released in 1981 and TASM was in 1989.

so far, I've seen 1 TASM quine floating along with some assembly code that is obviously derivative of the prominent assemblers and 1 MASM quine from a Japanese blogger.

but the way those were written are soo different with what about to show you.

since we got from 32-32-64, we'll go to 16-16

aries.asm

Code: [Select]
; ARIES
; by alCoPaUL[GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 3/2/2023 NYC
;
; ml /omf ARIES.asm
; m16link.exe ARIES.obj
;
.model tiny
.stack
.code
start:
main proc
push cs
pop ds
mov al,13
mov ah,45
z:lea bx,[k]
mov cx,1261
r:cmp byte ptr[bx],ah
je s
jmp u
s:mov byte ptr[bx],al
cmp al,45
je cu
mov byte ptr[bx+1],10
jmp u
cu:mov byte ptr[bx+1],45
u:inc bx
dec cx
cmp cx,0
jnz r
cmp al,45
je td
push ax
lea dx,[k]
mov ah,9h
int 21h
pop ax
jmp ll
td:
lea si,[k]
lea di,[n]
mov cx,1324
sn:mov al,byte ptr[si]
mov byte ptr[di],al
inc si
inc di
dec cx
cmp cx,1224
je t
cmp cx,1074
je t
cmp cx,924
je t
cmp cx,774
je t
cmp cx,624
je t
cmp cx,474
je t
cmp cx,324
je t
cmp cx,174
je t
cmp cx,24
je t
jmp sts
t:mov byte ptr[di],27h
mov byte ptr[di+1],0Dh
mov byte ptr[di+2],0Ah
mov byte ptr[di+3],64h
mov byte ptr[di+4],62h
mov byte ptr[di+5],20h
mov byte ptr[di+6],27h
add di,7
jmp sts
sts:cmp cx,0
jne sn
push ax
lea dx,[n]
mov ah,9h
int 21h
pop ax
ll:
cmp al,13
mov ah,45
xchg al,ah
je z
lea dx,[x]
mov ah,09h
int 21h
mov ax,4C00h
int 21h
main endp
.data
x db 2Ch,32h,37h,68h,2Ch,32h,34h,68h,0Dh,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,24h,0
n db 1261 DUP(0),24h
k db '; ARIES--; by alCoPaUL[GIMO][As][aBrA][NPA][b8][BCVG][rRlf]--; 3/2/2023 NYC--;--; ml /omf ARIES.asm-'
db '-; m16link.exe ARIES.obj--;--.model tiny--.stack--.code--start:--main proc--push cs--pop ds--mov al,13--mov ah,45--z:lea bx,[k]--mov cx,1261--r:cmp by'
db 'te ptr[bx],ah--je s--jmp u--s:mov byte ptr[bx],al--cmp al,45--je cu--mov byte ptr[bx+1],10--jmp u--cu:mov byte ptr[bx+1],45--u:inc bx--dec cx--cmp cx,'
db '0--jnz r--cmp al,45--je td--push ax--lea dx,[k]--mov ah,9h--int 21h--pop ax--jmp ll--td:--lea si,[k]--lea di,[n]--mov cx,1324--sn:mov al,byte ptr[si]-'
db '-mov byte ptr[di],al--inc si--inc di--dec cx--cmp cx,1224--je t--cmp cx,1074--je t--cmp cx,924--je t--cmp cx,774--je t--cmp cx,624--je t--cmp cx,474--'
db 'je t--cmp cx,324--je t--cmp cx,174--je t--cmp cx,24--je t--jmp sts--t:mov byte ptr[di],27h--mov byte ptr[di+1],0Dh--mov byte ptr[di+2],0Ah--mov byte p'
db 'tr[di+3],64h--mov byte ptr[di+4],62h--mov byte ptr[di+5],20h--mov byte ptr[di+6],27h--add di,7--jmp sts--sts:cmp cx,0--jne sn--push ax--lea dx,[n]--mo'
db 'v ah,9h--int 21h--pop ax--ll:--cmp al,13--mov ah,45--xchg al,ah--je z--lea dx,[x]--mov ah,09h--int 21h--mov ax,4C00h--int 21h--main endp--.data--x db '
db '2Ch,32h,37h,68h,2Ch,32h,34h,68h,0Dh,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,24h,0--n db 1261 DUP(0),24h--k db ',27h,24h
end start

GOAT.ASM

Code: [Select]
; GOAT
; by alCoPaUL[GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 3/2/2023 NYC
;
; tasm GOAT.asm
; tlink GOAT.obj
;
.model tiny
.stack
.code
start:
main proc
push cs
pop ds
mov al,13
mov ah,45
z:lea bx,[k]
mov cx,1265
r:cmp byte ptr[bx],ah
je s
jmp u
s:mov byte ptr[bx],al
cmp al,45
je cu
mov byte ptr[bx+1],10
jmp u
cu:mov byte ptr[bx+1],45
u:inc bx
dec cx
cmp cx,0
jnz r
cmp al,45
je td
push ax
lea dx,[k]
mov ah,9h
int 21h
pop ax
jmp ll
td:lea si,[k]
lea di,[n]
mov cx,1328
sn:mov al,byte ptr[si]
mov byte ptr[di],al
jmp q
zf:jmp z
q:inc si
inc di
dec cx
cmp cx,1224
je t
cmp cx,1074
je t
cmp cx,924
je t
cmp cx,774
je t
cmp cx,624
je t
cmp cx,474
je t
cmp cx,324
je t
cmp cx,174
je t
cmp cx,24
je t
jmp sts
t:mov byte ptr[di],27h
mov byte ptr[di+1],0Dh
mov byte ptr[di+2],0Ah
mov byte ptr[di+3],64h
mov byte ptr[di+4],62h
mov byte ptr[di+5],20h
mov byte ptr[di+6],27h
add di,7
jmp sts
sts:cmp cx,0
jne sn
push ax
lea dx,[n]
mov ah,9h
int 21h
pop ax
ll:cmp al,13
mov ah,45
xchg al,ah
je zf
lea dx,[x]
mov ah,09h
int 21h
mov ax,4C00h
int 21h
main endp
.data
x db 2Ch,32h,37h,68h,2Ch,32h,34h,68h,0Dh,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,24h,0
n db 1265 DUP(0),24h
k db '; GOAT--; by alCoPaUL[GIMO][As][aBrA][NPA][b8][BCVG][rRlf]--; 3/2/2023 NYC--;--; tasm GOAT.asm--; tlink '
db 'GOAT.obj--;--.model tiny--.stack--.code--start:--main proc--push cs--pop ds--mov al,13--mov ah,45--z:lea bx,[k]--mov cx,1265--r:cmp byte ptr[bx],ah--j'
db 'e s--jmp u--s:mov byte ptr[bx],al--cmp al,45--je cu--mov byte ptr[bx+1],10--jmp u--cu:mov byte ptr[bx+1],45--u:inc bx--dec cx--cmp cx,0--jnz r--cmp al'
db ',45--je td--push ax--lea dx,[k]--mov ah,9h--int 21h--pop ax--jmp ll--td:lea si,[k]--lea di,[n]--mov cx,1328--sn:mov al,byte ptr[si]--mov byte ptr[di],'
db 'al--jmp q--zf:jmp z--q:inc si--inc di--dec cx--cmp cx,1224--je t--cmp cx,1074--je t--cmp cx,924--je t--cmp cx,774--je t--cmp cx,624--je t--cmp cx,474-'
db '-je t--cmp cx,324--je t--cmp cx,174--je t--cmp cx,24--je t--jmp sts--t:mov byte ptr[di],27h--mov byte ptr[di+1],0Dh--mov byte ptr[di+2],0Ah--mov byte '
db 'ptr[di+3],64h--mov byte ptr[di+4],62h--mov byte ptr[di+5],20h--mov byte ptr[di+6],27h--add di,7--jmp sts--sts:cmp cx,0--jne sn--push ax--lea dx,[n]--m'
db 'ov ah,9h--int 21h--pop ax--ll:cmp al,13--mov ah,45--xchg al,ah--je zf--lea dx,[x]--mov ah,09h--int 21h--mov ax,4C00h--int 21h--main endp--.data--x db '
db '2Ch,32h,37h,68h,2Ch,32h,34h,68h,0Dh,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,24h,0--n db 1265 DUP(0),24h--k db ',27h,24h
end start

again, these codes are still thematic and relate to source code portability...

and yes, NASM still produces DOS codes/executables, right?

same drill and test roundtripping to prove that they're legit quines.

regards,

alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
3/2/2023 New York, Cubao

note:
attached is the DOS Linker for the Microsoft OMF object file. You can assemble the MS-DOS source code using Visual Studio 2010++ build tool ML.EXE AND use the Attached file.

How to Use the Linker:
* Execute with the source code and press 5 enters (you don't have to fill the blanks with any data)
« Last Edit: March 02, 2023, 09:07:06 PM by alCoPaUL »

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 68
  • Country: ph
    • Webpage
Re: TASM32, MASM32, MASM64 Quines
« Reply #5 on: March 03, 2023, 06:12:35 PM »
I noticed that Windows moved away from hardcoded CrLf, which is still the defacto [Enter] in DOS/DOSBox/DOSBox-X, and just went to the MacOS UNIX standard of Lf only.

And this is why the first post had spaces (which is still valid in the context of being quine since it is defined as "a program that displays its own source code" and the sources display themselves without spaces) because when you use file1.exe > file1.txt, it will add an extra 0Dh to 0Dh0Ah, making the linebreak 0Dh0DhAh when you redirect the console output to save to file.

and with this post, i modded the sources from the original post to display themselves properly - whether seeing output from the console or redirected text output to file

Code: [Select]
; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; Benu
; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 2/27/2023 NYC
; tasm32 benu.asm
; tlink32 ~Tpe ~ap benu.obj,benu.exe,,tmsvcrt.lib,,
; /////////////////////////////////////////////////////////////////////////////////////////////
.686
.model flat,stdcall
extrn _printf:proc
.code
start:
enter 0,0
mov al,0Ah
mov bl,2Dh
z:lea edx,[a]
mov cx,1318
r:cmp byte ptr[edx],bl
je s
jmp u
s:mov byte ptr[edx],al
u:inc edx
dec cx
cmp cx,0
jnz r
cmp bl,0Ah
je td
push offset a
push offset i
call _printf
jmp ll
td:
lea edi,[n]
lea esi,[a]
mov cx,1372
sn:mov al,byte ptr[esi]
mov byte ptr[edi],al
inc esi
inc edi
dec cx
cmp cx,1224
je t
cmp cx,1074
je t
cmp cx,924
je t
cmp cx,774
je t
cmp cx,624
je t
cmp cx,474
je t
cmp cx,324
je t
cmp cx,174
je t
cmp cx,24
je t
jmp sts
t:mov byte ptr[edi],27h
mov byte ptr[edi+1],0Ah
mov byte ptr[edi+2],64h
mov byte ptr[edi+3],62h
mov byte ptr[edi+4],20h
mov byte ptr[edi+5],27h
add edi,6
jmp sts
sts:cmp cx,0
jne sn
push offset n
push offset i
call _printf
ll:mov al,0Ah
cmp bl,2Dh
xchg al,bl
je z
push offset x
push offset i
call _printf
leave
ret
.data
x db 2Ch,32h,37h,68h,2Ch,30h,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,0
i db 25h,73h,0
n db 1319 DUP(0)
a db '; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////-; Benu-; by alCoPaUL [GIMO][As]'
db '[aBrA][NPA][b8][BCVG][rRlf]-; 2/27/2023 NYC-; tasm32 benu.asm-; tlink32 ~Tpe ~ap benu.obj,benu.exe,,tmsvcrt.lib,,-; //////////////////////////////////'
db '///////////////////////////////////////////////////////////-.686-.model flat,stdcall-extrn _printf:proc-.code-start:-enter 0,0-mov al,0Ah-mov bl,2Dh-z'
db ':lea edx,[a]-mov cx,1318-r:cmp byte ptr[edx],bl-je s-jmp u-s:mov byte ptr[edx],al-u:inc edx-dec cx-cmp cx,0-jnz r-cmp bl,0Ah-je td-push offset a-push '
db 'offset i-call _printf-jmp ll-td:-lea edi,[n]-lea esi,[a]-mov cx,1372-sn:mov al,byte ptr[esi]-mov byte ptr[edi],al-inc esi-inc edi-dec cx-cmp cx,1224-j'
db 'e t-cmp cx,1074-je t-cmp cx,924-je t-cmp cx,774-je t-cmp cx,624-je t-cmp cx,474-je t-cmp cx,324-je t-cmp cx,174-je t-cmp cx,24-je t-jmp sts-t:mov byte'
db ' ptr[edi],27h-mov byte ptr[edi+1],0Ah-mov byte ptr[edi+2],64h-mov byte ptr[edi+3],62h-mov byte ptr[edi+4],20h-mov byte ptr[edi+5],27h-add edi,6-jmp st'
db 's-sts:cmp cx,0-jne sn-push offset n-push offset i-call _printf-ll:mov al,0Ah-cmp bl,2Dh-xchg al,bl-je z-push offset x-push offset i-call _printf-leave'
db '-ret-.data-x db 2Ch,32h,37h,68h,2Ch,30h,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,0-i db 25h,73h,0-n db 1319 DUP(0)-a db ',27h,0
end start

; ///////////////////////////////////////////////////////////////////////////////////////////
;
; Firebird
; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 2/27/2023 Revised: 3/03/2023 @ NYC
; ml64.exe firebird.asm /link /subsystem:console /defaultlib:64mscrt.lib /entry:main
;
; /////////////////////////////////////////////////////////////////////////////////////
extrn printf:proc
.code
main proc
sub rsp,28h
mov al,0Ah
mov bl,2Dh
z:lea r9,[a]
mov dx,1318
r:cmp byte ptr[r9],bl
je s
jmp u
s:mov byte ptr[r9],al
u:inc r9
dec dx
cmp dx,0
jnz r
cmp bl,0Ah
je td
lea rdx,[a]
lea rcx,[i]
call printf
jmp ll
td:
lea rdi,[n]
lea rsi,[a]
mov cx,1372
sn:mov al,byte ptr[rsi]
mov byte ptr[rdi],al
inc rsi
inc rdi
dec cx
cmp cx,1224
je t
cmp cx,1074
je t
cmp cx,924
je t
cmp cx,774
je t
cmp cx,624
je t
cmp cx,474
je t
cmp cx,324
je t
cmp cx,174
je t
cmp cx,24
je t
jmp sts
t:mov byte ptr[rdi],27h
mov byte ptr[rdi+1],0Ah
mov byte ptr[rdi+2],64h
mov byte ptr[rdi+3],62h
mov byte ptr[rdi+4],20h
mov byte ptr[rdi+5],27h
add rdi,6
jmp sts
sts:cmp cx,0
jne sn
lea rdx,[n]
lea rcx,[i]
call printf
ll:mov al,0Ah
cmp bl,2Dh
xchg al,bl
je z
lea rdx,[x]
lea rcx,[i]
call printf
add rsp,28h
ret
main endp
.data
b db 27h,0Dh,0Ah,64h,62h,20h,27h,0
x db 2Ch,32h,37h,68h,2Ch,30h,0Ah,65h,6eh,64h,0
i db 25h,73h,0
n db 1319 DUP(0)
a db '; ///////////////////////////////////////////////////////////////////////////////////////////-;-; Firebird-; by alCoPaUL [GIMO][As][aBrA][NPA][b8][B'
db 'CVG][rRlf]-; 2/27/2023 Revised: 3/03/2023 @ NYC-; ml64.exe firebird.asm /link /subsystem:console /defaultlib:64mscrt.lib /entry:main-;-; /////////////'
db '////////////////////////////////////////////////////////////////////////-extrn printf:proc-.code-main proc-sub rsp,28h-mov al,0Ah-mov bl,2Dh-z:lea r9,'
db '[a]-mov dx,1318-r:cmp byte ptr[r9],bl-je s-jmp u-s:mov byte ptr[r9],al-u:inc r9-dec dx-cmp dx,0-jnz r-cmp bl,0Ah-je td-lea rdx,[a]-lea rcx,[i]-call pr'
db 'intf-jmp ll-td:-lea rdi,[n]-lea rsi,[a]-mov cx,1372-sn:mov al,byte ptr[rsi]-mov byte ptr[rdi],al-inc rsi-inc rdi-dec cx-cmp cx,1224-je t-cmp cx,1074-j'
db 'e t-cmp cx,924-je t-cmp cx,774-je t-cmp cx,624-je t-cmp cx,474-je t-cmp cx,324-je t-cmp cx,174-je t-cmp cx,24-je t-jmp sts-t:mov byte ptr[rdi],27h-mov'
db ' byte ptr[rdi+1],0Ah-mov byte ptr[rdi+2],64h-mov byte ptr[rdi+3],62h-mov byte ptr[rdi+4],20h-mov byte ptr[rdi+5],27h-add rdi,6-jmp sts-sts:cmp cx,0-jn'
db 'e sn-lea rdx,[n]-lea rcx,[i]-call printf-ll:mov al,0Ah-cmp bl,2Dh-xchg al,bl-je z-lea rdx,[x]-lea rcx,[i]-call printf-add rsp,28h-ret-main endp-.data-'
db 'b db 27h,0Dh,0Ah,64h,62h,20h,27h,0-x db 2Ch,32h,37h,68h,2Ch,30h,0Ah,65h,6eh,64h,0-i db 25h,73h,0-n db 1319 DUP(0)-a db ',27h,0
end

; //////////////////////////////////////////////
;
; Feng Huang
; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 2/27/2023 Revised: 3/03/2023 @ NYC
; ml.exe fenghuang.asm /link /subsystem:console /defaultlib:32mscrt.lib /entry:main
;
; ////////////////////////////////////////////////////////////////
.686
.model flat,stdcall
extern printf:proc
.code
start:
main proc
enter 0,0
mov al,0Ah
mov bl,2Dh
z:lea edx,[a]
mov cx,1318
r:cmp byte ptr[edx],bl
je s
jmp u
s:mov byte ptr[edx],al
u:inc edx
dec cx
cmp cx,0
jnz r
cmp bl,0Ah
je td
push offset a
push offset i
call printf
jmp ll
td:
lea edi,[n]
lea esi,[a]
mov cx,1372
sn:mov al,byte ptr[esi]
mov byte ptr[edi],al
inc esi
inc edi
dec cx
cmp cx,1224
je t
cmp cx,1074
je t
cmp cx,924
je t
cmp cx,774
je t
cmp cx,624
je t
cmp cx,474
je t
cmp cx,324
je t
cmp cx,174
je t
cmp cx,24
je t
jmp sts
t:mov byte ptr[edi],27h
mov byte ptr[edi+1],0Ah
mov byte ptr[edi+2],64h
mov byte ptr[edi+3],62h
mov byte ptr[edi+4],20h
mov byte ptr[edi+5],27h
add edi,6
jmp sts
sts:cmp cx,0
jne sn
push offset n
push offset i
call printf
ll:mov al,0Ah
cmp bl,2Dh
xchg al,bl
je z
push offset x
push offset i
call printf
leave
ret
main endp
.data
b db 27h,0Dh,0Ah,64h,62h,20h,27h,0
x db 2Ch,32h,37h,68h,2Ch,30h,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,0
i db 25h,73h,0
n db 1319 DUP(0)
a db '; //////////////////////////////////////////////-;-; Feng Huang-; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]-; 2/27/2023 Revised: 3/03/2023 @'
db ' NYC-; ml.exe fenghuang.asm /link /subsystem:console /defaultlib:32mscrt.lib /entry:main-;-; /////////////////////////////////////////////////////////'
db '///////-.686-.model flat,stdcall-extern printf:proc-.code-start:-main proc-enter 0,0-mov al,0Ah-mov bl,2Dh-z:lea edx,[a]-mov cx,1318-r:cmp byte ptr[ed'
db 'x],bl-je s-jmp u-s:mov byte ptr[edx],al-u:inc edx-dec cx-cmp cx,0-jnz r-cmp bl,0Ah-je td-push offset a-push offset i-call printf-jmp ll-td:-lea edi,[n'
db ']-lea esi,[a]-mov cx,1372-sn:mov al,byte ptr[esi]-mov byte ptr[edi],al-inc esi-inc edi-dec cx-cmp cx,1224-je t-cmp cx,1074-je t-cmp cx,924-je t-cmp cx'
db ',774-je t-cmp cx,624-je t-cmp cx,474-je t-cmp cx,324-je t-cmp cx,174-je t-cmp cx,24-je t-jmp sts-t:mov byte ptr[edi],27h-mov byte ptr[edi+1],0Ah-mov b'
db 'yte ptr[edi+2],64h-mov byte ptr[edi+3],62h-mov byte ptr[edi+4],20h-mov byte ptr[edi+5],27h-add edi,6-jmp sts-sts:cmp cx,0-jne sn-push offset n-push of'
db 'fset i-call printf-ll:mov al,0Ah-cmp bl,2Dh-xchg al,bl-je z-push offset x-push offset i-call printf-leave-ret-main endp-.data-b db 27h,0Dh,0Ah,64h,62h'
db ',20h,27h,0-x db 2Ch,32h,37h,68h,2Ch,30h,0Ah,65h,6eh,64h,20h,73h,74h,61h,72h,74h,0-i db 25h,73h,0-n db 1319 DUP(0)-a db ',27h,0
end start
regards,

alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]