Last active
August 26, 2020 14:08
-
-
Save nahiyan/4ea2924784f24e253e84f58b1d6f4706 to your computer and use it in GitHub Desktop.
CSE331
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org 100h | |
; Set the address | |
MOV AX, 3010h | |
MOV DS, AX | |
MOV BX, 0000h | |
; Move the contents of the selected address to BL | |
MOV BL, BYTE PTR DS:[BX] | |
; Copy BL to BH to do some calculations regarding odd/even | |
MOV BH, BL | |
; BH will only have the LSB | |
AND BH, 0001h | |
; Is LSB = 0? | |
CMP BH, 0000h | |
; Copy BL to AL for port output | |
MOV AL, BL | |
JZ EVEN | |
JNZ ODD | |
; odd | |
ODD: | |
OUT 03h, AL | |
JMP EXIT | |
; even | |
EVEN: | |
MOV DX, 0303h | |
OUT DX, AL | |
JMP EXIT ; not necessary, but keeping it for consistency | |
EXIT: | |
ret | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org 100h | |
; BL = Arbitrary | |
MOV BL, 10111001b | |
MOV BH, 0 | |
MOV CX, 8 | |
L: | |
SHR BL, 1 | |
ADC BH, 0 | |
LOOP L | |
; BH now has the number of set bits in BL | |
ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org 100h | |
; BL = Arbitrary | |
MOV BL, 00001001b | |
XOR BL, 10000000b | |
AND BL, 10000000b | |
CMP BL, 00000000b | |
JZ PS | |
JNZ NG | |
; positive | |
PS: | |
MOV DL, 00h | |
JMP EXIT | |
; negative | |
NG: | |
MOV DL, 01h | |
JMP EXIT | |
EXIT: | |
ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org 100h | |
; BL = arbitrary | |
MOV BL, 9AH | |
AND BL, 0F0H | |
CMP BL, 90H | |
JG GT | |
JNG LT | |
; BL's higher nibble > 9 | |
GT: | |
MOV AL, BL | |
OUT 00h, AL | |
JMP EXIT | |
; BL's higher nibble <= 9 | |
LT: | |
MOV AX, 0F000h | |
MOV DS, AX | |
MOV BX, 0FF2h | |
MOV BYTE PTR DS:[BX], BL | |
JMP EXIT | |
EXIT: | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment