BCD to 7 segment code conversion
BCD to 7 segment code conversion Algorithm
Step I : Initialize the data segment.
Step II : Load the offset of look up table in BX.
Step III : Load AL with key i.e. digit whose 7
segment code is to be found.
Step IV : Compute 7 segment code using XLAT
instruction.
Step V : Display the result.
Step VI : Stop.
BCD to 7 segment code conversion Code
1 |
.model small <br/> .data <br/> lookup db 01h, 04h, 1Ah, 09h, 02H <br/> key db 02h <br/> .code <br/> mov ax, @data ; Initialize data section <br/> mov ds, ax <br/> mov bx, offset lookup ; Load offset of lookup in bx <br/> mov al, key ; key no. in al <br/> xlat ; translate byte in al <br/> mov bh, al ; al = lookup(key) <br/> mov ch, 02h ; Count of digits to be displayed <br/> mov cl, 04h ; Count to roll by 4 bits <br/> l2: rol bh, cl ; roll bl so that msb comes to lsb <br/> mov dl, bh ; load dl with data to be displayed <br/> and dl, 0fH ; get only lsb <br/> cmp dl, 09 ; check if digit is 0-9 or letter A-F <br/> jbe l4 <br/> add dl, 07 ; if letter add 37H else only add 30H <br/> l4: add dl, 30H <br/> mov ah, 02 ; Function 2 under INT 21H (Display character) <br/> int 21H <br/> dec ch ; Decrement Count <br/> jnz l2 <br/> mov ah, 4cH ; Terminate Program <br/> int 21H <br/> end |
Source projectgeek.com