130 likes | 225 Views
Introduction to Computer Organization and Assembly Language . Sheet 1. Program Comment . A semicolon marks the beginning of this field, and the assembler ignores anything typed after the semicolon . Example: MOV CX, 0 ; CX counts terms, initially 0. Identifiers.
E N D
Introduction to Computer Organization and Assembly Language Sheet 1
Program Comment • A semicolon marks the beginning of this field, and the assembler ignores anything typed after the semicolon. • Example: • MOV CX, 0 ; CX counts terms, initially 0
Identifiers • Can be from 1 to 31 characters long (not case sensitive). • May consist of letters, digits, and the special characters. • ? . @ _ $ % (Thus, embedded blanks are not allowed). • Names may not begin with a digit. • If a dot is used, it must be the first character.
Defining Types of data • Syntax: • name Dninitial_value
Defining Types of data Cont. • Dn (Directive):
Question1 Q1: Tell whether each of the following identifiers is Valid or Invalid.
Question2 Q2: Give data definition pseudo-ops to define each of the following: a) A word variable X initialized to 41. X DW 41
Question2 Cont. Q2: Give data definition pseudo-ops to define each of the following: b) A word variable WORD1, uninitialized. WORD1DW ?
Question2 Cont. Q2: Give data definition pseudo-ops to define each of the following: c) A byte variable Y initialized to 32h. Y DB 32H
Question2 Cont. Q2: Give data definition pseudo-ops to define each of the following: d) A byte variable ITEM containing the hex equivalent to decimal 71. ITEM DB 47H
Question2 Cont. Q2: Give data definition pseudo-ops to define each of the following: e) A word array ARRAY1, initialized to the first 5 positive integers (i.e. 1-5). ARRAY1 DW 1,2,3,4,5
Question2 Cont. Q2: Give data definition pseudo-ops to define each of the following: f) A 30 bytes array ARR, with each entry initialized to 10H. ARR DB 30 DUP (10H)
Question2 Cont. Q2: Give data definition pseudo-ops to define each of the following: g) A constant LENGTH with value 20, another constant WIDTH with value 10, and constant AREA using LENGTH and WIDTH that you just defined (Note: area = length * width). LENGTH EQU 20 WIDTH EQU 10 AREA EQU length * width