Assembly language with 8086 exercise 1 PDF

Title Assembly language with 8086 exercise 1
Author hitler kareem
Course Bsc. Electrical and Electronic engineering
Institution Jomo Kenyatta University of Agriculture and Technology
Pages 2
File Size 163.9 KB
File Type PDF
Total Downloads 19
Total Views 149

Summary

an assembly language to output a string on the screeen...


Description

ELECTRICAL AND ELECTRONIC ENGINEERING SAMPLE PROGRAM  

Directives are statements that give directions to the assembler about how it should translate the assembly language instructions into machine code. Directives are used by the assembler to organize the program as well as other output files. Examples are SEGMENT, DB (allocation of memory in bytes), DW (2 bytes allocation at a time), DD (2 words allocation at a time), DQ (4 words), DT (10 bytes of memory space), ENDS, ASSUME, END, and ENDP

An assembly language instruction consists of four fields,

A tab makes the program listing neat and easy to debug. Include comments in your program for documentation and passing information. 

Brackets indicate that the field is optional. Brackets are not typed.

1. The label field allows the program to refer to a line of code by name. 2. In a line of assembly language program there can be mnemonic (instruction) and operand(s). Separate operands by a comma (,).

;****************8086 Assembly Language Program******************** ;Exercise 1: ;This is the first 8086 Assembly language program ; Confirm the segment initialization and usage .MODEL SMALL ;Specifies the memory model the program will use ;in the simplified segment definition. In this case ;64Kb for code and 64Kb of data memory is reserved. .STACK ;Allocate stack. Need to be initialized .CODE ;A directive to start code segment. START: ;Generally a good name to use for entry point ;or MAIN: Also used by some programmers. JMP BEGIN ;jump to label BEGIN welcome DB "Hello Namibia! This is the message.$" ; Terminating a string

BEGIN: ;code starts here mov dx, OFFSET welcome ;puts the offset of message in DX mov ax, SEG welcome ;puts the segment that the message is in AX mov ds, ax ;copy ax to ds mov ah, 9 ;move 9 into ah to call function 9 of interrupt int 21h ;21h responds to displaying a string to the screen. mov ax,4c00h ;move value 4c00 hex into AX. Int 21h ;call interrupt 21h, subroutine 4c which returns ; controls to DOS, otherwise it would crash. 00h is an ;error level returned to DOS. END START ;end here

The following Memory Models can be used: 1. • SMALL MODEL (.MODEL SMALL): The model uses maximum of 64K bytes for Code and 2. 64K bytes for Data (Code64K). 10. • HUGE MODEL, (.MODEL HUGE): Both Code and Data can exceed 64K bytes. Additionally, 11. a single data set (i.e. array) can exceed 64K bytes (Code>64K and Data >64K)....


Similar Free PDFs