어셈블리 문자 판별 프로그램

supaflow의 이미지

8086 프로세서 기반 어셈블리 프로그램을 짜고 있습니다.

사실 프로그램을 짠다라기 보단 제가 못짜서 그냥 키보드두드린다는 느낌밖에는 안드네요.

도스 프롬프트에서 문자를 입력하면
대문자인지, 소문자인지, 숫자인지, 기타문자 인지 판별하는건데요.

일단 소스 보여 드립니다.

.model small
 
.data
 
str1 	db 	"Input Key : ",'$'
var	db	?
 
upper 	db	'1'
lower	db	'2'
Num	db	'3'
etc	db	'4'
 
 
 
.code
main proc
 
	mov	ax,@data
	mov	ds,ax
 
	mov	ah,9
	mov	dx,offset str1
	int	21h
 
	mov	ah,1
	int 	21h
	mov	bl,var
 
	mov 	cl,'A'
	mov	ch,'Z'		
 
L1:	cmp 	bl,cl
	jge	L2
	jmp	L3
 
L2:	cmp	bl,ch
	jnge	L10
	jmp	L3
 
L3:	mov	cl,'a'
	mov	ch,'z'
 
	cmp 	bl,cl
	jge	L4
	jmp	L5
 
L4:	cmp	bl,ch
	jnge	L11
	jmp	L5
 
L5:	mov 	cl,'0'
	mov	ch,'9'
 
	cmp	bl,al
	jge	L6
	jmp	L13
 
L6:	cmp	bl,ch
	jnge	L12
	jmp	L13
 
L10:	mov	ah,2
	mov	dl,upper
	int	21h
 
	mov	ah,4Ch
	int	21h
 
L11:	mov	ah,2
	mov	dl,lower
	int	21h
	mov	ah,4Ch
	int	21h
 
L12:	
	mov	ah,2
	mov	dl,num
	int	21h
	mov	ah,4Ch
	int	21h
 
L13:	mov	ah,2
	mov	dl,etc
	int	21h
	mov	ah,4Ch
	int	21h	
 
 
 
main endp
end main

들여쓰기는 안되는군요,,;;

L1~L6 label 은 아스키 값을 비교합니다.
L10~L13 은 각 조건에 맞는 값을 출력하게 됩니다.

upper,lower,num,etc 는 각각 대문자,소문자,숫자,기타문자를 나타냅니다.

if문 처럼 조건 비교를 하게되는데 여기서 뭐가 잘못된건지
어떤 키를 눌러도 4만 나오네요. 다른걸 건들면 무한루프에 빠지게 되고 정말 난감합니다..

어셈블리 잘하시는분들 도와주시면 감사하겠습니다.
아니면 간단하게 짤수도 있나요..?

grassman의 이미지

버그가 두 개 있습니다.

mov ah,1
int 21h
mov bl,var <-
 
...
 
cmp bl,al <-
jge L6
jmp L13

우선 var는 초기화 된 값이 아닙니다. INT 21h, AH = 1로 호출한 결과는 AL에 저장됩니다. 무슨 뜻인지 아시겠죠?

cmp bl, al에서 원래 의도대로라면 al 대신 다른 것일 듯 하군요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.