;------------------------------------------------------------------------------
; fdm.asm
; FDD のモードを変更する for PC-9821V13
; Date: 2010/11/29
;
; > yasm -fbin -o fdm.com fdm.asm
; > nasm -fbin -o fdm.com fdm.asm
;
;------------------------------------------------------------------------------

%define	argnum	080h
%define	argpos	082h
%define	fddport	04BEh

    BITS 16
    org 100h
    section .text
start:
    mov dx,message
    mov ah,09h
    int 21h

	call modechg
    mov ah,09h
    int 21h

    mov ax,4c00h
    int 21h

modechg:
	cmp	byte [cs:argnum], byte 0
	jz	.none

.mode_chk:
	cmp	byte [cs:argpos], byte '2'
	jz	.m125
	cmp	byte [cs:argpos], byte '4'
	jz	.m144
.none:
    mov	dx,msg0
	ret

.m125:
    mov	al,30h
    mov dx,fddport
    out	dx,al
    mov dx,msg2
	ret

.m144:
    mov	al,31h
    mov dx,fddport
    out	dx,al
    mov dx,msg4

.done:
	ret

    section .data
message:    db 'FDD mode changer', 0dh, 0ah, '$'

msg0:		db 'usage: fdm [ 2 | 4 ]', 0dh, 0ah,
			db '  2: 1.25MB mode', 0dh, 0ah,
			db '  4: 1.44MB mode', 0dh, 0ah, '$'
msg2:		db '1.25MB mode', 0dh, 0ah, '$'
msg4:		db '1.44MB mode', 0dh, 0ah, '$'

