ini mas contoh yg coba saya kutip:listing dibawah menganggap klu di buf udah ada data 1.............3 tapi yg saya maksud jika data di buf berubah dan banya gimana?
org $30
buf ds3
buf ds3
;data di buf 1...3
;buf = '1'
;buf+1 = '2'
;buf+2 = '3'
....
mov r0,#buf
acall ascii2nible
acall ascii2nible
acall ascii2nible
....
mov a,buf
mov b,#100
mul ab
mov r7,a ;hasil ratusan
mov a,buf+1
mov b,#10
mul ab
adda,r7 ;puluhan+ratusan
adda,buf+2 ;puluhan+ratusan+satuan
;hasil akhir 1 hex di acc
....
;buf = '1'
;buf+1 = '2'
;buf+2 = '3'
....
mov r0,#buf
acall ascii2nible
acall ascii2nible
acall ascii2nible
....
mov a,buf
mov b,#100
mul ab
mov r7,a ;hasil ratusan
mov a,buf+1
mov b,#10
mul ab
adda,r7 ;puluhan+ratusan
adda,buf+2 ;puluhan+ratusan+satuan
;hasil akhir 1 hex di acc
....
ascii2nible:
mov a,@r0 ;ambil dr buf
cjne a,#'0',*+3
jc not_0_9 ;di bawah '0'?
cjne a,#'9'+1,*+3
jnc not_0_9 ;di atas '9'?
ok_0_9:clrc
subb a,#'0' ;ingat bhw '0'=$30 dan '1'=$31 dst...
mov @r0,a
inc r0 ;utk point ke buf selanjutnya
ret
not_0_9:
mov @r0,#0 ;paksa saja jadi 0!
inc r0 ;utk point ke buf selanjutnya
ret
mov a,@r0 ;ambil dr buf
cjne a,#'0',*+3
jc not_0_9 ;di bawah '0'?
cjne a,#'9'+1,*+3
jnc not_0_9 ;di atas '9'?
ok_0_9:clrc
subb a,#'0' ;ingat bhw '0'=$30 dan '1'=$31 dst...
mov @r0,a
inc r0 ;utk point ke buf selanjutnya
ret
not_0_9:
mov @r0,#0 ;paksa saja jadi 0!
inc r0 ;utk point ke buf selanjutnya
ret
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.
SPONSORED LINKS
| Power supply | Rf power amplifier | Power amplifier |
| Audio power amplifier | Audio power | Hobies |
YAHOO! GROUPS LINKS
- Visit your group "Elektronik-a" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
