Forum has syntax highlight support for different languages

This is the place to share ideas, likes and dislikes of the SharpBASIC language
Post Reply
User avatar
frank
Site Admin
Posts: 40
Joined: Sun Nov 21, 2021 12:04 pm
Location: Netherlands
Contact:

Forum has syntax highlight support for different languages

Post by frank »

The nice thing about syntax highlight support is that multiple languages can be supported. Prism supports a wide range of languages. By adding the language name to the code tag, the language tokens will be recognized. While this forum has default highlight support for SharpBASIC, adding e.g. "pascal" to the code tag (code=pascal) allows for nicely sharing Pascal code snippets.

Below are "hello world" examples in Pascal, BASIC, C, SharpBASIC and NASM.

Pascal:

Code: Select all

program HelloWorld(output);
begin
    Write('Hello, World!')
    {No ";" is required after the last statement of a block -
        adding one adds a "null statement" to the program, which is ignored by the compiler.}
end.
BASIC:

Code: Select all

print "Hello, World!"

sleep:end  rem Comment, prevents the program window from closing instantly
C:

Code: Select all

#include <stdio.h>
int main() {
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}
SharpBASIC:

Code: Select all

incl "sys.sbi";
main do
  ' print to standard output device (stdout)
  print("Hello, World!");
end
NASM:

Code: Select all

; Define variables in the data section
SECTION .DATA
	hello:     db 'Hello world!',10
	helloLen:  equ $-hello

; Code goes in the text section
SECTION .TEXT
	GLOBAL _start 

_start:
	mov eax,4            ; 'write' system call = 4
	mov ebx,1            ; file descriptor 1 = STDOUT
	mov ecx,hello        ; string to write
	mov edx,helloLen     ; length of string to write
	int 80h              ; call the kernel

	; Terminate program
	mov eax,1            ; 'exit' system call
	mov ebx,0            ; exit with error code 0
	int 80h              ; call the kernel
Last edited by frank on Tue Jul 04, 2023 8:44 am, edited 1 time in total.
Keep it simple!
Post Reply