harikrishnan's micro86 basic2: ; shows some of the data addressing modes of 8086 ; step this program ; immediate addressing mov BX,1011 ; copy 1011 to bx mov AL,50 ; copy 50 to AL ; register addressing mov cx,bx ; copy bx to cx ; direct addressing mov [1010] , AL ; place AL's contents to ; memory address 1010 ; see ram while stepping ; register indirect addressing mov [bx], AL ; place AL's contents to ; memory address bx ; here bx is 1011. so ; AL is copied to [1011], in effect. ; base plus index mov ch,[bx+si]; here si = 0 and bx = 1011 ; thus a byte from memory location bx+si ; ie,(1011+0) is copied to ch hlt basic3: ; shows some arithmetic instructions ; step the program and watch registers ; note:- all numbers are in hex form Add ax,5 ; ax = ax + 5 dec ax ; ax = ax - 1 (decrement) inc ax ; ax = ax + 1 (increment) sub ax,2 ; ax = ax - 2 ; 8-bit multiplication and division mov bl, 2 ; copy 2 to bl mul bl ; aX = al * bl; (result is 16-bit) mov dh,4 ; copy 4 to dh div dh ; aL = aX / dh (quotient in AL) ; remainder in ah hlt basic4: ; demo of a loop ;; mov cx,5 ; copy count to cx ; cx determines how many times ; loop should execute NEXT: ; 'NEXT' is a label inc ax; ax = ax + 1 ; loop NEXT ; goto NEXT if cx not zero hlt ;loop instruction does two things ;first cx = cx - 1 ;next it checks whether cx is 0 ;if cx is not zero,it jumps to a label (here 'NEXT') ;if cx is zero, execution of next instruction is continued basic5: ; demo of a loop using 'jmp' ; step this program START: ; 'START' is a label Add cx,3 ; your instructions Add cx,3 ; your instructions Add cx,3 ; your instructions jmp START ; jump to START ; 'jmp' jumps to the given label basic6: ; demo of a procedure ; 'call' is used to call a procedure ; procedures can be called many times ; step the program ; it does'nt do anything in particular mov ax,ffff ; call myproc1 ; call the procedure myproc mov ah,ee ; call myproc2 ; call the procedure myproc again hlt ; stop proc myproc1 ; this is how we name a procedure dec ax ; instructions to do ret ; return from here proc myproc2 ; this is how we name a procedure inc ax ; instructions to do ret ; return from here