Data Types in Assembly
Data Types in Assembly: BYTE, WORD and DWORD
In this lab, student will know about the almost each and every data types assembly language support and their compatibility with high level programming languages.
Prior to the arrival of MASM, most assemblers provided very little capability for declaring and allocated complex data types. Generally, you could allocate bytes, words, and other primitive machine structures. You could also set aside a block of bytes. As high level languages improved their ability to declare and use abstract data types, assembly language fell farther and farther behind. Then MASM came along and changed all that. Unfortunately, many long time assembly language programmers haven’t bothered to learn the new MASM syntax for things like arrays, structures, and other data types. Likewise, many new assembly language programmers don’t bother learning and using these data typing facilities because they’re already overwhelmed by assembly language and want to minimize the number of things they’ve got to learn. This is really a shame because MASM data typing is one of the biggest improvements to assembly language since using mnemonics rather than binary opcodes for machine level programming.
This lab teaches you the following topics:
- Understand data types in Assembly
- Storage considerations for each type
- Declaration of Integers, real, characters, strings, and arrays
- Various operators
- Data movement instructions
As pre-lab activity, read Chapter 3 from the book (Assembly Language for X86 processors, KIP
- IRVINE., 7th Edition (2015), Pearson), and also as given by your theory instructor.
MASM deﬁnes intrinsic data types, each of which describes a set of values that can be assigned to variables and expressions of the given type. The essential characteristic of each type is its size in bits: 8, 16, 32, 48, 64, and 80. Other characteristics (such as signed, pointer, or ﬂoating-point) are optional and are mainly for the beneﬁt of programmers who want to be reminded about the type of data held in the variable. A variable declared as DWORD, for example, logically holds an unsigned 32-bit integer. In fact, it could hold a signed 32-bit integer, a 32-bit single precision real, or a 32-bit pointer. The assembler is not case sensitive, so a directive such as DWORD can be written as dword, Dword, dWord, and so on.
Write a program that contains a definition of each data type listed in Table given below. Initialize each variable to a value that is consistent with its data type.
|BYTE||8-bit unsigned integer. B stands for byte|
|SBYTE||8-bit signed integer. S stands for signed|
|WORD||16-bit unsigned integer|
|SWORD||16-bit signed integer|
|DWORD||32-bit unsigned integer -D stands for double|
|SDWORD||32-bit signed integer. SD stands for signed|
|QWORD||64-bit integer. Q stands for quad|
|TBYTE||80-bit (10-byte) integer. T stands for Ten-byte|
|REAL4||32-bit (4-byte) IEEE short real|
|REAL8||64-bit (8-byte) IEEE long real|
|REAL10||80-bit (10-byte) IEEE extended real|
var1 BYTE 10h var2 SBYTE -14
var3 WORD 2000h var4 SWORD +2345
var5 DWORD 12345678h var6 SDWORD -2342423
var7 FWORD 0
var8 QWORD 1234567812345678h var9 TBYTE 1000000000123456789Ah var10 REAL4 -1.25
var11 REAL8 3.2E+100
var12 REAL10 -6.223424E-2343
exit main ENDP END main
Write a program that defines symbolic constants for all of the days of the week. Create an array variable that uses the symbols as initializes.
Sunday = 0
Monday = 1
Tuesday = 2
Wednesday = 3
Thursday = 4
Friday = 5
Saturday = 6
myDays BYTE Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
exit main ENDP END main
Write a program that defines symbolic names for several string literals (characters between quotes). Use each symbolic name in a variable definition.
sym1 TEXTEQU <“System failure”>
sym2 TEXTEQU <“Press any key to continue…”> sym3 TEXTEQU <“Insufficient user training”> sym4 TEXTEQU <“Please re-start the system”>
msg1 BYTE sym1 msg2 BYTE sym2 msg3 BYTE sym3 msg4 BYTE sym4
exit main ENDP END main
Home Task 1:
Define the following data in Assembly
Sort BYTE ’y’ ; ASCII of y = 79H
value WORD 25159 ; 25159D = 6247H total DWORD 542803535 ; 542803535D = 205A864FH
|marks||DWORD||0, 0, 0, 0, 0, 0, 0, 0|
|value1||BYTE ‘A’||; character constant|
|value2||BYTE 0||; smallest unsigned byte|
|value3||BYTE 255||; largest unsigned byte|
|value4||SBYTE -128||; smallest signed byte|
|value5||SBYTE +127||; largest signed byte|
|value6||BYTE ?||; uninitialized byte|
Home Task 2:
Create the following menu by declaring a string in Assembly Language.
- Create a new account.
- Open an existing account
- Credit the account
- Debit the account
Home Task 3:
Create the following arrays in Assembly Language.
- Array of ten
- Array of 100
- Arrays of 4×3 integers
- Array of 4x3x2
Home Task 4:
Implement each of the following declarations in assembly language:
- char initial;
- char grade = ‘B’;
- char x = ‘P’, y = ‘Q’;
- int amount;
- int count = 0;
- int number = -396;