Zdravim,
Balů: Vdaka, istotne to pouzijem ako studijny material jedneho dna ked to konecne vzdam s assemblerom a prejdem na C.
Anonymní: Prvy link uzitocny, pekne vysvetlenie principu na prevod 8-bitoveho cisla, ale update na tri 8-bitove registre ktore treba previest do 10 ascii digitov by bol vazne komplikovany.
Druhy link: tie 24bit to bcd procedury bud nefunguju, alebo som ich zle pouzil.
Treti link: neriesi 24-bitove cisla.
**JohnBoss:**Uzitocny link v pripade ak chcem 24-bitovo nasobit alebo delit, prevod do ascii tam ale nie je.
Po dlhom hladani sa mi podarilo nakoniec najst proceduru ktora funguje, takze ju tu pastnem, mozno v buducnosti niekto z toho vytazi
; ****************** Convert 24 bit binary to ASCII ************
;
ToAscii ; --- Do binary to packed BCD first
;
b2bcd movlw 24 ; 24-bits
movwf rI ; Make cycle counter
clrf rBcd ; Clear result area
clrf rBcd+1 ;
clrf rBcd+2 ;
clrf rBcd+3 ;
;
b2bcd2 movlw rBcd ; Make pointer
movwf FSR ;
movlw 8/2 ; Eight BCD nibbles, four packed bytes
movwf rCnt ;
;
b2bcd3 movlw 0x33 ; Add 3 to each nibble
addwf INDF,F ;
btfsc INDF,3 ; Test if low result > 7
andlw 0xf0 ; Low result >7 so don't take the 3 out
btfsc INDF,7 ; Test if high result > 7
andlw 0x0f ; High result > 7 so don't take the 3 out
subwf INDF,F ; Any results <= 7, subtract back
incf FSR,F ; Point to next
decfsz rCnt,F ; Dec byte count
goto b2bcd3 ; Do next byte...
;
rlf rBin+2,f ; Get another bit
rlf rBin+1,f ;
rlf rBin+0,f ;
rlf rBcd+3,f ; Put it into bcd
rlf rBcd+2,f ;
rlf rBcd+1,f ;
rlf rBcd+0,f ;
decfsz rI,f ; All done?
goto b2bcd2 ; No, loop
;
;
;
; --- Convert the 8 binary coded digits (4 bytes) starting at
; <bcd> into an ascii string also starting at <bcd>. Original
; bcd digits are lost.
;
bcd2a movlw rAscii+7 ;
movwf rPto ; Destination pointer
movlw rBcd+3 ;
movwf rPti ; Source pointer
movlw 4 ; 4 bytes to process
movwf rCnt ;
;
bcd2a1 movf rPti,W ; Get current input pointer
movwf FSR ;
decf rPti,F ; Prepare for next
movf INDF,W ; Get 2 bcds
movwf rTemp ; Save for later
movf rPto,W ; Get current output pointer
movwf FSR ;
decf rPto,F ; Prepare for next
decf rPto,F ;
movf rTemp,W ; Get digits back
andlw 0x0f ; Process lsd
movwf INDF ;
movlw '0' ;
addwf INDF,F ; To output
decf FSR,F ;
swapf rTemp,W ; Process msd
andlw 0x0f ;
movwf INDF ;
movlw '0' ;
addwf INDF,F ; To output
decfsz rCnt,F ; All digits?
goto bcd2a1 ;
retlw 0
a zdroj (prispevok 2):
https://forum.sparkfun.com/viewtopic.php?t=5725
Dakujem.