Docsity

Computer Organisation - Assembly Programming, Study notes of Computer Architecture and Organization

Partial preview of the text

Download Computer Organisation - Assembly Programming and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Assembly programming

using 8086 instruction set

Assembly program

  • (^) Series of statements which are either assembly language instructions or directives. ▫ Instructions are statements like ADD AX,BX which are translated into machine code. ▫ Directives or pseudo-instructions are statements used by the programmer to direct the assembler on how to proceed in the assembly process like ORG.

Typical template

Org 100 Mov ax,data Inc ax Mov bx,data ; ……sequence of assembly Instructions Ret ; ……data variables Data1 dw ff Data2 dw ff

Data types

▫Db for one byte data  (^) Syntax --- VarName db value ▫Dw for two byte  (^) Syntax --- VarName dw value ▫Constants  (^) Syntax --- varname EQU 100 ▫Array  (^) Vector db 1,2,3,4,  (^) Str db “this is a string” ▫Suffixes  (^) H/h-hexa, O/o-octal, B/b binary

Immediate mode

  • (^) The operand is part of the instruction.
  • (^) Useful in initializations.
  • (^) MOV AX,1111000B
  • (^) MOV CL, 0F1H

Register mode

  • (^) Operand is contained in one of the eight general purpose registers
  • (^) Most compact and fastest executing instructions.
  • (^) Operands are encoded in the instruction.
  • (^) MOV BX,DX
  • (^) MOV AL,CL

Memory – indirect mode

  • (^) Memory address of the operand is contained in one of the eight general purpose register
  • (^) MOV AX, DS:[BX]
  • (^) MOV DS:[DI],DX

Interrupt instruction

  • (^) Called for performing I/O and for calling OS routine
  • (^) In response to an <INT > instruction a Interrupt service routine(ISR) is called
  • (^) INT instruction generates a software interrupt
  • (^) Parameter required for ISR are supplied through registers, usually a sub function is specified by setting a

Common interrupts

  • (^) BIOS Interrupts ▫10h – Video services ▫16h – keyboard services
  • (^) DOS interrupts ▫21h

BIOS Interrupt 10h

  • (^) Option 2H – Sets the cursor to a specific location.
  • (^) Registers used: ▫ AH = 2H ▫ BH = 0H selects Page 0. ▫ DH = Row position. ▫ DL = Column position.
  • (^) Ex: ▫ MOV AH, ▫ MOV BH, ▫ MOV DH, ▫ MOV DL, ▫ INT 10H

BIOS Interrupt 16h

  • (^) Option 0H – read a character from keyboard , wait till key is pressed. Return read key ascii code in AL and scan code in AH
  • (^) Registers used: ▫ AH = 0H
  • (^) Ex: ▫ MOV AH, ▫ INT 16H

DOS 21h interrupt

  • (^) Option 1 – Inputs a single character from keyboard and echoes it to the monitor.
  • (^) Registers used: ▫ AH = 1 ▫ AL = the character inputted from keyboard.
  • (^) Ex: ▫ MOV AH, ▫ INT 21H

DOS 21h Interrupt

  • (^) Option 4CH – Terminates a process, by returning control to a parent process or to DOS.
  • (^) Registers used: ▫ AH = 4CH ▫ AL = binary return code.
  • (^) Ex: ▫ MOV AH,4CH ▫ INT 21H

Branching Instructions

  • (^) JMP-Unconditional Jump
  • (^) JA, JAE,JB, JBE, JE, JZ, JE
  • (^) JNA, JNAE,JNB, JNBE, JNE, JNZ, JNE