comment, rename, reformat
authorFrantišek Kučera <franta-hg@frantovo.cz>
Fri, 22 Dec 2017 18:14:40 +0100
changeset 165c142e9c00e5
parent 15 4b4fb847d01a
child 17 8f0a5552db78
comment, rename, reformat
c++/rgb-assembler/rgb-assembler.cpp
     1.1 --- a/c++/rgb-assembler/rgb-assembler.cpp	Fri Dec 22 18:09:58 2017 +0100
     1.2 +++ b/c++/rgb-assembler/rgb-assembler.cpp	Fri Dec 22 18:14:40 2017 +0100
     1.3 @@ -104,6 +104,8 @@
     1.4  
     1.5  	byte_t * memory = (byte_t*) malloc(MEMORY_SIZE);
     1.6  
     1.7 +	// Sample program / data:
     1.8 +	// TODO: load bytes from file, stdin, serial port, network…
     1.9  	{
    1.10  		address_t a = 0;
    1.11  		write<command_t>(memory, a, CMD_SLEEP);
    1.12 @@ -138,10 +140,10 @@
    1.13  
    1.14  	for (address_t i = 0; i < MEMORY_SIZE;) {
    1.15  		wprintf(L"command %*d = ", 4, i);
    1.16 -		command_t ch = read<command_t>(memory, i);
    1.17 -		wprintf(L"%02X  ", ch);
    1.18 +		command_t command = read<command_t>(memory, i);
    1.19 +		wprintf(L"%02X  ", command);
    1.20  
    1.21 -		switch (ch) {
    1.22 +		switch (command) {
    1.23  			case CMD_GOTO:
    1.24  			{
    1.25  				i = read<address_t>(memory, i);
    1.26 @@ -171,9 +173,9 @@
    1.27  				address_t address_r = address;
    1.28  				address_t address_w = address_r;
    1.29  				byte_t value = read<byte_t>(memory, address_r);
    1.30 -				value = ch == CMD_INCREMENT ? value + 1 : value - 1;
    1.31 +				value = command == CMD_INCREMENT ? value + 1 : value - 1;
    1.32  				write<byte_t>(memory, address_w, value);
    1.33 -				wprintf(L"%sCREMENT %*d → %02X\n", (ch == CMD_INCREMENT ? "IN" : "DE"), 5, address, value);
    1.34 +				wprintf(L"%sCREMENT %*d → %02X\n", (command == CMD_INCREMENT ? "IN" : "DE"), 5, address, value);
    1.35  				break;
    1.36  			}
    1.37  			case CMD_GOTO_COMPARE:
    1.38 @@ -187,13 +189,10 @@
    1.39  				byte_t a = read<byte_t>(memory, aa);
    1.40  				byte_t b = read<byte_t>(memory, ab);
    1.41  
    1.42 -				if (a == b) {
    1.43 -					i = eq;
    1.44 -				} else if (a > b) {
    1.45 -					i = gt;
    1.46 -				} else {
    1.47 -					i = lt;
    1.48 -				}
    1.49 +				if (a == b) i = eq;
    1.50 +				else if (a > b) i = gt;
    1.51 +				else i = lt;
    1.52 +
    1.53  				wprintf(L"GOTO COMPARE  a = %02X, b = %02X, eq = %d, gt = %d, lt = %d → %d\n", a, b, eq, gt, lt, i);
    1.54  				break;
    1.55  			}