title  Testing various addressing modes

dosseg

.model 	small			;Identifies type of memory model to use

.stack 	100h			; Identifies size of stack segment

.data				;Contains all variables for the program

count   db 20h 
count1  db 30h
array   dw 10h, 20h, 30h, 40h, 50h, 60h, 70h, 80h

.code				;Contains all code from program
main  	proc
      	mov   	ax,@data	;Required to setup the data segment in the ds register.
      	mov   	ds,ax

; direct addressing
	mov   	ah, count
        mov     al, [count] ; preferred
; indirect addressing
        mov     bx, offset array
        mov     ax, [bx]
        add     bx, 2
        mov     ax, [bx]
; using the segment prefix
        mov     bp, offset array
        mov     ax, [bp] ; WRONG!!! If loads from SS:BP
        mov     ax, ds:[bp]  ; this is what you probably wanted
; based, indexed
        mov     bx, 8
        mov     ax, array[bx]
        
; based and indexed
        mov     bx, offset array
        mov     si, 6
        mov     ax, [bx+si]
; based and indexed with displacement
        mov     ax, 2[bx][si] ; 2 + bx + si
        
; terminate
  	mov   	ax,4C00h	;Required to terminate program normally
	int   	21h
main  	endp
end   	main

