Presentation is loading. Please wait.

Presentation is loading. Please wait.

Azir ALIU 1 Library of common functions - emu8086 To make programming easier there are some common functions that can be included in your program To make.

Similar presentations


Presentation on theme: "Azir ALIU 1 Library of common functions - emu8086 To make programming easier there are some common functions that can be included in your program To make."— Presentation transcript:

1 Azir ALIU 1 Library of common functions - emu8086 To make programming easier there are some common functions that can be included in your program To make your program use functions defined in other file you should use the INCLUDE directive followed by a file name To use any of the functions in emu8086.inc you should have the following line in the beginning of your source file: include 'emu8086.inc'

2 Azir ALIU 2 emu8086.inc defines the following macros:  PUTC char - macro with 1 parameter, prints out an ASCII char at current cursor position  GOTOXY col, row - macro with 2 parameters, sets cursor position.  PRINT string - macro with 1 parameter, prints out a string.  PRINTN string - macro with 1 parameter, prints out a string.The same as PRINT but automatically adds "carriage return" at the end of the string.

3 Azir ALIU 3  CURSOROFF - turns off the text cursor  CURSORON - turns on the text cursor include emu8086.inc ORG 100h PRINT 'Hello World!' GOTOXY 10, 5 PUTC 65 ; 65 - is an ASCII code for 'A' PUTC 'B' RET ; return to operating system. END ; directive to stop the compiler.

4 Azir ALIU 4 ORG 100h MOV AX, 5 ; set AX to 5. MOV BX, 2 ; set BX to 2. JMP calc ; go to 'calc'. back: JMP stop ; go to 'stop'. calc: ADD AX, BX ; add BX to AX. JMP back ; go 'back'. stop: RET ; return to operating system. END ; directive to stop the compiler

5 Azir ALIU 5 Procedures Procedure is a part of code that can be called from your program in order to make some specific task. The syntax for procedure declaration: name PROC ; here goes the code ; of the procedure... RET name ENDP

6 Azir ALIU 6 name - is the procedure name RET instruction is used to return to operating system. The same instruction is used to return from procedure (actually operating system sees your program as a special procedure). PROC and ENDP are compiler directives, so they are not assembledintoany real machine code. Compiler just remembers the address of procedure. CALL instruction is used to call a procedure.

7 Azir ALIU 7 example: ORG 100h CALL m1 MOV AX, 2 RET ; return to operating system. m1 PROC MOV BX, 5 RET ; return to caller. m1 ENDP END

8 Azir ALIU 8 ORG 100h LEA SI, msg ; load address of msg to SI. CALL print_me RET ; return to operating system. print_me PROC next_char: CMP b.[SI], 0 ; check for zero to stop JE stop ; MOV AL, [SI] ; next get ASCII char. MOV AH, 0Eh ; teletype function number. INT 10h ; using interrupt to print a char in AL. ADD SI, 1 ; advance index of string array. JMP next_char ; go back, and type another char. stop: RET ; return to caller. print_me ENDP ; msg DB 'Hello World!', 0 ; null terminated string. END

9 Azir ALIU 9 Arithmetic and Logical Operators OperatorSyntaxDescription ++exprPositive(unary) --exprNegation +Expr+exprAddition -Expr-exprSubtraction *Expr*exprMultiplication /Expr/exprDivision MODExpr MOD exprModulo(remainder) [ ]Expr [expr]Addition(index operator)

10 Azir ALIU 10 OperatorSyntaxDescription SHRExpr SHR exprShift right SHLExpr SHL exprShift left NOTNOT exprLogical(bit by bit)NOT ANDExpr AND exprLogical AND ORExpr OR exprLogical OR XORExpr XOR exprLogical XOR Logical Operators

11 Azir ALIU 11 OperatorSyntaxDescription EQExpr EQ expr True (OFFh) if equal, false (0) otherwise NEExpr NE expr True (OFFh) if not equal, false (0) otherwise LTExpr LT expr True (OFFh) if less, false (0) otherwise LEExpr LE expr True (OFFh) if lesse or qual, false (0) otherwise GTExpr GT expr True (OFFh) if greater, false (0) otherwise GEExpr GE expr True (OFFh) if greater or equal, false (0) otherwise Relational Operators

12 Azir ALIU 12 ?


Download ppt "Azir ALIU 1 Library of common functions - emu8086 To make programming easier there are some common functions that can be included in your program To make."

Similar presentations


Ads by Google