Hi again,
I know this should be really simple to do - but instead I get some interesting outputs when I try this program... I've modified a variable (a) that is initialized to 0 and it should now hold 1 as a value - but it prints the initial value instead.
I've tried modifying the line 'a equ 0' to 'a dd 0' or 'a resd 0' but that does something even stranger (the output is 364).
org 0x100
section .data
a equ 0 ; set a to 0
Newline db 13, 10
Newlinelength equ 2
section .text
And esp, 0x0ffff
;Lea ESI, [a] ; load effective address of a into ESI.
;Mov EAX, 1 ; load 1 into EAX.
;Mov ESI, EAX ; load ESI with EAX.
Mov dword [a], 1 ; load address of a with 1.
push dword a ; push a
Call WriteInteger ; Writes 0 to the screen, instead of 1.
push Newlinelength
push Newline
Call WriteString
mov ax, 0x4c00
int 0x21
WriteInteger:
mov eax, [esp + 2]
mov ecx, 10
xor bx, bx
divide:
xor edx, edx
div ecx
push dx
inc bx
test eax, eax
jnz divide
mov cx, bx
outputDigit:
pop ax,
add al, '0'
mov dl, al
mov ah, 0x06
int 0x21
loop outputDigit
ret 4
WriteString:
mov si, [esp + 2]
mov cx, [esp + 4]
strtoconsole:
lodsb
mov dl, al
mov ah, 0x06
int 0x21
loop strtoconsole
.end:
ret 4
Thanks for your time and patience as I fumble with assembly code,
- Dominick