Printing bits of a 16-bit register
;this program prints all the bits of bx register
;this program also shows how we can use MACRO
org 100h
display macro char
;just printing a char
mov al, char
mov ah, 0Eh
int 10h
endm
start:
mov bx,3632;putting any random value in ax
mov cx,16 ;16 because there are 16 bits in bx register
begin:
;shifting one byte to left, left most byte goes to carry flag
;we can shift more byte, eg shl bx,5 will shift 5 bytes
;shl bx,2 will be equal to multiplying ax with 2
;shr bx,2 will be equal to dividing ax with 2
shl bx,1
jc one ;jump to one if carry flag has 1 in it
display '0'
dec cx
jnz begin;if cx is not zero than goto begin again
jmp end
one:
display '1'
dec cx
jnz begin;if cx is not zero than goto begin again
end:
mov ax, 4ch; terminating
int 21h
Running System Bell
;this program prints all the bits of bx register
;this program also shows how we can use MACRO
org 100h
display macro char
;just printing a char
mov al, char
mov ah, 0Eh
int 10h
endm
start:
mov bx,3632;putting any random value in ax
mov cx,16 ;16 because there are 16 bits in bx register
begin:
;shifting one byte to left, left most byte goes to carry flag
;we can shift more byte, eg shl bx,5 will shift 5 bytes
;shl bx,2 will be equal to multiplying ax with 2
;shr bx,2 will be equal to dividing ax with 2
shl bx,1
jc one ;jump to one if carry flag has 1 in it
display '0'
dec cx
jnz begin;if cx is not zero than goto begin again
jmp end
one:
display '1'
dec cx
jnz begin;if cx is not zero than goto begin again
end:
mov ax, 4ch; terminating
int 21h
There is no output you will hear only sound of system bell
No comments:
Post a Comment