how I can do so that the following code receives letters, it stores them in the array and soon it shows them by screen, that is to say, just like it does now but with letters.
thank you friends
.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include \masm32\include\windows.inc ; always first
include \masm32\macros\macros.asm ; MASM support macros
; -----------------------------------------------------------------
; include files that have MASM format prototypes for function calls
; -----------------------------------------------------------------
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
; ------------------------------------------------
; Library files that have definitions for function
; exports and tested reliable prebuilt code.
; ------------------------------------------------
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.data
; --------------------------
; initialise 10 DWORD values
; --------------------------
itm0 dd ?
itm1 dd ?
itm2 dd ?
; ---------------------------------
; put their addresses into an array
; ---------------------------------
array dd itm0,itm1,itm2
.code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start: ; The CODE entry point to the program
call main ; branch to the "main" procedure
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
main proc
LOCAL var1:DWORD
LOCAL str1:DWORD
LOCAL cnt:DWORD
push esi
push edi
mov cnt, 1
mov edi,array
llena:
mov str1, input("Enter a number : ")
print chr$(" ",10,13)
mov var1, sval(str1)
mov eax, var1
mov [edi],eax
add edi, 4
add cnt,1
cmp cnt,4
jb llena
jae imprime
imprime:
pop esi
pop edi
ciclou:
push esi
push edi
mov cnt, 1
mov esi,array
ciclo:
print chr$(" ",10,13)
mov edi, [esi]
print str$(edi)
add esi,4
add cnt,1
cmp cnt,3
jbe ciclo
pop esi
pop edi
ret
main endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
dgonzalez,
I see a couple of things in your code, that can be changed.
First, the pushing and popping of esi,edi in your code is not needed.
Second you have this:
mov cnt, 1
mov edi,array <--------------------------------------------
With the code you have that I have pointed to, you are moving the dword VALUE at the ADDRESS of the variable 'array' into the edi register.
IF you need edi to contain the ADDRESS of the variable 'array', then you would use this:
mov edi, OFFSET array
OFFSET returns the address of a label or variable at compile time.
Also, try changing this:
cmp cnt,4
jb llena
jae imprime
imprime:
to this:
cmp cnt,4
jne llena
imprime:
This way you'll keep loop back to llena, untill cnt = 4, and when it does, the program will continue at the address of imprime.
rags
thanks for your aid, I already made the changes that you suggested to me, but I have another problem, I want to fill the array with letters types from keyboard and soon to be able to show it to it by screen.
how I can do that, because my program works very well but when the type values are numbers.
For example, I want to fill my array thus:
arrray[1]=a, array[2]=s, array[3]=p
and soon to show the user the letters to him that type are:
a
s
p
dgonzalez,
The reason why only numbers and not letters show up is this, according to the Masm32 high level reference entry for sval:
Quote
Description
Convert a signed string value to a 32 bit integer.
Which means, any string that is passed to it, will only be converted to a numeric value, if the string contains a representation of a numeric value.
Example:
.DATA
str1 db "1234",0
str2 db "-3",0
.DATA?
num1 dd ?
num2 dd ?
.CODE
-------
-------
mov num1, sval(offset str1) ; num1 now contains the value 1234
mov num2, sval(offset str2) ; num2 now contains the value -3
------
I hope this helps.
Rags
As a side note, your original code is popping registers in the same order as that which they were pushed in. For stack preservation to work correctly, you need to pop them in the OPPOSITE order.
ie.
push edi
push esi
.
.
.
pop esi
pop edi
I'm also getting some serious deja vu here (I think I posted exactly the same to another identical question yesterday...) but can you post a copy of the output you're getting and the output you expect/want? Makes it much easier to follow without coding the entire thing ourselves ;)
Hello friends
Thank you rags for yours aid, look, exactly I want to do is this:
it watches the attached file
[attachment deleted by admin]