Download ibm pc assembly language - Ron Burkey`s Project Page
Transcript
IBM-PC ASSEMBLY-LANGUAGE LECTURE NOTES PAGE 47/361 executes in 128 clock cycles (about 26 microseconds) and uses 36 bytes of memory. Indeed, we can improve this slightly by using the "increment" and "decrement" instructions. These instructions have the form INC destination and DEC destination where the destination operand is a byte or word register or memory variable. INC adds one to the destination, while DEC subtracts one. Thus these instructions are functionally equivalent to ADD destination,1 and SUB destination,1 However, the increment and decrement instructions are actually smaller and execute more quickly. Thus, the following fragment is superior to both of the above: mov inc mov mov dec mov mov inc mov mov dec mov ax,my ; get MY into ax, ax ; increment it, play,ax ; and save it as PLAY. ax,name ; similarly for MISTY=NAME-1 ax misty,ax ax,is ; similarly for FOR=IS+1 ax for,ax ax,nobody ; similarly for ME=NOBODY-1 ax me,ax Actually, I was exagerating slightly when I stated that the increment and decrement instructions were functionally equivalent to the instructions that immediately subtract or add one. There is, in fact, one difference between (for example) ADD destination,1 and INC destination. This difference is the effect on the carry flag. We will discuss the so-called "flags" in the next section; for now, just think of the carry flag as a bit-sized register located somewhere in the CPU. As is happens, ADD and SUB instructions may modify the carry flag, but INC and DEC instructions do not. What is the carry flag used for? It can happen in integer addition that the result of an addition is too big for the destination address to hold. For example, if we have the word-values 8000H and 8001H stored in some word-sized source or destination the sum, 10001H, is 17 bits long and hence too large to store in the destination. It is easy to show that this in fact represents the worst possible case: that is, the result of a 16-bit CLASS 3