untio 36 Light Poster

Hi,

Can you replace a part of your code for this one:

mov ecx, SIZEOF msg                    ;initialize loop counter   * I believe the issue starts here???
mov eax, OFFSET msg          ;address of msg
mov esi, eax                           ;esi points to start       
add eax, ecx               
mov edi, eax               
dec edi
dec edi                                ;edi points to end
shr ecx,1                              ;shift loop counter 

L1: 
 mov al, [esi]                         ;load characters
 mov bl, [edi]
 mov [esi], bl                         ;swap characters
 mov [edi], al
 inc esi                               ;update forward pointer by 1
 dec edi                               ;update backward pointer by 1
                                       ;loop
loop L1

With some changes to your code it works.

Best wishes.

Reedited: Please, forgive me. I have answered a solved question. Well, at least, everybody can see the solution.

untio 36 Light Poster

Hi,
Ancient Dragon, you have detected some errors, but, forgive me if I am wrong, in line 2:
"first: "
Is a literal string that contains the name of a variable, but it is not the variable.
Please, forgive my mistakes.

untio 36 Light Poster

Hi,

I am not a C++ expert, but I think that when you call scanf you must pass a pointer. The problem is that first is a pointer to char (that is the right parameter), but you are passing a pointer to pointer to char.

When you call scanf to get a string you should not use &. The name of the array is itself a pointer.

Cheers.

untio 36 Light Poster

Maybe I am wrong but this could be a first aproach to the solution:

    xorps xmm0, xmm0
    movaps [rbp - 64], %xmm0
    mov byte ptr [rbp - 63], 2
    mov dword ptr [rbp - 60],  3103850762
    mov word ptr [rbp - 62], 20480
    lea r14, [rbp - 64]

Please, forgive my mistakes.

untio 36 Light Poster

Hi,
Can you tell me what means:
passChar[i] - 1;
I think that this expression has no effect.
Maybe it must be:

if(i > 0)
{
    i--;
    passchar[i] = '\0';
}

And, for obtaining a string, remenber to add a zero to the end:

passChar[i] = input;
passChar[i++] = '\0';

Please, forgive me if I am wrong.
Cheers.

untio 36 Light Poster

Hi,
In 32 bits systems, there was emulation to 16 bits code.
In 64 bits systems, there is emulation to 32 bits code, but they do not support 16 bits programs.
If you want to know more about this emulation search in google "wow" (windows on windows).
There are three solutions:
1. You can install an emulator like VirtualBox and create a 32 bits virtual machine. To do this you need a 32 bits instalation disk. The virtual 32 bits system will emulate 16 bits machine when needed.
2. You can use an emulator to emulate a 16 bits machine. You need the instalation disks and a way to install them.
3. You use DosBox. It is the easier solution, I think.

Cheers.

untio 36 Light Poster

Hi,
I do not know your level of assembly in 32 bits on windows.
I have written a Hello world program and can be compiled using the file build.bat of the masm32 package. May be it surprise you.

This is the code:

.486
.model flat,stdcall
option casemap:none

include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib


.data
    bbbb db "is wonderful", 0
        aaaa db "Assembly",0
.code


inicio:
    invoke MessageBox, NULL, addr bbbb, addr aaaa, MB_OK
    invoke ExitProcess, 0
end inicio

You need to understand that interrupts are forbiden and you must call windows api functions.

Registers are named preceding an "E" to the msdos part: EAX, EBX, ECX, etc.
The low word can be accessed with the msdos name. AX is the low word of EAX. And AH is the high byte of AX and AL is the low byte of AX (and of EAX).

The good news are that in the model flat all segment registers point to the same segment of 4GB. You do not need to refer to them in the most cases.

Cheers.

untio 36 Light Poster

Hi once more,

Can you test my code:

.286
.MODEL SMALL

.STACK 1024

.DATA              
    inputFile db "A:\TASM\DRIVES.ASM", 0
    openingError db 'An error has occured at opening the file!$'
    readingError db 'An error has occured at reading the file!$'

.DATA?
    s1 db 10 dup(?)
    ls db ?
    handle dw ?

.CODE
    start:
    mov ax,@data
    mov ds,ax
;open the file
    mov ah, 3dh
    mov al, 0
    lea dx, inputFile
    int 21h
    jc openError
    mov handle, ax
;read 10 bytes from the file into s1
    mov ah, 3fh
    mov bx, handle
    mov cx, 10
    mov dx, offset s1
    jc readError
    int 21h
;I put the string terminator after the bytes read:
    mov bx, offset s1
    add bx, ax
    mov byte ptr [bx], '$'
;close file
    mov ah, 3eh
    mov bx, handle
    int 21h
;print string on the screen
    lea dx, s1
    mov ah, 09h
    int 21h
the_end:
    mov ax,4C00h
    int 21h
openError:
    mov ah, 09h
    mov dx, offset openingError
    int 21h
    jmp the_end
readError:
    mov ah, 09h
    mov dx, offset readingError
    int 21h
    jmp the_end
    END start

You must change the file path.
Please, forgive my mistakes.

Cheers.

untio 36 Light Poster

Hi,
Can you give a test to this code:

.286
.model small

.stack 1024h
.code

start:
    mov cx, 5
first:
    mov bl, 2ah
    mov bh, 1
    call    drawall
    loop    first

    mov dx, 5
second:
    mov bl, 20h
    mov bh, 0
    mov cx, dx
    call    drawall
    mov cx, 6
    sub cx, dx
    mov bl, 2ah
    mov bh, 1
    call    drawall
    dec dx
    jnz second
    mov ax, 4c00h
    int 21h


drawall:
    push    ax
    push    bx
    push    cx
    push    dx
drawone:
    mov     ah,2h
    mov     dl,bl
    int     21h
    loop    drawone
    or  bh, bh
    jz  retorn
    mov     dl,0Ah
    int     21h
    mov dl,0Dh
    int 21h
retorn:
    pop dx
    pop cx
    pop bx
    pop ax
    ret

    end start

Please, forgive me if I am wrong.

Cheers.

untio 36 Light Poster

Hi,
Well, it is the kind of bug that is repeated again and again.
Look at these lines:

mov dx, offset s1
int 21h
jc readError
openError:
mov ah, 09h

The program opens the file. The program reads the file and after "jc readError" it simply continues with the next line that is: "openError:" mov ah, 09h...
This can be solved simply adding after "jc readError" a simple "jmp someplaceafteropenerrorandreaderror".

Cheers.

untio 36 Light Poster

Hi once more,

The problem solves writing setResizable(false) before pack().

And this solution works in the two versions (awt and swing).

Thanks once more.

untio 36 Light Poster

Hi once more.

The problem is not solved at all. It seemed to work in the swing version because into it there is not this line:

setResizable(false);

When I add this line to the swing version the behaviour is the same.

And, when I comment the line in the first version it runs nice.

Is there another method to achieve this result?

Thanks once more.

untio 36 Light Poster

Hi James,

you were right. I have writen the swing version (or so I believe) and it runs nice.

This is the new code (with a lot of copy and paste):

import javax.swing.JFrame;
import javax.swing.JPanel;

import java.util.GregorianCalendar;
import java.util.TimerTask;
import java.util.Timer;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;


public class SimpleClock2 extends JFrame{

    private MiPanel jp;
    private Timer mt;

    private void dibujaAgujas(Graphics2D g) {
        GregorianCalendar cal = new GregorianCalendar();
        int seg, x;
        double cx,cy, an;
        seg = cal.get(GregorianCalendar.SECOND);
        seg *= 6;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        cy = Math.sin(an) * 170.0;
        cx = Math.cos(an) * 170.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(255, 0, 0));
        g.setStroke(new BasicStroke(2));
        g.drawLine(201, 201, (int) cx, (int) cy);


        seg = cal.get(GregorianCalendar.MINUTE);
        x = seg;
        seg *= 6;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        cy = Math.sin(an) * 155.0;
        cx = Math.cos(an) * 155.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(0, 255, 0));
        g.setStroke(new BasicStroke(5));
        g.drawLine(201, 201, (int) cx, (int) cy);

        seg = cal.get(GregorianCalendar.HOUR);
        seg *= 30;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        an += (x / 2.0) / 180.0 * Math.PI;
        cy = Math.sin(an) * 145.0;
        cx = Math.cos(an) * 145.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(0, 0, 255));
        g.setStroke(new BasicStroke(8));
        g.drawLine(201, 201, (int) cx, (int) cy);


    }

    private void dibujaCirculosUnaVez(Graphics2D g, int incr, int radi, Color col) {
        int x;
        double an, cx, cy;
        for(x = 0; x < 360; x += incr) …
untio 36 Light Poster

Well,

Another day I will try to write the swing version.

May be you are right (I think so). May be in the recent JVM the use of awt is superceeded.

Thanks,

Cheers.

untio 36 Light Poster

Hi,

First, thanks James.

I have tried changing the code to use only awt. Another day I will try with swing.

The problem persist. The only diference is that now the extra space is white. With the old version it was grey. Here is the current code:

import java.awt.Frame;
import java.util.GregorianCalendar;
import java.awt.image.BufferedImage;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.util.TimerTask;
import java.util.Timer;
import java.awt.BasicStroke;

public class SimpleClock extends Frame {

    private BufferedImage bi;
    private Graphics2D g;
    private Timer mt;
    private MiCanvas mican; 

    private void dibujaAgujas(Graphics2D g) {
        GregorianCalendar cal = new GregorianCalendar();
        int seg, x;
        double cx,cy, an;
        seg = cal.get(GregorianCalendar.SECOND);
        seg *= 6;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        cy = Math.sin(an) * 170.0;
        cx = Math.cos(an) * 170.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(255, 0, 0));
        g.setStroke(new BasicStroke(2));
        g.drawLine(201, 201, (int) cx, (int) cy);


        seg = cal.get(GregorianCalendar.MINUTE);
        x = seg;
        seg *= 6;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        cy = Math.sin(an) * 155.0;
        cx = Math.cos(an) * 155.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(0, 255, 0));
        g.setStroke(new BasicStroke(5));
        g.drawLine(201, 201, (int) cx, (int) cy);

        seg = cal.get(GregorianCalendar.HOUR);
        seg *= 30;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        an += (x / 2.0) / 180.0 * Math.PI;
        cy = Math.sin(an) * 145.0;
        cx = Math.cos(an) * 145.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(0, 0, 255));
        g.setStroke(new BasicStroke(8));
        g.drawLine(201, 201, (int) cx, (int) cy);


    }

    private …
untio 36 Light Poster

Hi,

First, thanks for reading this stuff.

I am learning java. I recognize that I am a beginner. Last weekend I have coded a clock. Sourcecode is:

import javax.swing.JFrame;
import java.util.GregorianCalendar;
import java.awt.image.BufferedImage;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.util.TimerTask;
import java.util.Timer;
import java.awt.BasicStroke;

public class SimpleClock extends JFrame {

    private BufferedImage bi;
    private Graphics2D g;
    private Timer mt;
    private MiCanvas mican; 

    private void dibujaAgujas(Graphics2D g) {
        GregorianCalendar cal = new GregorianCalendar();
        int seg, x;
        double cx,cy, an;
        seg = cal.get(GregorianCalendar.SECOND);
        seg *= 6;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        cy = Math.sin(an) * 170.0;
        cx = Math.cos(an) * 170.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(255, 0, 0));
        g.setStroke(new BasicStroke(2));
        g.drawLine(201, 201, (int) cx, (int) cy);


        seg = cal.get(GregorianCalendar.MINUTE);
        x = seg;
        seg *= 6;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        cy = Math.sin(an) * 155.0;
        cx = Math.cos(an) * 155.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(0, 255, 0));
        g.setStroke(new BasicStroke(5));
        g.drawLine(201, 201, (int) cx, (int) cy);

        seg = cal.get(GregorianCalendar.HOUR);
        seg *= 30;
        seg += 270;
        an = (seg / 180.0) * Math.PI;
        an += (x / 2.0) / 180.0 * Math.PI;
        cy = Math.sin(an) * 145.0;
        cx = Math.cos(an) * 145.0;
        cy += 201;
        cx += 201;
        g.setColor(new Color(0, 0, 255));
        g.setStroke(new BasicStroke(8));
        g.drawLine(201, 201, (int) cx, (int) cy);


    }

    private void dibujaCirculosUnaVez(Graphics2D g, int incr, int radi, Color col) {
        int x;
        double an, cx, cy;
        for(x = 0; x …
untio 36 Light Poster

Hi,

I have neither used into. A have found this:

Click Here

Cheers.

untio 36 Light Poster

Hi,
First, I am a beginner java programmer.
I see in the paths of the files first // and after that ///
I think that this can be wrong.

Forgive me if I am wrong.

Cheers.

untio 36 Light Poster

Hi,
I think that it can be useful an example from Microsoft:
Click Here

Cheers.

untio 36 Light Poster

Please, forgive me,

I was confused. The solution is about objAcc[i] = new Account(Your parameters) inside the loop, not the first one (objAcc[i].Som...).

I mixed in my head C++ and Java.

Sorry.

untio 36 Light Poster

Hi,

I think that in these lines:

Account[] objAcc = new Account[10];
for(int i=0;i<10;i++){
new Account(i,100);
}

You create an array of Account, but inside the for loop you are creating once more ten Account variables that you don't assign. Maybe you want to use inside the for loop something like objAcc[i].SOMEMETHODOFTHEACCOUNTCLASS(). Or assign the created Account to some place of the array. Something like objAcc[i] = new Account()

untio 36 Light Poster

Hi,

First, visit this page:

Click Here

Now you employ the 09h to invite the user to press a key.

You employ service 01h to read a character

You test what is the character and employ the 09h with the apropiate message.

Please, forgive me if I am wrong.

Cheers.

untio 36 Light Poster

Hi,
May be, os.system() is useful to you:
Click Here
Forgive me if I am wrong.

untio 36 Light Poster

Hi,
G_Waddell is right.
Form2.textbox1.text = Cstr(Val(Form2.textbox1.Text) - 1)
Cheers.

untio 36 Light Poster

Hi,
The code in this place:
Click Here
Can be of some help.
Cheers.

untio 36 Light Poster

Hi,
I think that you need to change
var c=document.getElementById("myCanvas");
Into
var c=document.getElementById("canvas1");
myCanvas for canvas1.
canvas1 is the id that you have done to it.

untio 36 Light Poster

Hi,
What you need can be achieved with html or with css.
You can employ the answer of JorgeM. I believe that nowadays css is preferred to html for styles.
Cheers.

untio 36 Light Poster

Hi,
I don't understand your question very well, but I think that you need a public variable in every form from 1 to 4. You assign the value of input and you get its value from form 5 with a form1.yourvariable.
Please, forgive me if I'm wrong.

untio 36 Light Poster

Hi,
I think that this is a html problem. You can look at:
Click Here
To resize the text in the paragraph.
Please, forgive me if I am wrong.

untio 36 Light Poster

Hi,
1. If you like, you could use a macro to call range and border. Something like:
macro mymacro x, y, b
range x, y
border b
endm
Saving a lot of writing. But I think that your code can be shorter with some loops.
2.You have started the calculator. Now you may enter in a loop that checks if an apropiate key have been pressed or if the apropiate mouse button have been pressed in the correct place. Your loop ends with the apropiate action, may be the esc key.
If you need reading about interrupts, try this link:
Click Here
Best regards.

untio 36 Light Poster

Hi,
You have my source code of a win32 calendar written with masm32 at:
Click Here
Cheers.

untio 36 Light Poster

Hi,
First, forgive my possible errors.
In your code there are a lot of calls to the range macro and after that an "mov ah, 09", a lea instruction and a call to an interrupt.
I know that sometimes some of these is not present, but you could create another macro with another parameter that simply calls range, executes "mov ah, 09", the lea instruction and the call to the interrupt.
When necessary, you employ the new macro and in the other places, you employ range.
Once more, forgive my mistakes.

untio 36 Light Poster

Hi,
I am learning php as probably you. I think that you need to use sprintf to format the string after LIKE. See:
Click Here
Please, forgive me if I am wrong.

untio 36 Light Poster

Hi,

Please, forgive me if I am wrong, but if you use another register instead of 8, you can increment it adding it 8.

mov r13, 0 
mylabel:
mov qword [r14+r13], rsi
add r13, 8
cmp r13, YourArrayLimitMultipliedBy8
jb mylabel

But you must realize that in this loop rsi never changes.

Cheers.

untio 36 Light Poster

Hi,
If you are coding with Visual C++, then may be UNICODE is defined.

You can try if I am right adding this two lines before any other one:

#undef UNICODE
#undef _UNICODE

And, after that the rest of the code.

Cheers.

untio 36 Light Poster

You need to realize that in this code:

cmp eax,minVal

jge Loop_stat

a greater than minVal will cause a jump to Loop_stat and it will never be compared with maxVal.

Cheers.

untio 36 Light Poster

Hi,
You can use: CMPEQPS
And to test if the result is all ones or zeros: MOVMSKPS.
I hope that this can be useful.

Please, forgive me. I have not read the number version of sse in the post.

untio 36 Light Poster

Hi,
Thanks in advance for reading this message.
My problem is that I need to write a program that must list the pdf files in a folder that contain a text pattern.
The user writes a text and the program list the files that contain the pattern.
I know that there are a lot of free libraries that work with pdf files, but I have not tried none.
Can you recommend me some free library.
Thanks a lot.

untio 36 Light Poster

Hi,
Please, forgive me if I am wrong, but I think that in the next part of your code:
getint:
popl %ebp
movl %esp, %ebp
movl $1, %edi
call getinpos
You really want to write at the first line:
pushl %ebp

I am wrong?

untio 36 Light Poster

Please forgive me if I am wrong:
I use intel sintax and may be I am wrong.
At this line:
leal values(, %edi,4), %esi
If it translate to intel sintax:
lea esi, [values + edi*4]
Or something like this, you need to realize that "EDI" has a random value.
May be you need to init it.
And at lines:
dec %ebx
addl $4, %esi
jnz loop
You really want to write:
addl $4, %esi
dec %ebx
jnz loop
Because:
addl $4, %esi
Changes the flags.
And forgive if I am wrong.

untio 36 Light Poster

Hi,

I have modified a little your code. It still does not work, but you can learn some things. I will correct your code, but I won't write your program:

#include<stdio.h>
#include<string.h>
#include<ctype.h> 
int main()
{
      char org[50],r[50],m[50],a;
      int i,j,c=0,length=0,h=0,g=0,z;
      char token [3] [20] = { "void", "main", "int"};
      printf("\nenter a line:");
	//gets READS A COMPLETE LINE. IF org HAS PLACE FOR 50 bytes AND THE USER WRITES MORE THAN 50 BYTES
	//THEN IT WRITES BEYOND THE ROOM. THIS ENDS WITH A RUN TIME ERROR.
      fgets(org, 50, stdin);
	//FGETS READ UP TO 50 CHARACTERS FROM THE STREAM stdin (STANDARD INPUT) AND
	//SAVES THEM ON org. IF THE USER WRITES MORE THAN 50 CHARACTERS ONLY 50 ARE WRITTEN.
      for(i=0;org[i]!='\0';i++)
      {
      length++;
      }
      for(h=0;h<3;h++)
       {
         for(g=0;g<length;g++)
         {     
	  //I HAVE MODIFIED THE NEXT LINE. LOOK AT THE &.
	  //org IS A POINTER TO THE FIRST CHARACTER OF THE STRING
	  //&org[2] IS A POINTER TO THE THIRD CHARACTER OF THE STRING
	  //&org[n] IS A POINTER TO THE n + 1 th CHARACTER OF THE STRING
	  //org[2] IS THE THIRD CHARACTER OF THE STRING
          z=strcmp(&org[g],token [h]);                      
          if(z==0)
          printf("Keyword:%s\n\n",m);
          else
          printf("NO_Keyword:%s\n\n",m);
         }
       }

 	printf("\n");      
      getchar();
      return 0;
}
untio 36 Light Poster

Hello,
You need realize that if you enter the line:
void main
You compare every token with the line:
"main" with "void main"
and
"void" with "void main"
And them will be always different.
You need to isolate the tokens inside the string.
I hope that this can be useful.

untio 36 Light Poster

Thanks a lot for you answers. I am just starting with JavaScript and I think that Aptana is great for my needs.
Thanks once more.

untio 36 Light Poster

Hi,
I am starting to learn JavaScript. But now I need a good IDE to code.
Obviously I need a free IDE, I am not planning to make money with my code.
Can experts give me some advice.
Thanks in advance.

untio 36 Light Poster

Hi once more,

You can compare your code with the next one:

#include <stdio.h>
#include <stdlib.h>

extern "C" void getlarge(unsigned char *number1, unsigned  char *number2, unsigned  char *result);
int main(int argc, char *argv[])
{
  unsigned char number1[256];
  unsigned char number2[256];
  unsigned char result[256];
  getlarge(number1, number2, result);
  printf("done,\n 1 = %s,\n 2 = %s\n", number1, number2);
  system("PAUSE");	
  return 0;
}

And obviously, the assembly code:

.section .data
numberone:
          .ascii "Enter first number: \n"
          .byte 00
numbertwo:
          .ascii "Enter second number: \n"
          .byte 00
formatstr:
          .ascii  "%s"
          .byte 00
.text
          .align 4

.global _getlarge
_getlarge:
          pushl %ebp
          movl %esp, %ebp
          call _getnumberone
          call _getnumbertwo
          movl %ebp, %esp
          popl %ebp
          ret

.global _getnumberone
_getnumberone:
    pushl %ebp
    movl %esp, %ebp
    pushl $numberone
    call _printf
    addl $4, %esp
    movl 16(%ebp), %ecx
    pushl %ecx
    pushl $formatstr
    call _scanf
    addl $8, %esp
    movl %ebp, %esp
    popl %ebp
    ret
    
.global _getnumbertwo
_getnumbertwo:
    pushl %ebp
    movl %esp, %ebp
    pushl $numbertwo
    call _printf
    addl $4, %esp
    movl 20(%ebp), %ecx
    pushl %ecx
    pushl $formatstr
    call _scanf
    addl $8, %esp
    movl %ebp, %esp
    popl %ebp
    ret

Keep in mind that every 'call' decrements esp by 8 bytes.

Cheers.

untio 36 Light Poster

Hi,
This time more seriously.
Your program is very very useful to learn many things about inline assembly. Indeed very useful. Here is the corrected version:

#include <stdio.h>

#define SZ 7



int* a[SZ];
int x, y, z;

void populate() {

  x = 1;
  y = 2;
  z = 3;
  a[0] = &x;
  a[1] = &y;
  a[2] = &z;
  a[3] = a[0];
  a[4] = a[1];
  a[5] = a[2];
  a[6] = a[3];
}
void printall() 
{
    int i;
  for( i = 0; i < SZ; i++) 
  {
    printf("a[%1d]=%1d, ", i, *(a[i]));
  }
  printf("x=%1d, y=%1d, z=%1d\n", x, y, z);
}

void add1each(int *a[SZ])
{
 __asm__("\
    movl    8(%ebp), %ecx\n\
	subl	$23, %esp\n\
	movl	$0, -4(%ebp)\n\
	jmp	compare\n\
    increment:\n\
	movl	-4(%ebp), %eax\n\
	movl	(%ecx,%eax,4), %eax\n\
	movl	-4(%ebp), %edx\n\
	movl	(%ecx,%edx,4), %edx\n\
	movl	(%edx), %edx\n\
	addl	$1, %edx\n\
	movl	%edx, (%eax)\n\
	addl	$1, -4(%ebp)\n\
    compare:\n\
	cmpl	$6, -4(%ebp)\n\
	jle	increment\n\
	addl   $23, %esp\n\
	");
}

int main(int argc, char* argv[]) {
  populate();
  printall();
  add1each(a);
  printall();
  getchar();
  return 0;
}

As you can see, in my version of the procedure, there is no the definition of an stack frame. This was your error. And I have learned the truth thanks to you.
The C compiler creates an stack frame. If you saw the assembly output, the pop with ebp and the assignation of esp to ebp happened twice. And likewise with the return code.

Do not care about my previous post. And thank you. I have learned something new thanks to you.

untio 36 Light Poster

Hi,
I was wrong. Actualy there are two calls.
Inside _getlarge the first parameter is at ebp+8 (return segment and offset)
Inside _getnumbertwo the first parameter passed to _getlarge is at ebp+16. (return segment and offset of _getlarge and return segment and offset of _getnumbertwo).
In a call instruction the segment and the offset of the return address are pushed on the stack.
Remenber to correct _getnumberone also.
And I remenber to you that with the C calling convention you can change inside your procedure only eax, ecx and edx. The rest of register must be preserved, with push and pop.
Cheers.

untio 36 Light Poster

Hi,
I do not work with at&t syntax but I believe that:

movl $0, -4(%ebp)\n\ --You move zero to the first 4 bytes of local space.

jmp compare\n\
increment:\n\
movl -4(%ebp), %eax\n\ --You move to eax the value inside the first 4 bytes of local space (zero):
movl a(,%eax,4), %eax\n\ --You move to eax the content of the address pointed for eax. eax has the value zero. You are trying to read at the memory address zero (null pointer) == Memory error == Program crashes

Cheers.

untio 36 Light Poster

Hi,
When you press a special key, you get first a key code with the value 0 (zero). Inmediately you read the second part of the code. I believe that for the arrow up key it is 72. The same issue applies to combinations of standard keys and Control and Alt. Simply there are two values inside the buffer. At least this worked with MSDOS.
Cheers.

untio 36 Light Poster

Hi,
Please, can you tell me what are you looking for reading the stack. You must realize that inside the stack with the parameters there are the returning addresses of your procedures (segment and offset 8 bytes) and you call one procedure from another one that is called from a C function (3 calls * 8 bytes). If you want access to the parameters, you can add to esp the required value and call your procedure (restoring esp).
Cheers.