NASM Forum > Example Code

MacOS Quine (And Many More)

(1/2) > >>

alCoPaUL:
; 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

And The Many More Section

Win64, Win32, MacOS 64-bit and 32-bit Assembly Language Quines
https://github.com/alcopaul/HeXtASY/blob/master/Project159alCoPaULGIMOGdGe.zip
 
Windows x64 and Win32 Quines
https://github.com/alcopaul/W32.Perrun/blob/master/Project159_Windows11_NASM_VS2029.zip

DOS16 Quine (For DOSBox 74-3)
https://github.com/alcopaul/W32.Perrun/blob/master/Project159_sulfur712_dosbox.zip

Update: 64-bit version for MacOS Attached

alCoPaUL:
Formatting Fix (From MacOS to Notepad 'That is if you just want to assemble and link it on the fly coz the previous attachment has funky text formatting.')

Winifred58:
A commitment of appreciation is all together for the data. I will endeavor to figure it out for extra. Mysainsburys Login

alCoPaUL:
 8)

for the 64 bit MacOS quine, i have to thank Samuel Evans-Powell for the "default rel" needed in the .data section coz the source code would be longer without it.
and how to pass a data address to a formatting and locking it at the required parameter for printf()

note:
replace the parentheses with square brackets coz the forum does weird formatting with square brackets with i & x inside.
....
lea rdi,(i) ; pass "%s" as the destination
lea rax,(x) ; prep data by getting its address
mov rsi,rax ; set the data as the source | printf("%s", data);
xor rax,rax ; lock the parameters @ 2 items
call _printf ; do magic
....
section .data
default rel ; no need to use [rel i], [rel x]
x:db 2Ch,32h,37h,68h,2Ch,30h,0
i:db 25h,73h,0

his website : http://sevanspowell.net/posts/learning-nasm-on-macos.html

and to assemble the 32 and 64 bit MacOS quines, use this nasm version

https://www.nasm.us/pub/nasm/releasebuilds/2.08rc1/

which is alright and proper since MacOS Snow Leopard's built in NASM version is 0.98 (no MACHO64 directive)

NASM 2.08 already has directive for MACHO64 and the assembler can natively run on MacOS.

so to replicate my results, you should do everything in MacOS Snow Leopard WITH NASM 2.08(RCs)

alCoPaUL:
MacOS is the only computer operating system which is sold to the mass regular consumers that is certified UNIX and/or a legit UNIX OS via the Single Unix Specification..

https://en.wikipedia.org/wiki/Single_UNIX_Specification

currently, only 6 OS'es are certified as UNIX.

and they are AIX, HP-UX, MacOS, OpenServer, UnixWare, z/OS

(like who're using AIX or z/OS in their houses to check instagram?)

and for MacOS...

MacOS (previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers

The first desktop version, Mac OS X 10.0, was released in March 2001, with its first update, 10.1, arriving later that year. All releases from Mac OS X 10.5 Leopard and after are UNIX 03 certified, with an exception for OS X 10.7 Lion. ** (OS X 10.4 is named Tiger)

https://en.wikipedia.org/wiki/MacOS

Navigation

[0] Message Index

[#] Next page

Go to full version