3 ms·
Question; it's been 20 years since I've done assembler, but I want to understand in what sense is this "512 bytes"? - The downloaded COM file is almost 64k -
by NikolaNovak 7y ago
Question; it's been 20 years since I've done assembler, but I want to understand in what sense is this "512 bytes"?
- The downloaded COM file is almost 64k
- The source code appears to be about 4k
Is 512 bytes the memory footprint? Assembled but not linked code? Something else?
- bepvte 7y agoCompiled, it is 512 bytes. The com file is for running out side of the boot sector afaik.
- simcop2387 7y agoIt's also possible that the com file is just being padded because of the way they work, statically loaded into a specific 64kb segment of ram, limiting their size to 64kb. The assembler might just be padding it to zero out the rest of the segment, even though it isn't needed.
- acqq 7y agoI never saw any unnecessary padding there. The initial commit was 512 bytes for .com. 9e7101f BIN +512 Bytes invaders.com One can also boot directly from the 512 byte floppy disk image .img, e.g. qemu-system-i386w -fda invaders.img
- oops 7y agoOr the OP downloaded the HTML page[1] instead of the raw file. The HTML for a signed-out user is about 64kB. 1: https://github.com/nanochess/Invaders/blob/master/invaders.com https://github.com/nanochess/Invaders/blob/master/invaders.c...
- 300bps 7y agoin what sense is this "512 bytes"?...The source code appears to be about 4k The source .asm file is about 4k, most of which consists of comments. The rest is assembly language code with things like: mov ah,al That assembly language which is 17 bytes including the preceding spaces gets assembled into machine language which is substantially lower. I'm much more familiar with 6510 assembly than I am 8086 assembly but I believe mov ah,al is one byte for the mnemonic and two bytes for the registers for a total of 3 bytes. So the actual machine code is far smaller than the assembly source code.
- a1369209993 7y ago> mov ah,al is One byte for [mov Gb Eb] and one byte for [modrm sp ax] (ah == (byte) r4 (word) == sp). x86 is pretty good about code density.
- acqq 7y ago> I believe mov ah,al is one byte for the mnemonic and two bytes for the registers for a total of 3 bytes. Two bytes in the 8086 mode: 88C4 mov ah,al And inside, ah and al are encoded with the 3 bits each, spending just 6 bits for "from which register to which register."
- acqq 7y ago> - The downloaded COM file is almost 64k I don't know how you did that, but now I've downloaded it and I get: ls -l invaders.com -rwxrwxrwx 1 user group 518 Jun 7 00:00 invaders.com The boot sector version is: ls -l invaders.img -rwxrwxrwx 1 user group 512 Jun 7 00:00 invaders.img The .com file is bigger because it has "more features" -- it allows one to "exit" the game, and in the com version it doesn't have to be less or equal of 512 bytes to fit, the boot sector version has that limitation. I also see that even the first commit had both the .com and the .img 512 bytes: 9e7101f BIN +512 Bytes invaders.com BIN +512 Bytes invaders.img I was also able to configure a virtual machine to boot from invaders.img (512 bytes) as a "floppy disk image."