I'm trying to display characters on screen by calling the following function in my C code:
.global _putInMemory
;void putInMemory (int segment, int address, char character)
_putInMemory:
mov bp,sp
push ds
mov ax,[bp+2]
mov si,[bp+4]
mov cl,[bp+6]
mov ds,ax
mov [si],cl
pop ds
ret
like this:
int segment_start = 0xB000;
putInMemory(segment_start, 0x8140, 'R');
putInMemory(segment_start, 0x8141, 0x1F);
putInMemory(segment_start, 0x8142, 'A');
putInMemory(segment_start, 0x8143, 0x1F);
However, this only displays the first letter without the color, but when I specify this in the code like this, it works just fine:
putInMemory(0xB000, 0x8140, 'R');
putInMemory(0xB000, 0x8141, 0x1F);
putInMemory(0xB000, 0x8142, 'A');
putInMemory(0xB000, 0x8143, 0x1F);
I don't understand why it does not work if I store int in a variable. Is int
too small?
I'm using the bcc
compiler
Edit:
The correct code would be this:
;void putInMemory (int segment, int address, char character)
_putInMemory:
push bp
mov bp,sp
push ds
mov ax,[bp+4]
mov si,[bp+6]
mov cl,[bp+8]
mov ds,ax
mov [si],cl
pop ds
pop bp
ret