User Tools

Site Tools


base:another_hexadecimal_to_decimal_conversion

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
base:another_hexadecimal_to_decimal_conversion [2015-04-17 04:30] – external edit 127.0.0.1base:another_hexadecimal_to_decimal_conversion [2020-11-14 22:54] – fixed typos in comments mace
Line 18: Line 18:
  rol lobyte  rol lobyte
  rol hibyte  rol hibyte
- bcs calculate // when bit drops off, it means we need to calculate+ bcs calculate // when bit drops off, decimal value must be added
  // if not, go to the next bit  // if not, go to the next bit
  txa  txa
- axs #$05 // ILLEGAL OPCODE, use the 3 lines below as alternative+ axs #$05 // ILLEGAL OPCODE, alternatively use lines below
  // sec  // sec
  // sbc #$05  // sbc #$05
  // tax  // tax
- cpx #$ff + bpl loop1
- bne loop1+
 END: END:
  rts  rts
Line 34: Line 33:
  ldy #$04  ldy #$04
 loop2: loop2:
- lda table,x // get the decimal equivalent of the bit in ASCII numbers + lda table,x // get decimal equivalent of bit in ASCII numbers 
- beq zero // skip (speed up) when there's nothing to add + adc #$00        // add carry, is set if the former addition ≥10 
- adc result,y // add to whatever result we alread haven +                beq zero // skip (speed up) when there's nothing to add 
- cmp #$3a // passing 10 with the addition? + adc result,y // add to whatever result we already have 
- bcc notten + cmp #$3a // 10 with the addition? 
- sbc #$0a // if so, subtract 10, carry will take care of overflow + bcc notten      // if not, skip the subtraction 
 + sbc #$0a // subtract 10 
 notten: notten:
  sta result,y  sta result,y
base/another_hexadecimal_to_decimal_conversion.txt · Last modified: 2020-11-14 23:05 by mace