Digital Stronghold - Software Engineering Blog




October 18, 2006

Bad luck

This is a program that simply extracts numbers from buffered input. I do not have any idea why this didn’t work. I got a zero.

input:
        mov ah, 0ah		; buffered input sys call
        lea dx, strptr		; load effective address
        int 21h			; call kernel
	
        mov ah, 02h		; write character to stdout sys call
        mov dl, 0ah		; issue carriage-return
        int 21h			; call kernel
	
        lea si, string		; set source index to start of string
        mov cl, [strlen]	; set loop counter
	
here:
        mov dl, [si]		; place current character in dl
        cmp dl, '0'		; compare if below '0'
        jb traverse
        cmp dl, '9'		; compare if above '9'
        ja traverse
	
        mov ah, 02h		; write character to stdout sys call
        int 21h			; call kernel
        cmp dl, '$'		; check end-of-string sentinel
        je exit			
	
traverse:
        inc si			; increment source index pointer
	
loop here
	
exit:
        int 20h			; terminate
	
strptr  label byte
maxlen  db 49
strlen  db ?
string  db 50 dup ('$')

It runs smoothly on my machine. Damn it.

1 Comment »

The URI to TrackBack this entry is: http://eradicus.blogsome.com/2006/10/18/bad-luck/trackback/

  1. maybe you ran it under linux… :p

    Comment by south coast marine — October 19, 2006 @ 1:01 pm

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Theme designed by Joset Anthony Zamora


Digital Stronghold

↑ Get Headline Animator