More String Copying

Another way of copying a string different from what we did in class:

.data
  src  BYTE "abcdef",0
  dest BYTE SIZEOF src DUP(0)
.code
    mov edi,0
    mov ecx, SIZEOF src

l1: mov al, src[edi]
      mov dest[edi],al
      inc edi
    loop l1
Two final instructions in Chapter 4 are:

(i12) NEG operand - takes the two's complement of the operand where operand can be a reg or mem.

Note: The ADD, SUB, and NEG instructions change the Carry, Zero, Sign, Overflow, and Parity flags.

Problem: Consider the following assembly language program segment:

.data
x BYTE 1
y BYTE 10
.code
  neg x
  mov al, 0
  sub al,y
a) What is the value in x, y, and al after the program has executed?

b) What are the values of the Carry, Zero, Sign, Overflow, and Parity flags after neg, mov, and sub instructions are executed?

(i13) JUMP label - unconditional transfer to a target called label inside of the code segment.

top:
     ....
     jmp top
The above program segment will produce an infinite loop which makes the jmp instruction kind of useless at this point in time!!!


©Douglas J. Ryan / ryandj@pacificu.edu