;*********************************************************** ;Name: Addressing Mode Demo ;Author: Dan Kohn ;Date: 9/12/02 ;Function: To demonstrate the various addressing modes ; of the 80x86 processor ;On call: (Self contained code, no inputs needed) ;Returns: (no Return -> mainline program) ;*********************************************************** #make_COM# ; COM file is loaded at CS:0100h ; (the value of CS is set by Operating System) ORG 100h jmp main TEST1 db 'Dello world how are you' ; ^ NO : (it will not work with colon) main: mov al,'h' ; Immediate addressing ; puts 'h' into al mov bl,al ; register addressing ; puts what was in AL into BL mov al, test1 ; direct (from memory) ; puts the first character of string ; into AL mov test1, bl ; direct (to memory) ; puts what is in BL into memory location ; pointed to by test1 mov si, offset test1 ; Register Indirect (gets what is pointed mov al,[si] ; to by label test1 and places that into AL) ; [valid registers for mode: BX BP SI DI] mov bx, offset test1 ; base address (gets address of TEST1 and adds mov al,[bx+2] ; 2 to it and then gets what that is pointing ; to and places that into AL) ; [valid registers for mode: BX BP] mov bp, offset test1 ; Base indexed addressing (Gets address of TEST1 mov si,00007h ; adds the value of BP (7 in this case) and go to mov dl,[si+bp] ; that memory location and put the contents ; into DL). ; [valid registers for mode: BX or BP / DI or SI] mov bp, offset test1 ; Base indexed with displacement (Gets address mov si,00007h ; of TEST1 adds the value of BP (7 in this mov dl,[si+bp+4] ; case) adds the value of 4 and go to that ; memory location and puts the contents into DL. ; [valid registers for mode: BX or BP / DI or SI] hlt