What is the primary book used
There isn't one. Most people don't learn this stuff by reading a book.
The best way to learn is by looking at actual assembly code, then research what each instruction does. I wouldn't start with actual compiler generated code. Being computer generated it's often quite messy and obviously undocumented. Best to start with easier to read code like the example I've included below — a simple "print Hello World" in CISC, then in RISC.
Notice CISC uses mov, int and xor, while RISC uses mov, ldr, and svc. You should look those up in a manual (plenty of free ones online) but in simple terms:
mov: move memory from one place to another. RISC and CISC have the same instruction but but they're not identicalint: means interrupt, essentially stop execution (for a moment) and hand execution over to other softwarexor: modifies a value (an XOR operation)ldr: is "load register", it loads a value from elsewhere in memorysvc: means "supervisor call" which, is used in much the same way asint. The code is asking the kernel to do something (once to write to stdout, and once to terminate the program).
section .data
helloWorld db 'Hello World',0xa ; 'Hello World' string followed by a newline character
section .text
global _start
_start:
; write(1, helloWorld, 13)
mov eax, 4 ; system call number for sys_write
mov ebx, 1 ; file descriptor 1 is stdout
mov ecx, helloWorld ; pointer to the string to print
mov edx, 13 ; length of the string to print
int 0x80 ; call kernel
; exit(0)
mov eax, 1 ; system call number for sys_exit
xor ebx, ebx ; exit status 0
int 0x80 ; call kernel
.section .data
helloWorld:
.asciz "Hello World\n"
.section .text
.global _start
_start:
; write(1, helloWorld, 13)
mov r0, #1 ; file descriptor 1 is stdout
ldr r1, =helloWorld ; pointer to the string to print
mov r2, #13 ; length of the string to print
mov r7, #4 ; system call number for sys_write
svc 0 ; make system call
; exit(0)
mov r0, #0 ; exit status 0
mov r7, #1 ; system call number for sys_exit
svc 0 ; make system call