More on operators and procedures in the Linked

Slides:



Advertisements
Similar presentations
DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
Advertisements

Introduction to Assembly Language
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
Irvine, Kip R. Assembly Language For Intel-Based Computers TYPE and SIZE Operators TYPE –returns the size, in bytes of a single element of a data label.
Important Irvine Library Procedures Randomize Randomize –Initializes the seed of the random-number formula by both the Random32 and the RandomRange procedures.
Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, All rights reserved. You may modify and.
Assembly Language for Intel-Based Computers Chapter 8: Advanced Procedures Kip R. Irvine.
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
Runtime Stack Managed by the CPU, using two registers
Outline Learning Assembly by an Example.  Program Formats  Some Simple Instructions  Assemble and Execute Learning Another Example  Data Definition.
CS2422 Assembly Language & System Programming October 3, 2006.
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
CS2422 Assembly Language and System Programming Procedures Department of Computer Science National Tsing Hua University.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy.
CS2422 Assembly Language & System Programming October 24, 2006.
Coding.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
CS2422 Assembly Language & System Programming September 26, 2006.
Sahar Mosleh California State University San MarcosPage 1 Applications of Shift and Rotate Instructions.
Dr. José M. Reyes Álamo 1.  The 80x86 memory addressing modes provide flexible access to memory, allowing you to easily access ◦ Variables ◦ Arrays ◦
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong
Today’s topics Parameter passing on the system stack Parameter passing on the system stack Register indirect and base-indexed addressing modes Register.
Assembly Language for x86 Processors 6th Edition Chapter 4: Data-Related Operators and Directives, Addressing Modes (c) Pearson Education, All rights.
Assembly Language for Intel-Based Computers, 6 th Edition Chapter 8: Advanced Procedures (c) Pearson Education, All rights reserved. You may.
Multiplication and Division Instructions & the 0Ah function.
Today's topics Multi-dimensional arrays Multi-dimensional arrays String processing String processing Macros Macros.
Assembly Language for Intel-Based Computers, 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy.
Today’s topics Procedures Procedures Passing values to/from procedures Passing values to/from procedures Saving registers Saving registers Documenting.
Sahar Mosleh California State University San MarcosPage 1 Nested Procedure calls and Flowcharts.
Binary Number Output To display a number in binary format, a program looks at each bit in the number and sends the ASCII equivalent of a ‘1’ (31h) or a.
Sahar Mosleh California State University San MarcosPage 1 Stack operations, Applications and defining procedures.
ASSEMBLY LANGUAGE FOR INTEL-BASED COMPUTERS, PROCEDURES.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
Computer Organization and Assembly Languages Yung-Yu Chuang 2006/11/13
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 10: Structures and Macros (c) Pearson Education, All rights reserved. You.
1 The Stack and Procedures Chapter 5. 2 A Process in Virtual Memory  This is how a process is placed into its virtual addressable space  The code is.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 5: Procedures Lecture 18 Linking to External Library The Book’s Link Library Stack Operations.
Assembly 09. Outline Strings in x86 esi, edi, ecx, eax stosb, stosw, stosd cld, std rep loop 1.
Arrays. Outline 1.(Introduction) Arrays An array is a contiguous block of list of data in memory. Each element of the list must be the same type and use.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
Addressing Modes Dr. Hadi Hassan.  Two Basic Questions  Where are the operands?  How memory addresses are computed?  Intel IA-32 supports 3 fundamental.
Lecture 15 Advanced Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
CSC 221 Computer Organization and Assembly Language
Stack Operations Dr. Hadi AL Saadi.
Assembly Language for x86 Processors 6th Edition
Chapter 5: Procedures.
Assembly Lab 3.
Segment Definition The CPU has several segment registers:
Additional Assembly Programming Concepts
Chapter 9.
Assembly Language Lab (4).
High-Level Language Interface
9/17/2018 Kiến Trúc Máy Tính.
Assembly Language for Intel-Based Computers, 5th Edition
Data-Related Operators and Directives
Stack Frames and Advanced Procedures
تهیه و تنظیم: فاطمه قاسمی دانشگاه صنعتی شریف – پاییز 86
Libraries and Procedures
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
Assembly Language for Intel-Based Computers, 4th Edition
Two ways to discuss color 1) Addition 2) Subtraction
Week 2: Buffer Overflow Part 1.
The Stack and Procedures
What Color is it?.
By Nasser Halasa Assembly Language.
Computer Organization and Assembly Language
Hardware & Software Architecture
MUL operation.
Computer Architecture and System Programming Laboratory
Presentation transcript:

More on operators and procedures in the Linked Library

Pointers A variable that contains the address of another variable is called a pointer variable. Pointers are essential when manipulating arrays and data structures. Intel- based programs use basic type of pointers, Near and Far pointers. With the protected mode in this course we use near pointers, so they are stored in double word variables.

Example: ArrayB Byte 10h, 20h, 30h, 40h ArrayDW Dword 1000,2000,3000,4000 The pointers to the above arrays can be define as: ptrB Dword ArrayB PtrDW Dword ArrayDW

Example: TITLE pointers Include Irvine32.inc .data arrayB Byte 10h,20h,30h arrayD Dword 4,5,6 Ptr1 Dword arrayB ;pointer to arrayB Ptr2 Dword arrayD ;pointer to arrayD .code main proc mov esi, ptr1 ;move the address (pointer to arrayB) to esi mov ebx, [esi] mov esi, ptr2 ;move the address (pointer to arrayD) to esi mov eax,[esi] Exit Main ENDP END main

ReadString Procedure ReadString procedure reads a string input, stopping when the user press the enter key. It returns a count of the number of bytes read in the EAX register. Before calling read string, set EDX to the offset to an array of bytes where input characters will be stored, and set ECX ( loop counter) to the maximum number of characters to read. In The next example, the segment calls ReadString, passing ECX and EDX. Notice that we subtract 1 from the buffer size to save a byte at the end of the string for the null terminator

.data Buffer Byte 50 DUP(0) ;holds the characters byteCount Dword ? ;holds counter for loop .code mov edx, offset buffer ;points to the buffer mov ecx, (sizeof buffer)-1 ;specify max characters call ReadString ;input the string mov bytecount, eax

SetTextColor The SetTextColor procedure sets the current foreground and background colors for text output. The following color constants are predefined and can be used for both the foreground and background. Black = 0 Red=4 Gray=8 lightRed=12 Blue=1 Magenta=5 lightBlue=9 lightMagenta=13 Green=2 Brown=6 lightGreen=10 Yellow=14 Cyan=3 Lightgray=7 Lightcyan=11 White=15

These color constants are defined in Irvine32.inc. The background color must be multiplied by 16 before being added to the foreground color. The following example, defines yellow characters on a blue background Yellow + (blue * 16) Before calling SetTextColor, move the desired color to EAX Mov eax, white + (blue*16) Call setTextColor