Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Assembly language

  1. Sep 29, 2016 #1
    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
     
  2. jcsd
  3. Sep 29, 2016 #2

    jim mcnamara

    User Avatar

    Staff: Mentor

  4. Sep 30, 2016 #3

    chiro

    User Avatar
    Science Advisor

    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".
     
  5. Sep 30, 2016 #4
  6. Oct 2, 2016 #5

    Mark44

    Staff: Mentor

    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.
     
  7. Oct 3, 2016 #6
    "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?
     
  8. Oct 3, 2016 #7

    Mark44

    Staff: Mentor

    Not sure what you're saying here. Speech recognition is pretty difficult.
    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.
    There's not really a "pentium" language. At each stage of CPU development. Intel (and AMD) have added new op codes.
    Apparently it wasn't, judging from the code I saw.
     
  9. Oct 3, 2016 #8
    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
    I think it's not "pretty", but "very":smile:
     
  10. Oct 3, 2016 #9

    Mark44

    Staff: Mentor

    They didn't do the whole thing in assembly -- they just optimized a portion where they were feeding bytes into a recognition engine.
    "Pretty difficult" -- "very difficult" -- similar meaning..
     
  11. Oct 3, 2016 #10
    Ahh, the feeding part. While Lotus 123 was purely in assembly language if I'm not mistaken.
     
  12. Oct 3, 2016 #11

    Svein

    User Avatar
    Science Advisor

    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 (Text):

        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
     
     
  13. Oct 3, 2016 #12
    Interesting your code is.
    Where is the entry point? I think this is for library. But there's no
    Code (Text):
    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
     
  14. Oct 3, 2016 #13

    Mark44

    Staff: Mentor

    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 (Text):
    ; 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
     
  15. Oct 4, 2016 #14

    FactChecker

    User Avatar
    Science Advisor
    Gold Member

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Assembly language
  1. Assembly language (Replies: 5)

  2. Assembly language or C (Replies: 5)

  3. New to assembly language (Replies: 12)

Loading...