I still have Russell Rector/George Alexy's "The 8086 Book" on my bookshelf, from 1980. Not sure it would be helpful in a modern context, but it has descriptions of all the op codes and example programs at the back.
https://www.amazon.com/8086-Book-Russell-Rector/dp/007931029X
I absolutely adore GUI Turbo Assembler (TASM) for 16bit DOS work. It works great in a Windows environment, assembles with the reliable TASM, and even automatically loads DOSBox to execute the binaries. It doesn't have all the fancy features of other IDEs, but it's wonderful for what it does.
No, it actually looks reasonable to me. I particularly like how it explains the Intel manual's formatting in the 4th set of slides, that's a really crucial resource for working out what's going on. It's just a slightly different emphasis to what I'd do.
What I'd suggest is installing Windows on a virtual machine in your macOS computer (e.g. via VirtualBox). Then you can follow along easily enough with the real exercises.
Best use case is just understanding that layer of computer systems. ASM has very limited real world applications.
Check out the KolbriOS for a relatively modern Operating System written in ASM.
I don't know about graphics (I think Mr. Google should give you some directions on that), but I'd say there is a lot of layers. Obligatory James Hague.
Also, if you want to see, what is it like, when an OS is written completely in assembly, is unportable, but has nice GUI, minimalist API, fits 1.44 Mb diskette and is “flat”, I'd recommend you KolibriOS. It's mostly made by the Russian guys, but they have some English docs, and making a new window there is as easy as filling all four registers and call an interruption. A very interesting and educating experiment.
Edit: mark up.
I recommend RISC-V. It is significantly simpler than ARM or x86.
RISC-V is obviously not as common as ARM or x86 at the moment, but it's growing fast, is taking significant sales from ARM in the embedded world, and is already killing off virtually everything that isn't ARM or x86.
MIPS, for example, has abandoned their own ISA and is adopting RISC-V. The same for the Taiwanese company Andes, which is replacing its own widely-used (at least in China) NDS32 ISA (which is important enough to be supported by mainline gcc and Linux) with RISC-V. The very popular ESP32 line of Wifi/Bluetooth chips is moving from xtensa to RISC-V. NXP, Allwinner, and Microchip have started making some RISC-V chips. Intel has announced they are making a chip using RISC-V CPU cores as the main processors. And so on.
There are a growing number of small boards using RISC-V, starting from the Longan Nano, which is $5. There are RISC-V boards running Linux, but they are not yet as cheap as the Raspberry Pi. The best deal right now is the Allwinner "Nezha" for $99. It's similar in capability to a Raspberry Pi Zero. Sipeed and Pine64 have both promised boards using the same chip for $10-$15 in the coming months. Things are moving fast.
You can also easily use an emulator on your Windows, Mac, or Linux computer. On Linux you can install the QEMU RISC-V emulator using the "binfmt_misc" feature and run RISC-V programs just as if they were native code, except about three or four times more slowly.
The following $20 book is a pretty good absolute beginner introduction to RISC-V assembly language. It uses its own tools which are a little bit non-standard but fine. They run on Windows, Mac, Linux.
https://www.amazon.com/RISC-V-Assembly-Language-Anthony-Reis/dp/1088462006
Not right now. For me it's easy to get distracted by the amount of great books and courses you can find nowadays so I try to commit to one book from beginning to end making sure I understand all the concepts. Anyway I may enroll in this course:
https://www.cybrary.it/course/assembly/
As well as buy this two books, the second being more for reference:
Although I may change my plan an focus more on learning ARM.
Well, it's a made-up dialect by one of our professors. Somebody on hackernews said it looks like "a mix of AVR and 8051".
So nothing real, it's just for learning the mechanics :)
if you want to write assembly on Linux you are better of using nasm instead unless you have very specific reason to use gnu asm, but if you do there is an old book that will help you https://www.amazon.com/Linux-Assembly-Language-Programming-Neveln/dp/0130879401
Is it this book:
https://www.amazon.co.uk/Assembly-Language-Step-Step-Third/dp/0470497025
At least it uses Nasm and not the ghastly AT&T syntax, but Nasm works on other OSes too, so I'm not sure why it needs to be specific to Linux (details of call-conventions are a small part of assembly).
But, it is for 32-bit 8086 (and seems to cover 16 bits too), which is old hat now. As for the contents, I found the style unreadable from glancing through the preview pages. I don't think it even got as far as mentioning assembly at all.
A "Web Extension" chapter from Hennessy and Patterson's textbook. The book is primarily focused on the MIPS architecture, as an example of RISC, but this chapter presents an influential CISC architecture as an alternative.
I like what you're doing.
Here's another course with a similar Tetris-in-assembly destination. "From Nand to Tetris". It was offered in April 2015 but if you "enroll" now, the materials are still available.
here's (another) working version more like yours: https://repl.it/repls/PlushHandsomeIteration
#include <stdio.h>
int calcArea(int side1, int side2) {
int area;
asm(
".intel_syntax;"
"mul bx;" // multiplies ax by bx
"mov cx, 2;" // set cx to 2
"div cx" // divides ax by cx
: "=a" (area) // output `area` will be in ax
: "a" (side1), // input `side1` will be in ax
"b" (side2) // input `side2` will be in bx
: "cx" // we clobber cx
);
return area;
}
int main(void) {
int a, b;
printf("enter a, b: ");
scanf("%d%d", &a, &b);
printf("area: %d\n", calcArea(a, b));
return 0;
}
here's a working example: https://repl.it/languages/c
#include <stdio.h>
int area(int a, int b) { int rsl;
asm("mull %%ebx \n\t" "shrl %%eax" : [rsl] "=a" (rsl) : [a] "a" (a), [b] "b" (b));
return rsl; }
int main(void) { int a, b; printf("enter a, b: "); scanf("%d%d", &a, &b);
printf("area: %d\n", area(a, b)); return 0; }
with intel syntax:
asm(".intel_syntax\n\t" "mul ebx \n\t" "shr eax" : [rsl] "=a" (rsl) : [a] "a" (a), [b] "b" (b));
note x86 div
doesn't support an immediate divisor so I used shr
instead
Yes, -1 is the same as 0xffffffffffffffff on x64 and 0xffffffff on x32 if you interpret it as a pointer (don't do this, you're supposed to compare against MAP_FAILED, even in assembler). In both cases, this is part of the reset vector in both architectures and is not a valid physical memory address. Attempting to access it using anything other than bytewise addressing will cause the CPU to GPF.
If you're writing user space code, then the kernel uses virtual memory to map various regions in that area, in x64 there's a 2 megabyte hole there that's off limits and will cause the kernel to segfault your process if you try to touch it. See here:
Some code here.
Like /u/McLurkin said; there are layers of abstraction (and IMO huge inefficiencies) in networking. There are implementations of specific layers around, couldn't find a full stack.
It's relatively easy to get access to files from inside DOSBox, you just have to use the mount command to expose a particular directory and it's contents as a virtual drive using a particular drive letter (A-Z, except realistically A and B are reserved for floppy drives and C may be used already). It's also possible to mount floppy images (typically .IMG) and cd-rom images (typically .ISO).
As for making use of emu8086.inc, you simply need to make sure that the Macro and Procedure definitions are included appropriately for the assembler used. MASM stands for the 'Microsoft Macro Assembler'.
I believe MASM has an INCLUDE directive that you may be able to use in your code. You probably need to keep the include file and the actual code for your program in the same directory so it can find it.
E.g.
> INCLUDE emu8086.inc
P.S.
https://www.dosbox.com/wiki/MOUNT
https://en.wikipedia.org/wiki/Microsoft_Macro_Assembler
Hey..
Thanks for your help so far. I got my professor to help me understand what I was still insisting on messing up after you helped out, and am delighted to say i actually got my print and fill subroutines to work. The sort has been a whole different monster though. I am trying to send the code as attachment through email to my professor but the combination of me needing to use a school computer and wait 8-24 hours for a reply isn't really effective. Anyway. I was wondering if you could maybe point me in the right direction with this sort.. i'm still at the point of syntax errors, so it's hard to tell if my sort is even logically sound. Any pointers would be greatly appreciated, as I'm at a brick wall right now!
if you feel like taking a look: here's my updated code. My professor's comments at the bottom are referring to me using the wrong Compare ( i was using the one for ints) and that I was using ax instead of eax, etc. I think i fixed them but could never be sure.
thanks for reading.
I learned in high school ASM for DOS, and this book helped me convert my knowledge to an actual OS. It is also a very good book to start with.
Instructions (from the hard copy book edition): http://smile.amazon.com/xchg-rax-xorpd/dp/1502958082/
; 0x40 assembly riddles
"xchg rax,rax" is a collection of assembly gems and riddles I found over many years of reversing and writing assembly code. The book contains 0x40 short assembly snippets, each built to teach you one concept about assembly, math or life in general.
Be warned - This book is not for beginners. It doesn't contain anything besides assembly code, and therefore some x86_64 assembly knowledge is required.
How to use this book? Get an assembler (Yasm or Nasm is recommended), and obtain the x86_64 instruction set. Then for every snippet, try to understand what it does. Try to run it with different inputs if you don't understand it in the beginning. Look up for instructions you don't fully know in the Instruction sets PDF. Start from the beginning. The order has meaning.
ARM assembly on Raspberry Pi. This is the book I am using:
It is a really good basics book that is supposed to put you to the point that you can write major apps (not gui based, however) in ARM assembly.
The RPi is just fun anyway. It has a complete Linux environment, so in addition you can learn bash, c, python or whatever else you are interested in.
Here are two books that helped me to understand what is going on in x86 programming:
The Definitive Guide to How Computers do Math
Assembly Language Step-by-Step
Also, look into ARM assembly. It is supposed to be easy for beginners, you can find developer kits that run on Linux, and there are good books out there for ARM on Raspberry Pi (Waiting for Christmas for mine!)