Hello I am also a beginner Z180 assembly language programmer I would like to know how to times a register by a interger value i.e I want the accumulator to be times by 100 then I want to store this value then the new accumulator value (entered via a keypad)to be times by 10 then this is stored and then the new accumulator value is added wtih the previous two values of the accumulator after its had its multiplication.I am unsure about the programming PLEASE HELP.THANKS
Posted on 2001-11-20 15:57:10 by thepineapple1
Hi,

Maybe this should work (I haven't had time to test it, and I only have a Z80 emulator, not Z180, but I guess they're quite the same):




; multiply input*100

in a,(Keypad port 8 bit value here)
ld h,0
ld d,a
ld b,6
ld e,a
call multiply
ld f,h
ld e,d
ld b,5
call multiply
ld l,e
add af,hl
ld e,d
ld b,2
call multiply
ld l,e
add af,hl
push af ; store 16bit value in the stack

; Multiply next input*10

in a,(Keypad port 8 bit value here)
ld h,0
ld d,a
ld b,3
ld e,a
call multiply
ld f,h
ld e,d
ld b,2
call multiply
ld l,e
add af,hl
pop hl
add af,hl ; The 16 bit value needed is now in af

; af=(firstentry*100)+(secondentry*10)

multiply:
sla e
callc carry
cmp c,0
jnz jump
sla h
jump:
ld c,0
djnz multiply
ret

carry:
sla h
set h,1
ld c,1
ret



Hope it helps. Bye,

Wavemaker
Posted on 2001-11-20 20:38:46 by Wavemaker
thanks for your help do I have to use so many registers???
Posted on 2001-11-25 13:11:32 by thepineapple1
Does this mean on the keypad I enter a digit at a time or do i enter all three digit s at once???Or does this not matter ?
Posted on 2001-11-27 05:43:48 by thepineapple1
It depends on the machine you are using! I don't even know if you are coding for a mobile phone, a microwave oven or a computer. If you tell me the brand and the model of the machine, I could be of some help to you.

Regards,

Wavemaker
Posted on 2001-11-27 06:44:13 by Wavemaker