What would you want in a programming language?
I just checked out the PMODE example in C-- and it does infact have much of what I desired lol. weird, I had never even heard of it.
Website: https://joscor.com
All you need is fasm and you can use the very powerfull macro.
Example1. here is a simple example of turning fasm code into a quick and dirty Qbasic:
Use these macro
And then you can do this:
Example2.
Or using a macro like case
you can do this:
With the aid of some good macro, you can have your low and HLL language,its is call FASM.
Example1. here is a simple example of turning fasm code into a quick and dirty Qbasic:
Use these macro
Code: Select all
macro PRINT String{
local .Printer
local .Nextchar
local .Done
local .a
.Printer:
mov si, .a
mov ah, 0Eh
jmp .Nextchar
.Nextchar:
lodsb
or al, al
jz .Done
int 10h
jmp .Nextchar
jmp .Done
.a db String,10,13,0
.Done:
}
macro SCREEN mode
{
push ax
if mode = 0
mov ah,0h ;SCREEN 0; Default DOS screen mode
mov al,3h
int 10h
else if mode = 13
mov ah,0h ;SCREEN 13; VGA
mov al,13h
int 10h
end if
pop ax
}
macro SLEEP
{
;Output:
;ah = BIOS scancode of key pressed
;al = ASCII character of key pressed
;Could have also used...
; mov ah,8h
; int 21h
mov ah,0h
int 16h
}
macro END
{
mov ax,4Ch ;\END
int 21h ;/
}
macro LOCATE row,col
{
pusha
mov ah,2 ;Function 2
mov bh,0 ;Use page 0
mov dh,row ;row
mov dl,col ;col
int 10h
popa
}
Code: Select all
SCREEN 0
COLOR 33
LOCATE 5,5
PRINT "Hello World"
SLEEP
END
Or using a macro like case
Code: Select all
macro case op1,op2
{
cmp byte [edx],op1
je op2
}
Code: Select all
;;---------------------------------------------------------;;
;; - Solidus117
;; Team DexOS
;; Interpret
;; Interpret the Brainfuck source, acting upon the VMM
;;---------------------------------------------------------;;
Interpret:
mov edx,loadpoint-1
mov ebx,memory
lp: inc edx
case '+',incval
case '-',decval
case '>',incptr
case '<',decptr
case '.',putval
case ',',getval
case '[',tstjmp
case ']',uncjmp
case 00h,@f
jmp lp
@@: ret
SpooK wrote:Such a desired language already exists, it is called C--
But from the C-- syntax/reference manual:
Code: Select all
... constant expressions are always calculated
from left to right, contrary to the usual rules of arithmetic. This is
unlike the situation in other computer languages, and you must be careful
when writing expressions to remember that 2+3*2 equals 10 and not 8.
Considering that in that case, probably there's no standard defined operator precedence and then things will be calculated depending on the operators used in an expression, as they appear, from left to right, and that would force to re-code to reorder the set-up of a finished algorithm back and forth whenever expressions are concerned?
YouTube:
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
So, if such a way of solving expresions through a relatively simplified and non-standard interpreter and therefore, if producing a non-standard result is perfectly acceptable, it's safe to assume that in spite of anything else, such a product would be far more acceptable if it would solve expressions in a standard way without requiring nestings or groupings for getting it?JamesM wrote:So use parentheses. They're in the lexeme, so they're there to be used.
YouTube:
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
http://youtube.com/@AltComp126
My x86 emulator/kernel project and software tools/documentation:
http://master.dl.sourceforge.net/projec ... 7z?viasf=1
the fact that the expressions are taken from left to right is really odd. I don't like that at all, its almost like they didn't want to put the effort into making the math processing CORRECT.
Website: https://joscor.com
Well, that would involve much less effort than trying to write such a desired language from scratch. Even if you had to develop a stand-alone numeric preprocessor, C-- already covers the rest.01000101 wrote:the fact that the expressions are taken from left to right is really odd. I don't like that at all, its almost like they didn't want to put the effort into making the math processing CORRECT.
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
There is a precedent. Smalltalk also processes all binary operators from left to right, mainly because all operators are conceptually just messages. It pretty much makes parentheses in arithmetic expressions a requirement.
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
As does LISP, and all LISP based languages. LISP doesn't have infix operators at all, you have to define everything in a sort of reverse polish notation:
Also, instead of bitching about a language that was quite specifically dumbed down from a parsing perspective, try looking, and you'll find it's bigger cousin, C-. C- Builds on C-- in a couple of areas, specifically operator precedence.
Code: Select all
(+ 4 (* a b) 5) = 4+ a*b + 5
I'm not bitching about it, I don't even use it.. nor am I looking for languages, therefore I was not seeking its big cousin in the first place.
so lets see, there's C++,C,C-,C--.... any others?
so lets see, there's C++,C,C-,C--.... any others?
Website: https://joscor.com
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
My imaginary OS-dev language would feature:
- no single dependency on a runtime. (like assembler, C)
- inline assembly (both turbo C style (compiler preserves the necessary stuff) or GCC style (programmer specifies in/out/clobber) )
- user-defined width variables (not restricted to powers of two, or above
- native support for platform features (think: segmentation, vector instructions, atomic operations)
- a subset that is strictly cross-platform
- function pointers
- macros
- function and operator overloading (as in Haskell, new combinations of characters included)
- structs and typedefs (C style), enumerations (VB style), datatypes (haskell style)
- object-oriented programming
- customizable calling conventions
- aspect-oriented programming (powerful enough to implement garbage collection and have each defined class use that automatically)
- templates
- strong typing
For the geeks among us:
- a LL(1) grammar
The compiler:
- loads of semantic checks
- a -Werror flag
And on the far end of the wish list...
- header file generation
- dependency generation
- template and aspect export
- hash generation
- split array definition (where the linker will concatenate arrays defined over multiple object files)
- no single dependency on a runtime. (like assembler, C)
- inline assembly (both turbo C style (compiler preserves the necessary stuff) or GCC style (programmer specifies in/out/clobber) )
- user-defined width variables (not restricted to powers of two, or above
- native support for platform features (think: segmentation, vector instructions, atomic operations)
- a subset that is strictly cross-platform
- function pointers
- macros
- function and operator overloading (as in Haskell, new combinations of characters included)
- structs and typedefs (C style), enumerations (VB style), datatypes (haskell style)
- object-oriented programming
- customizable calling conventions
- aspect-oriented programming (powerful enough to implement garbage collection and have each defined class use that automatically)
- templates
- strong typing
For the geeks among us:
- a LL(1) grammar
The compiler:
- loads of semantic checks
- a -Werror flag
And on the far end of the wish list...
- header file generation
- dependency generation
- template and aspect export
- hash generation
- split array definition (where the linker will concatenate arrays defined over multiple object files)
-
- Member
- Posts: 566
- Joined: Tue Jun 20, 2006 9:17 am
Some people say that a language should only allow minimal amount of constructs so that it is easier to design the language as well as learn the language . Their viewpoint is , more features you have , far easier it becomes to write unreadable code . Btw the recent trend is squeeze lots of features into a single language so that it becomes unmaintainable afterall ... But this approch has its weakness ....
That might be the difference between languages say, like Ada, where EVERYTHING was a part of the language, and Java, where most of the language specification is in the library, which you don't have to use all of if you don't want.
My current opinion is that if you have third-party libraries to do stuff that could be made standard, then you are just inviting code incompatibility and rewriting. So I think what would be best would be using an 'external' standard library: it provides everything the programmer would want to use, but they don't have to use it, and it can be taken away to give just the core language.
My current opinion is that if you have third-party libraries to do stuff that could be made standard, then you are just inviting code incompatibility and rewriting. So I think what would be best would be using an 'external' standard library: it provides everything the programmer would want to use, but they don't have to use it, and it can be taken away to give just the core language.