Introduction to Computer Organization and Assembly Language Sheet

Introduction to Computer Organization and Assembly Language Sheet 2

Question 1 Q 1: Tell whether each of the following instructions is legal or illegal. WD 1 and WD 2 are word variables, and BT 1 and BT 2 are byte variables.

Question 1 A. ADD WD 1, WD 2 Illegal memory location & memory location B. MOV AL, 0 AC 3 h Illegal out of range C. MOV DS, BX Legal D. ADD 03, AL Illegal the destination is a constant E. MOV AH, WD 2 Illegal operands are not of the same type F. MOV BT 1, BT 2 Illegal memory location & memory location G. MOV CS, SS Illegal segment register to segment register H. MOV DS, 100 h Illegal constant to segment register MOV WD 2, CS J. MOV BT 1, WD 1 Legal segment register to memory location I. Illegal memory location & memory location

Question 2 Q 2: Using only MOV, ADD, SUB, INC, DEC, and NEG, translate the following high-level language assignment statements into assembly language. A, B, and C are word variables.

Question 2 a. B = 3 * B + 2 MOV AX, B ADD AX, 2 MOV B, AX b. B = A + C MOV AX, A ADD AX, C MOV B, AX

Question 2 c. C = -(C + 1) INC C NEG C d. A = C – B MOV AX, C SUB AX, B MOV A, AX

Question 2 e. A = C - A – 1 MOV AX, C SUB AX, A DEC AX MOV A, AX

Question 3 �Q 3: Write assembly program that displays the following “This Program is to swap content of two memory locations”, and then define two variables (BYTE 1 and BYTE 2) of type byte and uninitialized, then write a transfer instruction that assign value ('A') in BYTE 1 and value (45 H) in BYTE 2, then try to swap the values.

Question 3

Question 3

Question 3
- Slides: 11