title  Conditional operators and logical operations

dosseg

.model 	small			;Identifies type of memory model to use

.stack 	100h			; Identifies size of stack segment

.data				;Contains all variables for the program

num1   db 00000011b 
num2   db 00001010b
num3   db 11110000b
array   dw 10h, 20h, 30h, 40h, 50h, 60h, 70h, 80h

number1 dw 10h
number2 dw 20h
number3 dw 30h

.code				;Contains all code from program
main  	proc
      	mov   	ax,@data	;Required to setup the data segment in the ds register.
      	mov   	ds,ax

; logical operators: and
        mov     ah, [num1]
        mov     al, [num2]
        and     ah, al
; logical operators: or
        mov     ah, [num1]
        or     ah, al
; logical operators: xor
        mov     ah, [num1]
        xor     ah, al
; logical operators: test
        mov     ah, [num1]
        mov     cl, [num3]
        test     ah, al
        test     ah, cl

; implementing an if statement
        mov     cx, 5
        mov     ax, [number1]
        mov     bx, [number2]
        cmp     ax, bx  ; same as sub but it does not overwrite ax
        jge     else1     
        inc     cx
        inc     cx
        jmp     endif1
else1:  dec     cx
        dec     cx
endif1: nop

; implementing a while or for loop
        mov     ax, [number3]
        mov     bx, [number2]
while1: cmp     ax, bx  ; same as sub but it does not overwrite ax
        jge     whileend1
        ; body of the loop
        inc     bx
        inc     bx
        jmp     while1
whileend1: nop
        
        
; terminate
  	mov   	ax,4C00h	;Required to terminate program normally
	int   	21h
main  	endp
end   	main


