So, I then plugged the router in, and it stopped working. I rebooted my server, and ipconfig said that its IP was 192.168.1.100. Which is wrong, since my router dishes out static IPs and my server should be 192.168.1.200. After more potering around, I discovered that our wireless router - which is set up in access point mode - has decided that even though it's an access point, it's going to try and grab all the IP addresses, and act as a DHCP server. So, the access point was grabbing the IP from the modem before the router had a chance, and it was then dishing out IP addresses to the PCs on the network. But since there was no port forwarding set up on the access point, nobody could get to my server from the Internet, and for some reason nobody could get on the Internet from inside the network.
So, unplugging the access point while everything else booted up, and then plugging it in after seems to have fixed it. Now I need to investigate why the hell it's started doing that now...
Druinkscript.
So. Code generation is nearly working now. The optimiser is a work in progress.
Input file:
void Test() {
int test = 12 + 5 * 4 - 100 / 50;
}
Output file:
; test.dasm; Compiled from test.ds; By DruinkScript Compiler v1.0;---------------------------------------; Function: Test; Returns: void; Parameters: Nonefunc Test{ push 50 push 100 pop r0 pop r1 div r0, r1 push r0 push 4 push 5 pop r0 pop r1 mul r0, r1 push r0 push 12 pop r0 pop r1 add r0, r1 push r0 pop r0 pop r1 sub r0, r1 push r0 pop r0 mov test, r0}
After step 1 of optimising (Removing push/pop pairs):
func Test{ mov r0, 100 mov r1, 50 div r0, r1 mov r0, 5 mov r1, 4 mul r0, r1 mov r0, 12 mov r1, r0 add r0, r1 mov r0, r0 mov r1, r0 sub r0, r1 mov r0, r0 mov test, r0}
After step 2 of optimising (Removing redundant mov's):
func Test{ mov r0, 100 div r0, 50 mov r0, 5 mul r0, 4 mov r0, 12 mov r1, r0 add r0, r1 mov r0, r0 mov r1, r0 sub r0, r1 mov r0, r0 mov test, r0}
Hmm. Yeah. Needs some work...
I know the expression itself isn't getting optimised, but it will do eventually.
Other exciting stuff: That last line there, where it moves register 0 into test. Yeah, that's broken too. I have three choices that are immediately obvious:
- Make DruinkASM and DruinkVM support stack offsets, x86 style (mov eax, [esp-4]).
- Make DruinkASM and DruinkVM support a variable location, like I do with registers. E.g. v0..v10. That limits the number of variables I can support, however.
- Have an infinite number of registers (Or 65536 or something), and store variables in registers. This is my preference, and the script can say how many registers it needs, so there's no need for redundant allocations.
Still, nothing that major. I also need to give this thing some serious testing, and then I want to make some performance test apps between DruinkScript and Lua, and some profiling. Firstly, a fibonacci sequence app (Although that really just tests how expensive function calls are), and some other test, like looping 10000 times, doing something or other (Calling a C++ func?)
EDIT:
Shit. I need a stack to recurse. Looks like I'll be going for option #1. Should be easy anyway, I can just move stuff from stack to register when needed.