Hello I am pretty new to assembly and I am trying to write onto a file a score, a name and a date (by this order) from a game I developed in emu8086. However I can't write the score before the name (It only writes the name and the date). Any help?
Here's the code:
push si
push ax
push bx
push cx
push dx
;Score
push 4
mov ax, Score
call GetAscii >**; transforms number into ascii and puts it into [si]****
add sp, 4
> **;player name**
lea si, Result
add si, 12
mov [si], ';'
inc si
>**;Date**
push 2
mov ah, 2ah
int 21h
xor ax, ax
mov al, dl ;
call GetAscii ;Day
mov [si], '/'
inc si
mov al, dh ;
call GetAscii ;Month
mov [si], '/'
inc si
mov ax, cx
push 4
call GetAscii ;year
add sp, 2
mov [si], ';'
inc si
;time
mov ah, 2ch
int 21h
xor ax, ax
mov al, ch ;
call GetAscii ;Hours
mov [si], ':'
inc si
mov al, cl ;
call GetAscii ;minutes
mov [si], ':'
inc si
mov al, dh ;
call GetAscii ;Seconds
mov [si], ';'
inc si
;write onto file "Resultados.txt"
lea dx, ResultadosFile
mov al, 2
call FOpen
jnc WriteData
xor cx, cx
call FCreate
WriteData:
mov bx, ax
xor cx, cx
xor dx, dx
mov al, 2
call FSeek
lea dx, Result
mov cx, 40
call FWrite
call FClose
pop dx
pop cx
pop bx
pop ax
pop si
ret
RegScore endp
GetAscii proc
push dx
push cx
push bx
push bp
mov bp, sp
xor bh, bh
mov bl, 10
xor cx, cx
GetNum:
xor dx, dx
div bx
push dx
inc cx
cmp ax, 0
jne GetNum
PutZero:
cmp cx, [bp+10]
je PutNum
push 0
inc cx
jmp PutZero
PutNum:
pop [si]
add [si], 48
inc si
dec cx
or cx, 0
jz EndAscii
jmp PutNum
EndAscii:
pop bp
pop bx
pop cx
pop dx
ret
GetAscii endp
On the file it only appears the name of the player and the date.
If I put the score lines after the lea si, result it now shows the score.