assembly - Check if number is in range on 8051 -



assembly - Check if number is in range on 8051 -

i have received character on uart, , need validate if it's number character.

normally i'd do

if (char >= '0' && char <= '9') { /* valid */ }

however, have in assembly.

i haven't found compare instruction (so assume there none).

how can this?

mov a, sbuf ; load number ; -- pseudocode -- cmp a, #'0' ; in avr, i'd way brlt fail ; i'm new 8051 cmp a, #'9' brge fail ; -- pseudocode -- ; number fail:

edit: ok here's have doesn't work

;====================================================== ; check if r1 number char -> r0 = 1 or 0 ;------------------------------------------------------ fn_isnum: force acc force 1 mov r1,a subb a,#'0' jc isnum_bad mov a,r1 subb a,#'9'+1 jc isnum_bad pop 1 pop acc mov r0,#1 ret isnum_bad: pop 1 pop acc mov r0,#0 ret ;======================================================

the easiest thing compile in c , check listing file. here compiler produces.

mov a, sbuf clr c subb a, #030h jc ?c0026 mov a, sbuf setb c subb a, #039h jnc ?c0026 ; set instructions here execute when code valid ?c0026:

assembly embedded 8051

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -