Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Programming with NASM / Re: I need help
« Last post by Frank Kotler on January 28, 2023, 03:01:54 AM »
What OS?

Too tough a question?

One thing I will caution you on. There is a "pause" instruction. It does not do what you want.

Best,
Frank

22
Example Code / Re: Source and Compiled Level Portability
« Last post by alCoPaUL on January 27, 2023, 11:53:02 PM »
hi.

assembly language is not portable for say an x86 code to be ported to arm or powerpc or etc in terms of reusing most of the code. source level portability is doable coz windows, mac, unix, linux mostly run on x86 architecture and a single code base is not totally rewritten and compiled for each OS's is possible.

and add to that the C/C++ libraries that are installed in almost all OS coz everyone writes in C/C++. good thing that routines from these libraries are exposed to be used in the low level.

these omnipresent libraries are like the proto-virtual machines/frameworks that we all see now..

i hope i got my point across..
23
Example Code / Re: Source and Compiled Level Portability
« Last post by debs3759 on January 27, 2023, 05:15:23 PM »
I don't understand your point? Nobody expects assembly code to be easily ported between different platforms (OS or hardware).
24
Example Code / Source and Compiled Level Portability
« Last post by alCoPaUL on January 27, 2023, 05:06:09 PM »
pretty sure you already have your concrete concepts about the title already. but i just wanna impart my opinion about those coz there are notion and stereotypes about assembly language being not portable.

and the definition of that was true when the nascent computer hobbyist scene are bombarded with different chips. and with that, programmers had to write assembly language FOR each chip that are remotely similar to each other.

and then the sorcery of high level languages appeared (but that's for another thread).

so source level portability in assembly language.

pretty much the chips are collated now into a similarity and commonality. assembly instruction are still the same (unless it's arm & arm64). and this is even facilitated by the existence of old libraries that existed since brian kernighan wrote the hello world c program.

so in my opinion, source code portabilty is when you get a source, assemble it successfully in an operating system, mod the source by 1% or even .5% and then assemble it successfully in another operating system.

the same codebase being assembled in operating systems running under a similar or compatible hardware/chip.

this, again, is possible if you use libraries, not for the whole functionality of your code, but for certain functions (which were interrupts in DOS) that is present in the operating systems that you're building on.

coz int 0x80 or something like that is not ExitProcess() @ source level, right? (you get the point).

And compiled level portability??

you get a virtual machine/framework, write programs to run solely under the virtual machine's or framework constraints, develop ports of that virtual machine/framework to all of the available OS's and install those ports and the programs written for the virtual machine/framework will run in all architectures. and by all architectures i mean the different hardware on the bottom of the OS's that you want your virtual machine/framework to be installed in.

i think that the original .NET Framework's vision was to use old computers and mainframes coz they'll just make a .NET framework for 16 bit Computers or Mainframes and run C# or Visual Basic.NET programs in 16-bit Computers or Mainframes right?

~~ alCoPaUL [GIMO][As][aBrA][NPA][b8][BCVG][rRlf]
25
Example Code / Re: MacOS Quine (And Many More)
« Last post by alCoPaUL 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
26
Programming with NASM / Re: How C compilers do their magic?
« Last post by alCoPaUL on January 27, 2023, 03:53:19 PM »
correction:

the NASM version 2.08(RCs) should be used to make and run successfully both the 32 and 64 bit posted MacOS quines under MacOS Snow Leopard.

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

i was rechecking the 2.01 directory download section for /macos since i mentioned it earlier but didn't find it. so i wondered and just made sure by just seeing the -ver on my apple computer.

27
Example Code / Re: MacOS Quine (And Many More)
« Last post by alCoPaUL 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)
28
Programming with NASM / syscalls - MacOS
« Last post by fredericopissarra on January 27, 2023, 11:06:16 AM »
Just an info for you all...

MacOS is derived from FreeBSD and its syscalls follows the SysV ABI for i386 with extensions and a minor difference for x86-64: Instead of changing RCX by R10, MacOS uses RCX... and, again, yep... i386 table is used in x86-64 mode, so sys_exit is 1 and sys_write is 4.

I don't have a MacOS machine to test this, by this 'hello.asm' should work on MacOS in x86-64 mode:
Code: [Select]
  bits 64
  default rel   ; program need to be PIE.

  section .rodata

msg:     db `Hello\n`
msg_len  equ $ - msg

  section .text

  global _start

  align 4
_start:
  mov  eax,4      ; sys_write (must be 1 on Linux)
  mov  edi,1      ; stdout
  lea  rsi,[msg]
  mov  edx,msg_len
  syscall

  mov  eax,1      ; sys_exit (must be 60 on Linux)
  xor  edi,edi
  syscall
For i386 mode int 0x80 is used the same way as in Linux...

Reading some material I found that maybe the sections could be renamed to __text and __rodata. But I don't know where to find the official MacOS Reference to confirm.
29
Programming with NASM / Re: I need help
« Last post by Frank Kotler on January 27, 2023, 09:04:42 AM »
What OS?

sys-sleep in Linux...

Best,
Frank

30
Example Code / Re: MacOS Quine (And Many More)
« Last post by Winifred58 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
Pages: 1 2 [3] 4 5 ... 10