Re: [fpc-pascal] What's in Hello World

2024-01-11 Thread DougC via fpc-pascal
Ah, yes! The Hello World Machine.



Doug C.







 On Thu, 11 Jan 2024 14:34:29 -0500 Adriaan van Os via fpc-pascal 
 wrote ---



Nikolay Nikolov via fpc-pascal wrote: 
 > But that increases the binary size to 28 bytes. We can put a 'ret' 
 
That's still 27 bytes too much. Let's design a CPU that has "Hello World" as a 
one-byte 
instruction, implement that CPU in a Field-programmable gate array, write an OS 
for it and let it 
say hello. That's HelloWorld ad absurdum. 
 ___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] What's in Hello World

2024-01-11 Thread Adriaan van Os via fpc-pascal

Nikolay Nikolov via fpc-pascal wrote:

But that increases the binary size to 28 bytes. We can put a 'ret' 


That's still 27 bytes too much. Let's design a CPU that has "Hello World" as a one-byte 
instruction, implement that CPU in a Field-programmable gate array, write an OS for it and let it 
say hello. That's HelloWorld ad absurdum.


Or just send some smoke signals 



Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] What's in Hello World

2024-01-11 Thread Nikolay Nikolov via fpc-pascal


On 1/7/24 14:21, Ingemar Ragnemalm via fpc-pascal wrote:


Just for comparison, I fired up Think Pascal and made Hello world!

Plain Hello world, closes so quickly that you don't have time to see 
it: 4625 bytes.


Including ShowText and while not Button do; 4639 bytes.

Yes, less than 5k! Progress?


Nah! It's bloat, bloat, bloat, horrible bloat!!! I'm not impressed. :)

Nothing beats assembler for DOS:

; nasm asmhello.asm -o asmhello.com
    bits 16
    cpu 8086
    org 100h
    mov dx, msg
    mov ah, 9
    int 21h
    ret
msg:    db 'Hello, world!', 13, 10, '$'

The produced executable is only 24 bytes (8 bytes of code and 16 bytes 
of data):


BA 08 01 B4 09 CD 21 C3 48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 21 0D 0A 24

You can write this down on a sheet of paper, or memorize it and recite 
it from memory. Try doing that with 4639 bytes :)


Note that noobs will use the following way to terminate the program:

mov ax, 4c00h

int 21h

But that increases the binary size to 28 bytes. We can put a 'ret' 
instruction instead, and that works, because DOS puts a h word on 
top of the stack, and that points to CS:h, which is the beginning of 
the PSP. And that starts with an int 20h, which is the oldschool (MS-DOS 
version 1) way of terminating a process, which requires CS to point to 
the PSP, which it does, because we're a .com file.


Nikolay

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] %LINENUM%

2024-01-11 Thread Adriaan van Os via fpc-pascal

Section 1.2.41 of the Free Pascal Programmer’s Guide version 3.2.0 says:

	"As a result, this will generate a macro with the value of the XXX specifier, as if it were a 
string (or, in the case of LINENUM, an integer)."


I don't think this is correct, or at least requires clarification. One can not insert integers (as 
such) into a text stream. I think, the correct description is:


	"As a result, this will generate a macro with the value of the XXX specifier, as a quoted string 
(or, in the case of LINENUM, as an unquoted string)."


Regards,

Adriaan van Os



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal