recently i started learning assembly and it is quite a journey! :) I know a few basic things and I wanted to learn about data storage by recreating my python program. The program should take an input (I am not sure if it is possible in asembly) and return the number of heads a hydra will have after a certain number of days. Formula:result = ((old_day*new_day)+(new_day-old_day))
I have simplified my python code to:
old_day = 2
new_day = 3
fight = 5
temp1 = 0
temp2 = 0
temp3 = 0
for i in range(fight):
temp1 = old_day*new_day
temp2 = new_day-old_day
temp3 = temp1+temp2
old_day = new_day
new_day = temp3
print(old_day)
And so far I came up with this in assembly:
global _start
section .data
old dw 2
l_old equ $ - old
new dw 3
l_new equ $ - new
tem1 dw 0
l_tem1 equ $ - tem1
tem2 dw 0
l_tem2 equ $ - tem2
tem3 dw 0
l_tem3 equ $ - tem3
days dw 4
section .text
_start:
mov al, [old]
mov bl, [new]
mov cl, [tem1]
mov dl, [tem2]
mov ah, [days]
mov eax, 1
mov ebx, 0
int 0x80
label:
I got stuck at the label since mul
stores its result in aex
but i store my values in al
and ah
.
My question is: Will the mul
override my data? Is there a better way of storing data? And finally do I need all the lines with equ
or is that only relevant when outputting?
Thanks for your time and help :)