1 / 18

Mid-term Exam

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. Smile – though your heart is breaking! Enjoy with study!. 4.7 Program Structure.

abia
Download Presentation

Mid-term Exam

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 langprogs 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] .DATA directive .DATA HASINA DW 2 KHALEDA DW 5 ERSHAD EQU 10010001b ;named constants – equates

  6. Stack segment • To set a block of memory to store the stack .STACK size ; max stack size ; sizeis optional no. .STACK 100H ; 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 name ENDP; end procedure

  9. Defn. of a CODE segment .CODE MAIN PROC ; main procedure instructions MAIN ENDP ; other procedures go here

  10. …together! A typical form for SMALL model .MODEL SMALL .STACK 100h .DATA ;data definitions go here .CODE ;SMALL – so no name MAIN PROC ;instructions go here MAIN ENDP ;other instructions go here END MAIN

  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 – • 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. INT int_no.

  14. INT int_no. • int_no.  is a number that specifies a routine INT 16h  invokes a BIOS routine that performs keyboard input • Chap. 15 for more INT 21h  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 1 single-key input 2 single-character output 9 character 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 ASCII Symbol Function 7 BEL beep sound 8 BS backspace 9 HT tab …

  18. 1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line!

More Related