Assembly Language Textbooks - OPCodes, Registers & Tables

In summary: That's interesting. I wonder if it would run on a modern CPU.I think it's not "pretty", but "very":smile:.In summary, Jim recommends using an 8086 assembly language book that focuses more on opcodes, register status tables, etc instead of programming in assembly. John Lee recommends consulting the original manufacturers guides if you can still find them. Microsoft employee Jim suggests using "consulting" the original manufacturers guides if you can still find them. Speech recognition is difficult, and high level languages may not be sufficient.
  • #1
john_lee
1
0
hi everyone, i was wondering if you guys had any textbook recommendations on the subject of assembly language (8088 and 8086) that focuses more on opcodes, register status tables, etc rather than programming in assembly. I have been using kip irvine assembly textbook but that focuses more on programming (my professor emphasizes updating registers and where things are and in which registers) thanks
 
Technology news on Phys.org
  • #3
Hey john_lee.

Aside from actual books and notes, you might want to try "consulting" the original manufacturers guides [like the ones Intel, AMD, and IBM publish for their respective hardware] if you can still find them.

They usually have all of this information and they expect you to already know what you are doing regarding using an assembler and other such "tools".
 
  • #4
  • #5
Stephanus said:
I haven't done assembly language for 20 years. I don't think it has any use now with all the 32 register and protected mode addressing, but it's a knowledge after all.
I used to work at Microsoft (retired 3 years ago). I've seen assembly used in video drivers, as recently as 10 years ago, but I also saw some assembly used more recently in code that is used in speech recognition. I don't have access to the code base any longer, but I would be surprised if there wasn't at least some assembly code that's still there, mainly in places where extreme speed is important.
 
  • #6
Mark44 said:
I used to work at Microsoft (retired 3 years ago). I've seen assembly used in video drivers, as recently as 10 years ago, but I also saw some assembly used more recently in code that is used in speech recognition. I don't have access to the code base any longer, but I would be surprised if there wasn't at least some assembly code that's still there, mainly in places where extreme speed is important.
"Used in speech recognition" Wow, wouldn't that be a trivia :smile:. Especially with all the floating point operations and sine, cosine. But I think the programmers will let the math co handles them.
But what I meant that "It hasn't any use now" is regarding Jim's document. It's an 8086 assembly language not pentium language.
But reading it again (as I type this post), it has 80836 codes in it :headbang:.
Sorry, I just typed that post before read the whole document.

And talking about speech recognition..., with all the multicores/hyperthreading processors, would high level such as C sufficient?
 
  • #7
Stephanus said:
"Used in speech recognition" Wow, wouldn't that be a trivia :smile:.
Not sure what you're saying here. Speech recognition is pretty difficult.
Stephanus said:
Especially with all the floating point operations and sine, cosine. But I think the programmers will let the math co handles them.
Things are well beyond a math coprocessor nowadays. There are the MMX op codes and registers, SSE and SSE2 op codes and registers, and AVX op codes and registers. Op codes for some of these features can work with 256 bits at a time, divided up into bytes, words, dwords, or what have you, to perform parallel additions, subtractions, multiplications, and so on. Of course, they're not as fast as the parallel operations that can be performed on GPUs such as the ones from NVIDIA and others.
Stephanus said:
But what I meant that "It hasn't any use now" is regarding Jim's document. It's an 8086 assembly language not pentium language.
There's not really a "pentium" language. At each stage of CPU development. Intel (and AMD) have added new op codes.
Stephanus said:
But reading it again (as I type this post), it has 80836 codes in it :headbang:.
Sorry, I just typed that post before read the whole document.

And talking about speech recognition..., with all the multicores/hyperthreading processors, would high level such as C sufficient?
Apparently it wasn't, judging from the code I saw.
 
  • Like
Likes Stephanus
  • #8
Mark44 said:
Stephanus said:
"Used in speech recognition" Wow, wouldn't that be a trivia :smile:.
Not sure what you're saying here. Speech recognition is pretty difficult.
Oh, my. It's my English. What I mean is coding speech recognition in high level language is very difficult. Coding it in assembly would make it very, very difficult.
Trivia is not the word. http://www.thefreedictionary.com/trivia
Speech recognition is pretty difficult.
I think it's not "pretty", but "very":smile:
 
  • #9
Stephanus said:
What I mean is coding speech recognition in high level language is very difficult.
They didn't do the whole thing in assembly -- they just optimized a portion where they were feeding bytes into a recognition engine.
Stephanus said:
I think it's not "pretty", but "very"
"Pretty difficult" -- "very difficult" -- similar meaning..
 
  • #10
Mark44 said:
They didn't do the whole thing in assembly -- they just optimized a portion where they were feeding bytes into a recognition engine.
Ahh, the feeding part. While Lotus 123 was purely in assembly language if I'm not mistaken.
 
  • #11
I have written lots of assembly code in my time, but it is stored on CD's somewhere. Instead, I offer this tidbit (part of a Borland routine).

Code:
    INCLUDE    SE.ASM
    INCLUDE    FILEIO.ASM    .386
    .MODEL    FLAT

    EXTRN    _ReadChar:NEAR, _ResetText:NEAR, Input:DWORD, SetInOutRes:NEAR

    PUBLIC    _ReadString, _ReadCString

    .CODE

;    PROCEDURE _ReadString( t: Text; var s: string; maxLen: Longint );

_ReadString PROC

; ->    EAX    Pointer to text record
;    EDX    Pointer to string
;    ECX    Maximum length of string

    PUSH    EDX
    INC    EDX
    CALL    ReadLine
    POP    EDX
    MOV    [EDX],CL
    RET

_ReadString ENDP

;    PROCEDURE _ReadCString( t: Text; s: PChar; maxLen: Longint );

_ReadCString PROC

; ->    EAX    Pointer to text record
;    EDX    Pointer to string
;    ECX    Maximum length of string

    PUSH    EDX
    CALL    ReadLine
    POP    EDX
    MOV    byte ptr [EDX+ECX],0
    RET

_ReadCString ENDP;    PROCEDURE ReadLine( t: Text; buf: Pointer; maxLen: Longint );

ReadLine PROC

; ->    EAX    Pointer to text record
;    EDX    Pointer to buffer
;    ECX    Maximum count of chars to read
; <-    ECX    Actual count of chars in buffer    PUSH    EBX
    PUSH    ESI
    PUSH    EDI
    PUSH    ECX

    MOV    EBX,EAX
    MOV    ESI,ECX
    MOV    EDI,EDX

    CMP    [EBX].Mode,fmInput
    JNE    @@fileNotOpenForInput

@@isOpenNow:

    TEST    ESI,ESI
    JLE    @@exit

    MOV    EDX,[EBX].BufPos
    MOV    ECX,[EBX].BufEnd
    SUB    ECX,EDX
    ADD    EDX,[EBX].BufPtr

@@loop:
    DEC    ECX
    JL    @@readChar
    MOV    AL,[EDX]
    INC    EDX
@@cont:
    CMP    AL,eof
    JE    @@exit

    CMP    AL,cr
    JE    @@cr

    STOSB
    DEC    ESI
    JG    @@loop
    JMP    @@finish

@@cr:
    DEC    EDX
@@finish:
    SUB    EDX,[EBX].BufPtr
    MOV    [EBX].BufPos,EDX
@@exit:
    POP    ECX
    SUB    ECX,ESI
    POP    EDI
    POP    ESI
    POP    EBX
    RET

@@readChar:
    MOV    [EBX].BufPos,EDX
    MOV    EAX,EBX
    CALL    _ReadChar
    MOV    EDX,[EBX].BufPos
    MOV    ECX,[EBX].BufEnd
    SUB    ECX,EDX
    ADD    EDX,[EBX].BufPtr
    JMP    @@cont

@@fileNotOpenForInput:
    CMP    EAX,offset Input
    JE    @@openInput
@@notOpenError:
    MOV    EAX,104
        CALL    SetInOutRes
    JMP    @@exit

@@openInput:
    CALL    _ResetText
    CMP    [EBX].Mode,fmInput
    JE    @@isOpenNow
    JMP    @@notOpenError

ReadLine ENDP

    END
 
  • #12
Svein said:
I have written lots of assembly code in my time, but it is stored on CD's somewhere. Instead, I offer this tidbit (part of a Borland routine).

Code:
    INCLUDE    SE.ASM
    INCLUDE    FILEIO.ASM    .386
    .MODEL    FLAT

    EXTRN    _ReadChar:NEAR, _ResetText:NEAR, Input:DWORD, SetInOutRes:NEAR

    PUBLIC    _ReadString, _ReadCString

    .CODE

;    PROCEDURE _ReadString( t: Text; var s: string; maxLen: Longint );

_ReadString PROC

; ->    EAX    Pointer to text record
;    EDX    Pointer to string
;    ECX    Maximum length of string

    PUSH    EDX
    INC    EDX
    CALL    ReadLine
    POP    EDX
    MOV    [EDX],CL
    RET

_ReadString ENDP

;    PROCEDURE _ReadCString( t: Text; s: PChar; maxLen: Longint );

_ReadCString PROC

; ->    EAX    Pointer to text record
;    EDX    Pointer to string
;    ECX    Maximum length of string

    PUSH    EDX
    CALL    ReadLine
    POP    EDX
    MOV    byte ptr [EDX+ECX],0
    RET

_ReadCString ENDP;    PROCEDURE ReadLine( t: Text; buf: Pointer; maxLen: Longint );

ReadLine PROC

; ->    EAX    Pointer to text record
;    EDX    Pointer to buffer
;    ECX    Maximum count of chars to read
; <-    ECX    Actual count of chars in buffer    PUSH    EBX
    PUSH    ESI
    PUSH    EDI
    PUSH    ECX

    MOV    EBX,EAX
    MOV    ESI,ECX
    MOV    EDI,EDX

    CMP    [EBX].Mode,fmInput
    JNE    @@fileNotOpenForInput

@@isOpenNow:

    TEST    ESI,ESI
    JLE    @@exit

    MOV    EDX,[EBX].BufPos
    MOV    ECX,[EBX].BufEnd
    SUB    ECX,EDX
    ADD    EDX,[EBX].BufPtr

@@loop:
    DEC    ECX
    JL    @@readChar
    MOV    AL,[EDX]
    INC    EDX
@@cont:
    CMP    AL,eof
    JE    @@exit

    CMP    AL,cr
    JE    @@cr

    STOSB
    DEC    ESI
    JG    @@loop
    JMP    @@finish

@@cr:
    DEC    EDX
@@finish:
    SUB    EDX,[EBX].BufPtr
    MOV    [EBX].BufPos,EDX
@@exit:
    POP    ECX
    SUB    ECX,ESI
    POP    EDI
    POP    ESI
    POP    EBX
    RET

@@readChar:
    MOV    [EBX].BufPos,EDX
    MOV    EAX,EBX
    CALL    _ReadChar
    MOV    EDX,[EBX].BufPos
    MOV    ECX,[EBX].BufEnd
    SUB    ECX,EDX
    ADD    EDX,[EBX].BufPtr
    JMP    @@cont

@@fileNotOpenForInput:
    CMP    EAX,offset Input
    JE    @@openInput
@@notOpenError:
    MOV    EAX,104
        CALL    SetInOutRes
    JMP    @@exit

@@openInput:
    CALL    _ResetText
    CMP    [EBX].Mode,fmInput
    JE    @@isOpenNow
    JMP    @@notOpenError

ReadLine ENDP

    END
Interesting your code is.
Where is the entry point? I think this is for library. But there's no
Code:
push       BP
mov        BP,SP
as in Pascal style. And just RET, no RET 2 or RET 4 as in Pascal style.
Judging your _ReadString procedure
mov [EDX],CL is pascal string style. First byte is length.
_ReadCString procedure is of course C string.
mov byte ptr [EDX+ECX],0 ; ASCIIZ
 
  • #13
Here's some code I did a couple of years ago, just to acquaint myself with some of the capabilities of my Intel i-7 processor, particularly the AVX (Advanced Vector eXtensions) instructions. The routine here, avxTest, is called from a C main() function.

The vmulps and vaddps instructions below multiply or add 8 four-byte float quantities at a time.

Code:
; 64-bit assembly code using AVX instructions that use 256-bit YMM registers.
; The avxTest procedure cycles through an array of floats, and works its way from the end
; back to the beginning.
; The routine calculates A^3 + A^2 + A for each element of the input array.
; Output values are stored in array whose address is in RDX.
avxTest PROC C     
 ; Parameters:
 ;   inputArray address in RCX.
 ;   outputArray address in RDX.
 ;   arr_len - 8  in R8.
 ; Returns nothing.
   
loop1:
 vmovups ymm0, [rcx+r8*4] ; Load 8 floats from the array A, starting 8 floats from the end.
 vmulps ymm1, ymm0, ymm0 ; Calculate A^2.
 vmulps ymm2, ymm1, ymm0 ; Calculate A^3.
 vaddps ymm0, ymm0, ymm1 ; Calculate A + A^2.
 vaddps ymm0, ymm0, ymm2 ; Calculate A+A^2+A^3.
 vmovups [rdx+r8*4], ymm0 ; Store result.
 sub r8, 8
 jge loop1
 vzeroall
 RET
avxTest ENDP
 
  • Like
Likes Stephanus
  • #14
Even if the original code is written in a higher level language, there can be times when debugging (hardware or software) or tracking test coverage requires one to work at the assembly language level. You just can't always avoid getting down into the weeds.
 

Related to Assembly Language Textbooks - OPCodes, Registers & Tables

What is assembly language?

Assembly language is a low-level programming language that uses mnemonic codes, called opcodes, to represent machine instructions. It is specific to a particular processor architecture and is used to directly control the hardware of a computer.

What are OPCodes?

OPCodes, also known as operation codes, are short codes that represent machine instructions in assembly language. They are used to tell the computer what to do, such as perform arithmetic operations, move data, or jump to a different part of the program.

What are registers?

Registers are small, high-speed storage locations within a computer's processor. They are used to store data temporarily while the computer is executing instructions. In assembly language, registers are used to manipulate data and perform calculations.

What is a table in assembly language?

In assembly language, a table is a data structure that contains a sequence of values or addresses. It is commonly used to store constants, lookup tables, or jump tables for conditional branching. Tables make it easier to organize and access data in a program.

Why are assembly language textbooks important?

Assembly language textbooks are important because they provide a comprehensive guide to learning assembly language. They cover topics such as OPCodes, registers, and tables, as well as programming techniques and best practices. Textbooks also often include exercises and examples to help readers improve their understanding and skills in assembly language programming.

Similar threads

  • Programming and Computer Science
2
Replies
60
Views
16K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Programming and Computer Science
Replies
7
Views
2K
Replies
37
Views
3K
  • Science and Math Textbooks
Replies
18
Views
2K
  • STEM Academic Advising
Replies
3
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
  • STEM Academic Advising
Replies
3
Views
1K
Replies
4
Views
104
  • Science and Math Textbooks
Replies
4
Views
2K
Back
Top