Download presentation
Presentation is loading. Please wait.
Published bySamson Gibson Modified over 9 years ago
1
Mid-term Exam Basics & intuitive All materials till-to-date – very simple! Ref. book – Assembly Language Programming and Organization of the IBM PC, by Y. Yu & C. Marut Written exam
2
Smile – though your heart is breaking! Enjoy with study!
3
4.7 Program Structure Machine lang progs consist of – Code – Data – Stack Each part occupies a memory segment
4
4.7.1 Mem Models.MODEL memory_model; directive Mem. Models – SMALL Code in 1 segment, data in 1 seg. – MEDIUM Code in 1+ seg, data in 1 seg – COMPACT… – LARGE…array in max. 64KB – HUGE
5
Data segment Contains all the variable definitions Const. definitions too in most cases [cost. defn – no memory is involved, so anywhere].DATAdirective.DATA HASINADW2 KHALEDADW5 ERSHADEQU10010001b ; named constants – equates
6
Stack segment To set a block of memory to store the stack.STACKsize ; max stack size ; size is optional no..STACK100H ; sets 100h Bytes for the stack area. ; if no size is mentioned – 1 KB is assigned
7
Code segment Contains a program’s instructions.CODE name ; name is optional ; NO need for name in SMALL program -Insides a code segment – instructions are organized as procedures.
8
A simple procedure name PROC ; body of the procedure nameENDP ; end procedure
9
Defn. of a CODE segment.CODE MAINPROC ; main procedure instructions MAINENDP ; other procedures go here
10
…together! A typical form for SMALL model.MODEL SMALL.STACK100h.DATA ;data definitions go here.CODE;SMALL – so no name MAINPROC ;instructions go here MAINENDP ;other instructions go here ENDMAIN
11
4.8 I/O Instructions Instructions to access I/O ports directly – – IN – OUT ; provides first I/O ; less used
12
2 types of I/O service routines – 1.BIOS [Basic I/O System] routines BIOS routines r stored in ROM, interact directly with the I/O ports see chap. 12. 2. DOS [Disk OS] routines can do more complex tasks
13
INT instruction To invoke a DOS or BIOS routine – INT [Interrupt] instruction is used. Interrupt A signal to a computer that stops the execution of a running program so that another action can be performed. INTint_no.
14
int_no. is a number that specifies a routine INT 16h invokes a BIOS routine that performs keyboard input – Chap. 15 for more INT21h invokes a large no. of DOS functions – Appendix C for more
15
INT 21h ( invokes no. of DOS functions ) A particular function is requested by placing a function no. in the AH register & invoke INT 21h Function No.Routine 1single-key input 2single-character output 9character string output
16
INT 21h functions expect input values to be in certain reg. & return output in other reg. Function 1: Single-key input Input: AH = 1 Output:AL = ASCII code if character key is pressed = 0 if non-character key is pressed
17
Function 2: Single-character output / control func. Input: AH = 2 DL= ASCII code of the display char or control char Output:AL = ASCII code of the display char or control char Function 2: Some control functions ASCIISymbolFunction 7BELbeep sound 8BSbackspace 9HTtab …
18
1 st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.