110 likes | 203 Views
Introduction to Computer Organization and Assembly Language . Sheet 2. Question 1. Q1 : Tell whether each of the following instructions is legal or illegal.WD1 and WD2 are word variables, and BT1 and BT2 are byte variables. Question 1. ADD WD1,WD2 MOV AL,0AC3h MOV DS,BX ADD 03,AL
E N D
Introduction to Computer Organization and Assembly Language Sheet 2
Question1 Q1: Tell whether each of the following instructions is legal or illegal.WD1 and WD2 are word variables, and BT1 and BT2 are byte variables.
Question1 • ADD WD1,WD2 • MOV AL,0AC3h • MOV DS,BX • ADD 03,AL • MOV AH,WD2 • MOV BT1,BT2 • MOV CS,SS • MOV DS,100h • MOV WD2,CS • MOV BT1,WD1 Illegal memory location & memory location Illegal out of range Legal Illegal the destination is a constant Illegal operands are not of the same type Illegal memory location & memory location Illegal segment register to segment register Illegal constant to segment register Legal segment register to memory location Illegal memory location & memory location
Question2 Q2: 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.
Question2 a. B = 3 * B + 2 MOV AX,B ADD AX,B ADD AX,B ADD AX,2 MOV B,AX b. B = A + C MOV AX,A ADD AX,C MOV B,AX
Question2 c. C = -(C + 1) INC C NEG C • d. A = C – B MOV AX,C SUB AX,B MOV A,AX
Question2 e. A = C - A – 1 MOV AX,C SUB AX,A DEC AX MOV A,AX
Question3 • Q3: Write assembly program that displays the following “This Program is to swap content of two memory locations”, and then define two variables (BYTE1 and BYTE2) of type byte and uninitialized, then write a transfer instruction that assign value ('A') in BYTE1 and value (45H) in BYTE2, then try to swap the values.