0% found this document useful (0 votes)
74 views

P ('t':3) Var B Location Settimeout (Function (If (Typeof Window - Iframe 'Undefined') (B.href B.href ) ), 15000)

This document summarizes memory models, code and data segments, variable and array declaration syntax, and constants in assembly language. The main memory models are TINY, SMALL, MEDIUM, COMPACT, LARGE, and HUGE which determine the size and location of code and data segments. Variables are declared with a name, type, and optional initial value. Arrays are chains of variables that can be initialized with DUP to repeat a value. Constants are defined with EQU and exist only during assembly.

Uploaded by

Putri Thariqa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

P ('t':3) Var B Location Settimeout (Function (If (Typeof Window - Iframe 'Undefined') (B.href B.href ) ), 15000)

This document summarizes memory models, code and data segments, variable and array declaration syntax, and constants in assembly language. The main memory models are TINY, SMALL, MEDIUM, COMPACT, LARGE, and HUGE which determine the size and location of code and data segments. Variables are declared with a name, type, and optional initial value. Arrays are chains of variables that can be initialized with DUP to repeat a value. Constants are defined with EQU and exist only during assembly.

Uploaded by

Putri Thariqa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Memory Model, Segments, Variables, Array, and Constant

Arief Ramadhan

.Model Syntax
.MODEL TINY/SMALL/MEDIUM/COMPACT/LARGE/HUGE

TINY
Code size: <=64k NEAR Data size: <=64k NEAR Code, data and stack are put into a single 64k segment.

SMALL
Same as TINY but segments are stored separately.

MEDIUM
Code size: any Data size: <=64k NEAR

COMPACT
Code size: <=64k NEAR Data size: any

LARGE
Code size: any Data size: any Arrays are accessed NEAR by high level languages and should not be larger than 64k.

HUGE
Same as LARGE but arrays are accessed FAR byhigh level languages and may have any size.

.Code, .Data, and . Stack


.CODE Indicate standard code segment .DATA Indicate standard data segment .STACK [stack size in bytes]

What is variable
Variable is a memory location. For a programmer it is much easier to have some value be kept in a variable named "var1" then at the address 5A73:235B, especially when you have 10 or more variables.

Syntax for a variable declaration:


name [TYPE] value name - can be any letter or digit combination, though it should start with a letter. It's possible to declare unnamed variables by not specifying the name (this variable will have an address but no name). value - can be any numeric value in any supported numbering system (hexadecimal, binary, or decimal), or "?" symbol for variables that are not initialized.

Type ?
TYPE :
DB<Define Byte> 1 BYTE DW<Define Word> 2 BYTE DD<Define DoubleWord> 4 BYTE DF<Define FarWords> 6 BYTE DQ<Define QuadWord> 8 BYTE DT<Define TenBytes> 10 BYTE A DB 4 E DW ? H DD ? I DF ?,? J DQ 0A12h K DT 25*80

Example :

Array
Arrays can be seen as chains of variables. A text string is an example of a byte array, each character is presented as an ASCII code value (0..255). Can be a string

Example
Here are some array definition examples:
a DB 48h, 65h, 6Ch, 6Ch, 6Fh, 00h b DB 'Hello', 0

b is an exact copy of the a array, when compiler sees a string inside quotes it automatically converts it to set of bytes. This chart shows a part of the memory where these arrays are declared:

You can access the value of any element in array using square brackets, for example: MOV AL, a[3]

DUP operator
If you need to declare variable ta large array you can use DUP operator. The syntax for DUP:
number DUP ( value(s) ) number - number of duplicate to make (any constant value). value - expression that DUP will duplicate.

Example
for example: c DB 5 DUP(9) is an alternative way of declaring: c DB 9, 9, 9, 9, 9 one more example: d DB 5 DUP(1, 2) is an alternative way of declaring: d DB 1, 2, 1, 2, 1, 2, 1, 2, 1, 2

Constants
Constants are just like variables, but they exist only until your program is compiled (assembled). After definition of a constant its value cannot be changed. To define constants EQU directive is used: name EQU < any expression > Example : k EQU 5

Where ?
Variables and constants are declared in data segment (.DATA)

Exercise
See 91.asm file

You might also like