Low / High Level Languages
Programs written in machine code or assembly language are said to be low-level. Machine code is also called First-Generation Programming Assembly language are called Second. Generation.
Low Level Give some examples of Low Level Languages What are the advantages & disadvantages of Low Level Language?
Low Level Languages Advantages Allows user to address computer memory/addresses directly. User Learns how the computer work. Disadvantages Many lines of code for a simple program More difficult to locate errors and modify the code. Instructions are machine specific/dependent
High Level Languages The development of procedural languages are called third-generation Languages.
High Level Languages Name the High Level Language What are the advantages and disadvantages of High Level Languages?
High Level Language Advantage: Close to english language and therefore easier to write and understand They are portable They are easier to debug and modify Disadvantage Need to be compiled or interpreted before it can be run on computer this can be a slow process.
Standard Assembler Directives. model - Specify the program’s memory model. stack - Set the size of the stack segment (eg. 100 h). data - Mark the beginning of the data segment MSG 1 DB 10, 13, 'Hello, world! $‘. code - Mark the beginning of the code segment Proc -Begin procedure Endp- End of Procedure End – End of Program Assembly
Assembly Skeletal Code ; This is skeletal code. model small. stack 100 h. data. . code main proc ; initialize DS MOV AX, @DATA MOV DS, AX main endp end main
Assembly Tools needed to compile assembly language in 64 Bit OS Install Dosbox Install MASM/NASM/TASM Assembler Linker
Compilation The following three files are created to generate an assembly language.
Basic Instruction Set MOV - The MOV (move data) instruction copies data from one operand to another, so it is called a data transfer instruction. first operand – Target and second Operand – Source MOV reg, reg Eg. mov al, bl ; 8–bit register to register MOV mem, reg Eg. mov count, bl ; 8–bit memory to register MOV reg, mem Eg. mov bl, count ; 8–bit memory to register MOV mem, immed mov count, 26 ; 8–bit immediate to memory MOV reg, immed mov bl, 1 ; 8–bit immediate to register
INC and DEC Instructions The INC (increment) and DEC (decrement) instructions add 1 or subtract 1 from a single operand, respectively. INC destination Eg. , inc al ; increment 8 -bit register inc count ; increment memory operand DEC destination Eg. , dec al; decrement 8 bit register dec count ; decrement memory operand
ADD Instruction The ADD instruction adds a source operand to a destination operand of the same size. ADD destination, source Eg. add cl, al ; add 8 -bit register to register add var 1, 10 ; add immediate value to memory add dx, var 1 ; add 16 -bit memory to register add bx, 1000 h ; add immediate value to 16 bit register
SUB Instruction The SUB instruction subtracts a source operand from a destination operand. SUB destination, source For eg. , sub cl, al ; subtract 8–bit register from register sub var 1, ax ; subtract 16–bit register from memory sub dx, var 1 ; subtract 16–bit memory from register sub var 1, 10 ; subtract immediate value from memory