0

2つの文字を比較する方法、最初の文字はユーザー入力です。

include 'emu8086.inc'

#make_COM#

ORG 100h

answer DW ?
score DW ?

MOV score, 0

PRINT "This is a 10 question Exam"

PUTC 13
PUTC 10
PUTC 13
PUTC 10

PRINT "1.) A is the Answer"
PUTC 13
PUTC 10
PRINT " A.)"
PUTC 13
PUTC 10
PRINT " B.)"
PUTC 13
PUTC 10
PRINT " C.)"
PUTC 13
PUTC 10
PRINT " D.)"
PUTC 13
PUTC 10
PRINT "Your Answer: "  
LEA     DI, buffer      
MOV     DX, 10     
CALL GET_STRING  
MOV answer, AX
PUTC 13
PUTC 10

MOV     SI, answer
CALL    print_string

CMP SI, answer
JE Correct
JMP result

Correct:
ADD score, 1
JMP result

result: 
PRINT "Your Score: "
CALL PRINT_NUM

RET

buffer DB "x"

DEFINE_SCAN_NUM
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS
DEFINE_PRINT_STRING
DEFINE_GET_STRING

END
4

1 に答える 1