Page 2 of 3
Posted: Sat Mar 08, 2008 8:51 pm
by 01000101
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.
Posted: Sat Mar 08, 2008 9:38 pm
by Dex
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
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
}
And then you can do this:
Code: Select all
SCREEN 0
COLOR 33
LOCATE 5,5
PRINT "Hello World"
SLEEP
END
Example2.
Or using a macro like case
Code: Select all
macro case op1,op2
{
cmp byte [edx],op1
je op2
}
you can do this:
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
With the aid of some good macro, you can have your low and HLL language,its is call FASM.
Posted: Sun Mar 09, 2008 8:26 am
by ~
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.
Wouldn't performing, for
2+3*2, performing in a non-standard way, plainly from left to right, (2+3)=5 and then (5*2)=10, instead of correctly (3*2)=6 and then (2+6)=8, become a considerable standarization drawback?
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?
Posted: Sun Mar 09, 2008 8:42 am
by JamesM
So use parentheses. They're in the lexeme, so they're there to be used.
* I have written a C-- parser as part of a lecture. I'll be making the code generator next year. Everything just seems so easy after working in industry for a year
Posted: Sun Mar 09, 2008 1:11 pm
by ~
JamesM wrote:So use parentheses. They're in the lexeme, so they're there to be used.
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?
Posted: Sun Mar 09, 2008 1:58 pm
by 01000101
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.
Posted: Sun Mar 09, 2008 2:48 pm
by SpooK
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.
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.
Posted: Mon Mar 10, 2008 12:08 am
by Colonel Kernel
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.
Posted: Mon Mar 10, 2008 4:29 am
by JamesM
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.
Posted: Mon Mar 10, 2008 4:32 am
by 01000101
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?
Posted: Mon Mar 10, 2008 12:43 pm
by Combuster
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)
Posted: Thu Mar 13, 2008 4:10 am
by DeletedAccount
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 ....
Posted: Thu Mar 13, 2008 4:15 am
by JackScott
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.
Posted: Thu Mar 13, 2008 4:15 am
by Zacariaz
Now what would I want from a Programming language...
audiotory programming: "computer, make me a program that does this and that...."
Posted: Thu Mar 13, 2008 4:23 am
by JackScott
We can only hope.
One thing I like about newer languages (in general) as opposed to older ones (within the C family) is that they don't require header files. I hate header files. Java doesn't need them, and it saves so much time. You just need a smart compiler/linker.