NASM Forum > Example Code

MacOS Quine (And Many More)

<< < (2/2)

alCoPaUL:
;
; sulfur16.asm
;
; alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 10/7/2021 .revision 2 = 2/1/2023
;
; nasm <dash>f bin <dash>o sulfur16.com sulfur16.asm
;
org 100h
mov al,13
mov ah,45
z:lea bx,[k]
mov cx,551
r:cmp byte[bx],ah
je s
jmp u
s:mov byte[bx],al
cmp al,45
je c
mov byte[bx+1],10
jmp u
c:mov byte[bx+1],45
u:inc bx
dec cx
cmp cx,0
jnz r
push ax
lea dx,(k)
mov ah,9
int 21h
pop ax
cmp al,13
mov ah,45
xchg al,ah
je z
lea dx,(x)
mov ah,9
int 21h
int 20h
x:db 2Ch,32h,37h,68h,2Ch,32h,34h,68h,24h
k:db ';--; sulfur16.asm--;--; alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]--; 10/7/2021 .revision 2 = 2/1/2023--;--; nasm <dash>f bin <dash>o sulfur16.com sulfur16.asm--;--org 100h--mov al,13--mov ah,45--z:lea bx,[k]--mov cx,551--r:cmp byte[bx],ah--je s--jmp u--s:mov byte[bx],al--cmp al,45--je c--mov byte[bx+1],10--jmp u--c:mov byte[bx+1],45--u:inc bx--dec cx--cmp cx,0--jnz r--push ax--lea dx,(k)--mov ah,9--int 21h--pop ax--cmp al,13--mov ah,45--xchg al,ah--je z--lea dx,(x)--mov ah,9--int 21h--int 20h--x:db 2Ch,32h,37h,68h,2Ch,32h,34h,68h,24h--k:db ',27h,24h


; NOTE: replace the parentheses used in x and k in the code and data section with square brackets.
; Should run with no error in Classic MS-DOS, DOSBox 0.74.3 and DOSBox-X.
;
;
;
; And that being the culmination of the accomplished NASM project, here's the full project link.
;
; Win64, Win32, DOS16, MacOS 64-bit and 32-bit Quines ~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf] 2/1/2023, NYC
;
; https://github.com/alcopaul/W32.Perrun/blob/master/Project159_alCoPaULGIMOGdGeS.zip
; https://github.com/alcopaul/W32.Perrun/blob/master/Project159_alCoPaULGIMOGdGeS.z01
;
; and this is related to the "Source and Compiled Level Portability" thread.
;
; all made using NASM. Epic assembler.
;
;

EDIT: Or if you just want the source codes (coz the 2 links above contain the build tools (except for the MacOS, which is NASM 2.08(RCs))), i attached them on this post..

EDIT1: One Stop Shop : https://github.com/alcopaul/assemblylanguagequines

alCoPaUL:
Bumping the Example Quines From The Off-Topic Section

TASM32, MASM32, MASM64 Quines
https://forum.nasm.us/index.php?topic=3686.0

alCoPaUL:
just like from the off-topic forum quines that had issues on proper string formatting, i am addressing those issues because it affected 2 of the NASM quines and it is proper that I fix it..

and now, i am posting again the summary NASM quine codes here in this post.

The Win32 and Win64 quines were modded (by substitution highlighting) and should be fixed by now. The DOS16, 32-bit and 64-bit MacOS quines are still the same.

You can find the fixed quines (Win32 and Win64) inside the zip file from my github coz i've included both 32-bit and 64-bit \n and \r\n quines inside it before.

and they're still there..

it looks to me that the hard coded CrLf ended string lines are necessary only for the DOS16 quine so it will display and write to file properly, under the DOS native environment, DOSBox and DOSBox-X.

so without much ado, here are the 5 NASM Quines.


--- Code: ---;
; spc.asm
;
; alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 10/5/2021 .revision = 1/27/2023
;
; nasm -f win64 spc.asm
; link spc.obj /subsystem:console /defaultlib:msvcrt64.lib /entry:m /largeaddressaware:no
;
global m
extern printf
section .text
m:sub rsp,28h
mov al,10
mov bl,95
z:lea r9,a
mov dx,567
r:cmp byte[r9],bl
je s
jmp u
s:mov byte[r9],al
u:inc r9
dec dx
cmp dx,0
jnz r
lea rdx,a
lea rcx,i
call printf
mov al,10
cmp bl,95
xchg al,bl
je z
lea rdx,x
lea rcx,i
call printf
add rsp,28h
ret
section .data
x:db 2Ch,32h,37h,68h,2Ch,30h,0
i:db 25h,73h,0
a:db ';_; spc.asm_;_; alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]_; 10/5/2021 .revision = 1/27/2023_;_; nasm -f win64 spc.asm_; link spc.obj /subsystem:console /defaultlib:msvcrt64.lib /entry:m /largeaddressaware:no_;_global m_extern printf_section .text_m:sub rsp,28h_mov al,10_mov bl,95_z:lea r9,a_mov dx,567_r:cmp byte[r9],bl_je s_jmp u_s:mov byte[r9],al_u:inc r9_dec dx_cmp dx,0_jnz r_lea rdx,a_lea rcx,i_call printf_mov al,10_cmp bl,95_xchg al,bl_je z_lea rdx,x_lea rcx,i_call printf_add rsp,28h_ret_section .data_x:db 2Ch,32h,37h,68h,2Ch,30h,0_i:db 25h,73h,0_a:db ',27h,0

;
; sp4ce.asm
;
; alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 10/6/2021 .revision = 1/27/2023
;
; nasm <dash>f win32 sp4ce.asm
; link sp4ce.obj /subsystem:console /defaultlib:32msvcrt.lib /entry:m
;
global m
extern _printf
section .text
m:enter 0,0
mov al,10
mov bl,45
z:lea edx,a
mov cx,543
r:cmp byte[edx],bl
je s
jmp u
s:mov byte[edx],al
u:inc edx
dec cx
cmp cx,0
jnz r
push a
push i
call _printf
mov al,10
cmp bl,45
xchg al,bl
je z
push x
push i
call _printf
leave
ret
section .data
x:db 2Ch,32h,37h,68h,2Ch,30h,0
i:db 25h,73h,0
a:db ';-; sp4ce.asm-;-; alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]-; 10/6/2021 .revision = 1/27/2023-;-; nasm <dash>f win32 sp4ce.asm-; link sp4ce.obj /subsystem:console /defaultlib:32msvcrt.lib /entry:m-;-global m-extern _printf-section .text-m:enter 0,0-mov al,10-mov bl,45-z:lea edx,a-mov cx,543-r:cmp byte[edx],bl-je s-jmp u-s:mov byte[edx],al-u:inc edx-dec cx-cmp cx,0-jnz r-push a-push i-call _printf-mov al,10-cmp bl,45-xchg al,bl-je z-push x-push i-call _printf-leave-ret-section .data-x:db 2Ch,32h,37h,68h,2Ch,30h,0-i:db 25h,73h,0-a:db ',27h,0

;
; sulfur16.asm
;
; alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; 10/7/2021 .revision 2 = 2/1/2023
;
; nasm <dash>f bin <dash>o sulfur16.com sulfur16.asm
;
org 100h
mov al,13
mov ah,45
z:lea bx,[k]
mov cx,551
r:cmp byte[bx],ah
je s
jmp u
s:mov byte[bx],al
cmp al,45
je c
mov byte[bx+1],10
jmp u
c:mov byte[bx+1],45
u:inc bx
dec cx
cmp cx,0
jnz r
push ax
lea dx,[k]
mov ah,9
int 21h
pop ax
cmp al,13
mov ah,45
xchg al,ah
je z
lea dx,[x]
mov ah,9
int 21h
int 20h
x:db 2Ch,32h,37h,68h,2Ch,32h,34h,68h,24h
k:db ';--; sulfur16.asm--;--; alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]--; 10/7/2021 .revision 2 = 2/1/2023--;--; nasm <dash>f bin <dash>o sulfur16.com sulfur16.asm--;--org 100h--mov al,13--mov ah,45--z:lea bx,[k]--mov cx,551--r:cmp byte[bx],ah--je s--jmp u--s:mov byte[bx],al--cmp al,45--je c--mov byte[bx+1],10--jmp u--c:mov byte[bx+1],45--u:inc bx--dec cx--cmp cx,0--jnz r--push ax--lea dx,[k]--mov ah,9--int 21h--pop ax--cmp al,13--mov ah,45--xchg al,ah--je z--lea dx,[x]--mov ah,9--int 21h--int 20h--x:db 2Ch,32h,37h,68h,2Ch,32h,34h,68h,24h--k:db ',27h,24h

; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; January 25, 2023 NYC
; nasm <dash>f macho <dash>o GosuIchiban.o SnowLeopard.asm
; ld <dash>arch i386 <dash>macosx_version_min 10.4 <dash>lc /usr/lib/crt1.o <dash>o GesuIchIvan GosuIchiban.o
global _main
extern _printf
section .text
_main:
enter 0,0
mov al,10
mov bl,45
z:lea edx,[a]
mov cx,596
r:cmp byte [edx],bl
je s
jmp u
s:mov byte [edx],al
u:inc edx
dec cx
cmp cx,0
jnz r
push a
push i
call _printf
mov al,10
cmp bl,45
xchg al,bl
je z
push x
push i
call _printf
leave
ret
section .data
x:db 2Ch,32h,37h,68h,2Ch,30h,0
i:db 25h,73h,0
a:db '; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]-; January 25, 2023 NYC-; nasm <dash>f macho <dash>o GosuIchiban.o SnowLeopard.asm-; ld <dash>arch i386 <dash>macosx_version_min 10.4 <dash>lc /usr/lib/crt1.o <dash>o GesuIchIvan GosuIchiban.o-global _main-extern _printf-section .text-_main:-enter 0,0-mov al,10-mov bl,45-z:lea edx,[a]-mov cx,596-r:cmp byte [edx],bl-je s-jmp u-s:mov byte [edx],al-u:inc edx-dec cx-cmp cx,0-jnz r-push a-push i-call _printf-mov al,10-cmp bl,45-xchg al,bl-je z-push x-push i-call _printf-leave-ret-section .data-x:db 2Ch,32h,37h,68h,2Ch,30h,0-i:db 25h,73h,0-a:db ',27h,0


; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
; January 26, 2023 NYC
; ./nasm <dash>f macho64 <dash>o 6GosuIchiban4.o SnowLeopard64.asm
; ld <dash>arch x86_64  <dash>macosx_version_min 10.4 <dash>lc /usr/lib/crt1.o <dash>o 6GesuIchIvan4 6GosuIchiban4.o
global _main
extern _printf
section .text
_main:push rbx
mov cl,10
mov bl,45
z:lea r9,[a]
mov dx,685
r:cmp byte[r9],bl
je s
jmp u
s:mov byte[r9],cl
u:inc r9
dec dx
cmp dx,0
jnz r
lea rdi,[i]
lea rax,[a]
mov rsi,rax
xor rax,rax
call _printf
mov cl,10
cmp bl,45
xchg cl,bl
je z
lea rdi,[i]
lea rax,[x]
mov rsi,rax
xor rax,rax
call _printf
pop rbx
ret
section .data
default rel
x:db 2Ch,32h,37h,68h,2Ch,30h,0
i:db 25h,73h,0
a:db '; by alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]-; January 26, 2023 NYC-; ./nasm <dash>f macho64 <dash>o 6GosuIchiban4.o SnowLeopard64.asm-; ld <dash>arch x86_64  <dash>macosx_version_min 10.4 <dash>lc /usr/lib/crt1.o <dash>o 6GesuIchIvan4 6GosuIchiban4.o-global _main-extern _printf-section .text-_main:push rbx-mov cl,10-mov bl,45-z:lea r9,[a]-mov dx,685-r:cmp byte[r9],bl-je s-jmp u-s:mov byte[r9],cl-u:inc r9-dec dx-cmp dx,0-jnz r-lea rdi,[i]-lea rax,[a]-mov rsi,rax-xor rax,rax-call _printf-mov cl,10-cmp bl,45-xchg cl,bl-je z-lea rdi,[i]-lea rax,[x]-mov rsi,rax-xor rax,rax-call _printf-pop rbx-ret-section .data-default rel-x:db 2Ch,32h,37h,68h,2Ch,30h,0-i:db 25h,73h,0-a:db ',27h,0

--- End code ---

i could format the 1 line db but it's a built-in feature in NASM so why shall i gimp the assembler just to conform with the oldschool assemblers (MASM and TASM)?

anyway, everything here..
https://github.com/alcopaul/AssemblyLanguageQuines

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

alCoPaUL:
For The NASM and other non-16bit Quines Running On Windows ..

You can adjust the Window Size Width to perfectly view the text formatting and the layout of the Quines via clicking the top left black icon of the CMD Console window -> Click "Properties", Choose "Layout" and adjust the Window Size.

recommended Height x Width is 39 x 159

also, everything here..

https://bitbucket.org/alcopaul/datassemblylanguagequines/src/ThunderRT6Main

Essential Files and the Actual Workspace Are Also There As Downloads

regards,

Navigation

[0] Message Index

[*] Previous page

Go to full version