October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.

Slides:



Advertisements
Similar presentations
Practical Malware Analysis
Advertisements

Machine Instructions Operations
INSTRUCTION SET ARCHITECTURES
Instruction Set Architecture
Intel Computer Architecture Presented By Jessica Graziano.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Computer Organization & Assembly Language
Assembly Language :CSC 225 (Lec#4: Flag Register and Conditional Statements) By Dr. Syed Noman.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
TK 2633 Microprocessor & Interfacing
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Memory - Registers Instruction Sets
Flow Control Instructions
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Microcomputer & Interfacing Lecture 3
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
Programming Models CT213 – Computing Systems Organization.
Ch. 7 Logic, Shift and Rotate instr.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
Machine Instruction Characteristics
Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#5) By Dr. Syed Noman.
CET 3510 Microcomputer Systems Tech. Lecture 2 Professor: Dr. José M. Reyes Álamo.
Arithmetic Flags and Instructions
Computer Architecture and Organization
1 ICS 51 Introductory Computer Organization Fall 2009.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
1 Logic, Shift, and Rotate Instructions Read Sections 6.2, 7.2 and 7.3 of textbook.
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.
EEL 3801 Part V Conditional Processing. This section explains how to implement conditional processing in Assembly Language for the 8086/8088 processors.
LEA instruction The LEA instruction can be used to get the offset address of a variable Example ORG 100h MOV AL, VAR1 ; check value of VAR1 by moving it.
What is a program? A sequence of steps
COMP 2003: Assembly Language and Digital Logic Chapter 2: Flags and Instructions Notes by Neil Dickson.
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
Chapter 7 Bit Manipulation. 7.1 Logical Operations.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Assembly Language Wei Gao. Assembler language Instructions.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
F453 Module 8: Low Level Languages 8.2: Features of Low-Level Languages.
Computer Architecture and Assembly Language
Computer Architecture CST 250
Data Transfers, Addressing, and Arithmetic
Aaron Miller David Cohen Spring 2011
Morgan Kaufmann Publishers Computer Organization and Assembly Language
INSTRUCTION SET.
Assembly Language Programming Part 2
Overview Introduction General Register Organization Stack Organization
(The Stack and Procedures)
CS 301 Fall 2002 Assembly Instructions
BIC 10503: COMPUTER ARCHITECTURE
Fundamentals of Computer Organisation & Architecture
Chapter 8 Central Processing Unit
(The Stack and Procedures)
Shift & Rotate Instructions)
Homework Reading Machine Projects Labs PAL, pp
Shift & Rotate Instructions)
Morgan Kaufmann Publishers Computer Organization and Assembly Language
X86 Assembly Review.
CNET 315 Microprocessor & Assembly Language
(The Stack and Procedures)
Chapter 8: Instruction Set 8086 CPU Architecture
Computer Operation 6/22/2019.
Presentation transcript:

October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003

October 1, 2003Serguei A. Mokhov, 2 Contents Flags Mnemonics Basic I/O Exercises Overview of sample programs

October 1, 2003Serguei A. Mokhov, 3 Flag Register The flag register stores the condition flags that retain useful information of the past computation, especially as a consequence of the previous arithmetic operation. The following flags are noteworthy: –OOverflow –SSign –ZZero –PParity (=1 if the number of 1’s in the result is odd) –CCarry (= carry-out from most significant bit) –IInterrupt (= 1 means interrupts are enabled; important in I/O programming, a future topic) Flags are necessary to implement conditional jumps. Recall the following from computer arithmetic: – = 0100O = 1; Z = 0; S = 0; P = 1; C = 1

October 1, 2003Serguei A. Mokhov, 4 Flags A flag is a bit (0 or 1) in the flags register, a 16-bit register in the CPU. There are nine flags: three control flags and six status flags. The remaining seven bits of the flags register are unused. The three control flags are set (set means changes to 1) or reset (also called cleared, which means changes to 0) by instructions in the program O D I T S Z - A - P - C Bit position 16-bit register Flags

October 1, 2003Serguei A. Mokhov, 5 Category Bit # FlagNameDescription Control DITDIT Direction Interrupt Trap 1 : blocks in memory copied from high address to low. 0 : blocks in memory copied from low address to high. 1 : hardware interrupts are allowed. 0 : hardware interrupts are not allowed. 1 : program halts after each instruction. 0 : program dos not halts after each instruction. Status COSZAPCOSZAP Carry Overflow Sign Zero Auxiliary carry Parity 1 : when result of an unsigned arithmetic operation is too large. 1 : when result of a signed arithmetic operation is too large. 1 : when result of an arithmetic or logical operation is negative. 1 : when result of an arithmetic or logical operation is zero. 1 : when result of an operation causes a carry from bit 3 to bit 4. 1 : when result of an operation contains even number of 1-bits.

October 1, 2003Serguei A. Mokhov, 6 Compare Instruction dest-source UnsignedSigned CZZS,O <0 (dest<source)10?!= =0 (dest=source)011? >0 (dest>source)000=

October 1, 2003Serguei A. Mokhov, 7 Mnemonics We will learn only a subset of the opcodes available. If you are interested, you could read about the rest. Usually, in a current generation machine, the size of the instruction set can grow to several hundred instructions. [What is the advantage of a large instruction set? Disadvantage?]

October 1, 2003Serguei A. Mokhov, 8 MnemonicsMeaning add addition of two integers sub subtraction between two integers mul multiply two integers div divide one integer by another mov copy from source to destination inc increment operand by 1 dec decrement operand by 1 cmp compare two operands by sub and and of two operands or or of two operands xor xor of two operands ror or rol rotate shift right or left shr or shl logical shift right or left jmp jump to a different instruction loop repeat loop with cx as counter MnemonicsMeaning je jump if equal jz jump if zero jg jump if greater than jge jump if greater than or equal jl jump if less than jle jump if less than or equal jne jump if not equal jo jump if overflow push push operand onto stack pop pop operand from stack call jump to subroutine ret return from subroutine Few Mnemonics

October 1, 2003Serguei A. Mokhov, 9 Basic I/O We will make our lives easier by using some I/O functions supported by the OS. These I/O functions are software traps (interrupts) whose invocation causes a transfer of control to the corresponding OS (software) interrupt handler. These handlers can be considered as special subroutines that will be invoked whenever the int (software interrupt) instruction is executed. In Linux, int 0x80 the specific interrupt that we will use. (In DOS, it is int 21h). Parameters are passed from our program through registers from your program to the OS subroutine with a well-defined interface specification.

October 1, 2003Serguei A. Mokhov, 10 Output EAX = 4; 4 is a system call for Output EBX = 1; the device, screen, or STDOUT ECX = addr; starting address of the stuff to output; like a pointer to a buffer; char* EDX = length of the buffer Example: hello.asm

October 1, 2003Serguei A. Mokhov, 11 Input EAX = 3; EBX = 0; Standard input or keyboard; STDIN ECX = addr; address of the destination buffer EDX = max # of bytes to enter After int, EDX will have the length of the data actually read in bytes

October 1, 2003Serguei A. Mokhov, 12 Program Termination EAX = 1 EBX = exit code; EBX = 0 means successful termination to the calling program.

October 1, 2003Serguei A. Mokhov, 13 System Call Interface A topic of the System Software and OS courses. The goal is to abstract programmer from knowing hardware details when doing I/O. Input is similar to read() system call in C Output to write() Termination to exit() Whenever a system call is executed, it traps to kernel to carry out the requested operation on behalf of the user program using appropriate device driver.

October 1, 2003Serguei A. Mokhov, 14 Exercises Give an instruction that involves moving the content of some memory location to another memory location. –mov al, [mem_loc1] –mov [mem_loc2], al

October 1, 2003Serguei A. Mokhov, 15 Exercises (2) Write a program that moves 100 bytes from memory location input_buf to memory location output_buf. See movbytes.asm

October 1, 2003Serguei A. Mokhov, 16 Exercises (3) Give a assembly language ‘instruction’ that does not correspond to a machine language instruction. –mov [output_buf], [input_buf]

October 1, 2003Serguei A. Mokhov, 17 Exercises (4) Write a program that accepts 25 characters from the keyboard and buffer them in memory location input_buf. Afterwards, the characters are printed. See printchars.asm.