USE16
ORG 100h
exit =0
write =2
writes =9
dos =21h
ver =30h
start:
MOV AH,ver ;get version number
INT dos ;AL major AH minor version number
;;output major version number
PUSH AX ;create a copy of AX
CALL b2a ;convert lower byte to ASCII
MOV AH,write ;prepare write character system call
MOV DL,CH ;prepare to write high nybble ASCII
INT dos ;syscall
MOV DL,CL ;prepare to write low nybble ASII
INT dos ;syscall
;;write a dot between major and minor version number
MOV DL,'.' ;prepare to write a dot
INT dos ;syscall
;;output minor version number
POP AX ;restore AX
XCHG AH,AL ;switch bytes
CALL b2a ;convert higher byte to ASCII
MOV AH,write ;prepare write character system call
MOV DL,CH ;prepare to write high nybble ASCII
INT dos ;syscall
MOV DL,CL ;prepare to write low nybble ASCII
INT dos ;syscall
;;add a newline and quit
MOV AH,writes ;prepare write string system call
MOV DX,newline ;prepare to write newline
INT dos ;syscall
JMP quit ;quit
;;convert byte in AL into two ASCII characters in CH and CL
hextable:
DB '0123456789ABCDEF'
b2a:
PUSH AX ;save AX
MOV BX,hextable ;set address for translation table
MOV AH,AL ;create copy of nybble
SHR AL,4 ;isolate high nybble
AND AH,0Fh ;isolate low nybble
XLATB ;translate high nybble
XCHG AH,AL ;switch nybbles
XLATB ;translate low nybble
MOV CX,AX ;copy result into counter
POP AX ;restore AX
RET
newline:
DB 13,10,'$'
quit:
MOV AH,exit
INT dos