flat assembler
Message board for the users of flat assembler.
Index
> Main > Use and for divide 10? |
Author |
|
revolution 06 May 2020, 04:13
99999 and 9999 = 1551
The answer of 9999 is not possible by using and alone. xor can do it: 99999 xor 106896 = 9999 It also multiplies by 10: 9999 xor 106896 = 99999 |
|||
06 May 2020, 04:13 |
|
Roman 07 May 2020, 10:25
In packman game i see convert integer to asc2 where use asm comand And
And not use many calls. But i found this code Code: 16-bit Integer to ASCII (decimal) Input: HL = number to convert, DE = location of ASCII string Output: ASCII string at (DE) Num2Dec: ld bc,-10000 call Num1 ld bc,-1000 call Num1 ld bc,-100 call Num1 ld c,-10 call Num1 ld c,b Num1: ld a,'0'-1 Num2: inc a add hl,bc jr c,Num2 ;this carry flag. JMP if c=1 sbc hl,bc ld [de],a inc de ret Last edited by Roman on 07 May 2020, 10:30; edited 1 time in total |
|||
07 May 2020, 10:25 |
|
revolution 07 May 2020, 10:30
That is using add, not and.
Is is subtracting multiples of 10^n and counting the loops. IMO it gets unwieldy for 32-bit numbers and quite ugly for 64-bit numbers, especially if you want to do leading zero suppression. |
|||
07 May 2020, 10:30 |
|
st 16 May 2020, 08:01
Z80 does not support div nor mul, that is why such routines were common for it. On x86 it is more appropriate to use multiplication with magic numbers https://board.flatassembler.net/topic.php?t=20099
Also please take a look at Magic Divider by The_Svin |
|||
16 May 2020, 08:01 |
|
edfed 20 May 2020, 08:56
aam is the instruction you're searching for.
after aam: ah = al/10 al = al%10 |
|||
20 May 2020, 08:56 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.