dimanche 2 juin 2019

How can I change the proc of math random to returning me in dw and not in db?

I am coding a game in assembly graphic. In the game every time the character taught object it give her on more point. I an trying to do this and also have a random numbers that will added to the points. The point are dw and the random is db and I dont sucses to change on of without destroy the other proc. What should I do to change it.

dataseg 
Clock equ es:6Ch
divisorTable db 10,1,0
randomPoints db ?
pointsMessage db 'points: $'
points dw 0 
ten db 10



proc Random7
PushAll
mov ax, 40h
mov es, ax
mov cx, 10
mov bx, 0
mov ax, [Clock] ; read timer counter
mov ah, [byte cs:bx] ; read one byte from memory
xor al, ah ; xor memory and counter
and al, 00000111b ; leave result between 0-15
add [points],al
endp Random7

proc PrintPoints
PushAll
    mov dh, 2 ;y location
    mov dl, 3 ;x location
    mov bh, 0 
    mov ah, 2
    int 10h 
    mov dx, offset pointsMessage
    mov ah,9
    int 21h
    mov dh, 2;y location 
    mov dl, 10 ;x location
    mov bh, 0 
    mov ah, 2
    int 10h
    xor ah,ah
    mov al, [points] ;divide counter by 10 
    div [ten]   ;div saves quotient in AL and remainder in AH 
    add al, '0' ;ASCII code for quotient is value+48('0') 
    add ah, '0' ;ASCII code for remainder is value+48('0') 
    push ax     ;so value in AH will be saved
    mov dl, al  ;prints quotient
    mov ah,2h
    int 21h 
    pop ax
    mov dl, ah ;prints remainder
    mov ah,2h
    int 21h 
PopAll
    ret
endp PrintPoints
;----------------------------------------------
;--------------add points----------------------
proc addPoints 
   add [points],2
    ret 
endp addPoints

proc subPoints 
    sub [points] , 3
    ret 
endp subPoints




Aucun commentaire:

Enregistrer un commentaire