; Sa se scrie un program care sa inverseze semioctetul superior altui BL = 12h cu cel inferior a lui CH = 56h. 
.model small
.radix 16
.code
start:
; --- 1) ---
;incarcarea valorilor
	mov BL, 12
	mov CH, 56
;voi folosi AX si DX pentru transformarile necesare necesare
	mov AH, BL
	mov AL, BL
	mov DH, CH
	mov DL, CH

; --- 2) ---
;filtrez in xL doar semioctetul inferiori
	and AL, 0F  ; 0Fh = 00001111b
	and DL, 0F

; --- 3) ---
;cobor in semioctetul inferior al xH pe cel superior prin deplasare
	shr AH, 4  ; semibyte = 4 biti
	shr DH, 4

; --- 4) ---
;acum am in AH semioctetul superior BL si in DL semioctetul inferior CH
;schimb cu locul dupa cerintele problemei
	xchg AH, DL

; --- 5) ---
;acum asamblez inapoi valorile BL si CH din AX si DX, respectiv
;urc semioctetul inferior la locul lui in AH si DH
	shl AH, 4
	shl DH, 4

; --- 6) ---
;compun octetii din semiocteti
	or AH, AL ; ex: 1001 0000 or 0000 1010 = 1001 1010
	or DH, DL

; --- 7) ---
; mut valorile inapoi de unde le-am luat
	mov BL, AH
	mov CH, DH

term: jmp term
end start


; 1)
;  cs:0000 B312           mov    bl,12           ax 1212   Śc=0Ś
;  cs:0002 B556           mov    ch,56        Ś  bx 0012   Śz=0Ś
;  cs:0004 8AE3           mov    ah,bl        -  cx 5600   Śs=0Ś
;  cs:0006 8AC3           mov    al,bl        -  dx 5656   Śo=0Ś
;  cs:0008 8AF5           mov    dh,ch        -  si 0000   Śp=0Ś
;  cs:000A 8AD5           mov    dl,ch        -  di 0000   Śa=0Ś


; 2)
;  cs:0008 8AF5           mov    dh,ch           ax 1202   Śc=0Ś
;  cs:000A 8AD5           mov    dl,ch        Ś  bx 0012   Śz=0Ś
;  cs:000C 240F           and    al,0F        -  cx 5600   Śs=0Ś
;  cs:000E 80E20F         and    dl,0F        -  dx 5606   Śo=0Ś

; 3)
;  cs:0011 D0EC           shr    ah,1            ax 0102   Śc=0Ś
;  cs:0013 D0EC           shr    ah,1         Ś  bx 0012   Śz=0Ś
;  cs:0015 D0EC           shr    ah,1         -  cx 5600   Śs=0Ś
;  cs:0017 D0EC           shr    ah,1         -  dx 0506   Śo=0Ś
;  cs:0019 D0EE           shr    dh,1         -  si 0000   Śp=1Ś
;  cs:001B D0EE           shr    dh,1         -  di 0000   Śa=0Ś
;  cs:001D D0EE           shr    dh,1         -  bp 0000   Śi=1Ś
;  cs:001F D0EE           shr    dh,1         -  sp 0000   Śd=0Ś

; 4)
;  cs:0019 D0EE           shr    dh,1            ax 0602   Śc=0Ś
;  cs:001B D0EE           shr    dh,1         Ś  bx 0012   Śz=0Ś
;  cs:001D D0EE           shr    dh,1         -  cx 5600   Śs=0Ś
;  cs:001F D0EE           shr    dh,1         -  dx 0501   Śo=0Ś
;  cs:0021 86E2           xchg   dl,ah        -  si 0000   Śp=1Ś

; 5)
;  cs:0023 D0E4           shl    ah,1            ax 6002   Śc=0Ś
;  cs:0025 D0E4           shl    ah,1         Ś  bx 0012   Śz=0Ś
;  cs:0027 D0E4           shl    ah,1         -  cx 5600   Śs=0Ś
;  cs:0029 D0E4           shl    ah,1         -  dx 5001   Śo=0Ś
;  cs:002B D0E6           shl    dh,1         -  si 0000   Śp=1Ś
;  cs:002D D0E6           shl    dh,1         -  di 0000   Śa=0Ś
;  cs:002F D0E6           shl    dh,1         -  bp 0000   Śi=1Ś
;  cs:0031 D0E6           shl    dh,1         -  sp 0000   Śd=0Ś

6)
;  cs:0023 D0E4           or     ah,al          ax 6202   Śc=0Ś
;  cs:0025 D0E4           or     dh,dl       Ś  bx 0012   Śz=0Ś
;  cs:0027 D0E4           mov    bl,ah       -  cx 5600   Śs=0Ś
;  cs:0029 D0E4           mov    ch,dh       -  dx 5101   Śo=0Ś

; 7)
;  cs:0033 0AE0           or     ah,al           ax 6202   Śc=0Ś
;  cs:0035 0AF2           or     dh,dl        Ś  bx 0062   Śz=0Ś
;  cs:0037 8ADC           mov    bl,ah        -  cx 5100   Śs=0Ś
;  cs:0039 8AEE           mov    ch,dh        -  dx 5101   Śo=0Ś
