Author Topic: MacOS Quine (And Many More)  (Read 15552 times)

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 74
  • Country: ph
    • Webpage
MacOS Quine (And Many More)
« on: January 26, 2023, 12:44:42 AM »
; 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
« Last Edit: January 28, 2023, 12:00:02 AM by alCoPaUL »

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 74
  • Country: ph
    • Webpage
Re: MacOS Quine (And Many More)
« Reply #1 on: January 26, 2023, 07:15:42 PM »
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.')
« Last Edit: January 26, 2023, 07:33:45 PM by alCoPaUL »

Offline Winifred58

  • Jr. Member
  • *
  • Posts: 10
Re: MacOS Quine (And Many More)
« Reply #2 on: January 27, 2023, 08:51:14 AM »
A commitment of appreciation is all together for the data. I will endeavor to figure it out for extra. Mysainsburys Login
« Last Edit: January 28, 2023, 04:15:20 AM by Winifred58 »

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 74
  • Country: ph
    • Webpage
Re: MacOS Quine (And Many More)
« Reply #3 on: January 27, 2023, 03:30:02 PM »
 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)
« Last Edit: January 27, 2023, 03:48:33 PM by alCoPaUL »

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 74
  • Country: ph
    • Webpage
Re: MacOS Quine (And Many More)
« Reply #4 on: January 27, 2023, 04:43:56 PM »
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

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 74
  • Country: ph
    • Webpage
Re: MacOS Quine (And Many More)
« Reply #5 on: February 02, 2023, 05:08:58 AM »
;
; 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

« Last Edit: February 07, 2023, 06:21:49 PM by alCoPaUL »

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 74
  • Country: ph
    • Webpage
Re: MacOS Quine (And Many More)
« Reply #6 on: February 27, 2023, 07:03:55 PM »
Bumping the Example Quines From The Off-Topic Section

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

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 74
  • Country: ph
    • Webpage
Re: MacOS Quine (And Many More)
« Reply #7 on: March 05, 2023, 05:57:01 PM »
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: [Select]
;
; 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

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]
« Last Edit: March 05, 2023, 07:32:28 PM by alCoPaUL »

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 74
  • Country: ph
    • Webpage
Re: MacOS Quine (And Many More)
« Reply #8 on: June 17, 2023, 09:59:58 PM »
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,
« Last Edit: June 17, 2023, 10:01:30 PM by alCoPaUL »