RE: Help me with my new website!
December 28, 2018 at 2:38 pm
(This post was last modified: December 28, 2018 at 3:41 pm by FlatAssembler.)
Quote:I use HTML5 a lot, and older browsers don't support those tags anywayUsing an unsupported tag won't cause a parser error. You use the "main" tag, right? Internet Explorer 11 doesn't support the "main" tag, yet it becomes a part of the DOM and you can manipulate it using JavaScript and CSS. In Internet Explorer 6, the same is true for other HTML5 tags.
Quote:I simply do not care whether they are supported.Now that I see making the page render correctly in Internet Explorer 6 doesn't make it render correctly in all modern browsers, I don't care too much either.
Quote:I would never bother directly manipulating so much code like you have,Well, it was relatively easy to do for me since I was hand-writing all the JavaScript. Are you using CoffeeScript or something like that?
With CoffeeScript, it should be even easier to support older browsers since it transpiles to ES3, so I guess you are not using CoffeeScript, but something similar.
Do you think such things really help? I think they probably help a little if you find the time to learn them (CoffeeScript, for example, has a very weird syntax to me, but I can see how some of its features can come useful), but we cannot compare hand-writing JavaScript to hand-writing Assembly.
Quote:IE11 and the Apple browsers are currently a problem, since a lot of people use both of them.Apple browsers are a problem?
Well, I can see how Safari on iPhone could be a problem, it has a somewhat quirky font rendering (but that appears to be true not just for Safari, but for entire iOS, since similar problems appear in Objective-C), and it appears to execute JavaScript slightly slower than Mobile Chrome or Android Stock Browser (my SVG PacMan is barely playable on iPhones because of that).
But Safari on MacOS appears to be an excellent browser. I don't even have Chrome installed either on my 12-year-old PC or on my 5-year-old MacAir, but every time I test my website in Chrome on someone's computer, it works exactly the same as in Safari on Mac (apart from maybe taking slightly longer to load). Are you saying it's not like that the other way around (that what works in Chrome needs to be tweaked to work in Safari on Mac)?
By the way, I've managed to tweak almost the entire JavaScript on the compiler page to work in Duktape. Now it's trivial for me to process entire files and output assembly to some other file. You can download the Duktape-compatible version as well as the customized C stub required to run it on the compiler page (there is a link to a ZIP archive containing the source files there). This was my first program written in my own programming language (I call that programming language AEC, "Arithmetic Expression Compiler"):
Code:
AsmStart ;This part of code is Windows-dependent, so it has to be done in inline assembly.
debug=0
format PE console
entry start
include 'win32a.inc'
section '.text' code executable
start:
AsmEnd
i:=1
j:=1
While i<101
j:=1
While j<101
AsmStart
if debug=1 ;Invoking FlatAssembler preprocessor.
fld dword [j]
fstp qword [esp+12]
fld dword [i]
fstp qword [esp+4]
mov dword [esp],_debugOutput1
call [printf]
end if
AsmEnd
If i>j
a:=i
b:=j
Else
a:=j
b:=i
EndIf
While (b>1/100)&(a>1/100) ;Modified version of the Euclid's algorithm.
If a>b
a:=mod(a,b)
Else
b:=mod(b,a)
EndIf
EndWhile ;There is a reason why BASIC used different keywords for "EndIf" and "EndWhile", because they are trivial to translate to Assembly :-).
subscript:=i*101+j
If a>1/100
gcd[subscript]:=a ;Warning: Arrays are write-only in this version of AEC, they have to be read in inline Assembly. Hopefully that's not too hard.
Else
gcd[subscript]:=b
EndIf
AsmStart
if debug=1
fld dword [a]
fstp qword [esp+20]
fld dword [j]
fstp qword [esp+12]
fld dword [i]
fstp qword [esp+4]
mov dword [esp],_debugOutput2
call [printf]
mov dword [esp],_pause
call [system]
end if
AsmEnd
j:=j+1
EndWhile
i:=i+1
EndWhile
AsmStart
mov dword [esp],_output1
call [printf]
mov dword [esp+4],firstNumber
mov dword [esp],_input1
call [scanf]
mov dword [esp],_output2
call [printf]
mov dword [esp+4],secondNumber
mov dword [esp],_input1
call [scanf]
fild dword [firstNumber]
fstp dword [a]
fild dword [secondNumber]
fstp dword [b]
AsmEnd
subscript:=4*(a*101+b) ;While you need to use inline Assembly to read arrays, you can still calculate subscripts in AEC.
AsmStart
fld dword [subscript]
fistp dword [subscript]
mov ebx,[subscript]
fld dword [gcd+ebx]
fst qword [esp+4]
mov dword [esp],_output3
call [printf]
invoke system,_pause
invoke exit,0
_debugOutput1 db "DEBUG: Attempting to calculate the GCD of %f and %f.",10,0
_debugOutput2 db "DEBUG: GCD of %f and %f is %f.",10,0
_output1 db "Enter the first number (whole number 1-100): ",0
_input1 db "%d",0
_output2 db "Enter the second number (whole number 1-100): ",0
_pause db "PAUSE",0
_output3 db "Their greatest common divisor is: %f",10,0
section '.rdata' readable writable ;Yes, you are expected to declare the variables yourself in inline assembly, as the way it's done varies greatly from one operating system to another.
result dd ?
a dd ?
b dd ?
i dd ?
j dd ?
firstNumber dd ?
secondNumber dd ?
subscript dd ?
gcd dd 101*101 dup(?)
section '.idata' data readable import ;Those functions can't be called from this version of AEC (as the way to call them in Assembly varies from one operating system to another), they have to be called from inline Assembly.
library msvcrt,'msvcrt.dll'
import msvcrt,printf,'printf',system,'system',exit,'exit',scanf,'scanf'
AsmEnd