Print to VGA works with int* but not char*

I’ve been following the tutorial at https://github.com/cfenollosa/os-tutorial to create a custom 32-bit os on x86_64 asm and c, and i got to the screen drivers part which is about writing to the vga buffer to display characters on the screen from inside the kernel.
I prefer c++ so im using it instead of c, but now im getting this issue where if i use a char pointer to store a string instead of a int pointer i can’t get to display anything.

This is my main function, where i initialize the pointer and populate it with characters from A to L, which works if i use a int pointer, but not with a char one.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#define size 12
int main(){
char* ptr = (char*)0x11000FF; // int* ptr = (int*)0x11000FF works
for(int i = 0; i < size; i++){
ptr[i] = 'A'+i;
}
ptr[size+1] = '';
for(int i = 0; i < size; i++){
printChar(i,0,ptr[i]);
}
}
</code>
<code>#define size 12 int main(){ char* ptr = (char*)0x11000FF; // int* ptr = (int*)0x11000FF works for(int i = 0; i < size; i++){ ptr[i] = 'A'+i; } ptr[size+1] = ''; for(int i = 0; i < size; i++){ printChar(i,0,ptr[i]); } } </code>
#define size 12

int main(){
    char* ptr = (char*)0x11000FF; // int* ptr = (int*)0x11000FF works
    
    for(int i = 0; i < size; i++){
        ptr[i] = 'A'+i;
    }
    ptr[size+1] = '';

    for(int i = 0; i < size; i++){
        printChar(i,0,ptr[i]);
    }
}

Here is my print function

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#define VIDEO_ADDRESS 0xB8000
#define MAX_ROWS 25
#define MAX_COLS 80
#define WHITE_ON_BLACK 0x0F
#include "screen.h"
void printChar(unsigned int x, unsigned int y, char c){
char* videoMem = (char*)VIDEO_ADDRESS;
unsigned int offset = ((y*MAX_COLS + x)*2)+1;
videoMem[offset] = c;
videoMem[offset+1] = WHITE_ON_BLACK;
}
</code>
<code>#define VIDEO_ADDRESS 0xB8000 #define MAX_ROWS 25 #define MAX_COLS 80 #define WHITE_ON_BLACK 0x0F #include "screen.h" void printChar(unsigned int x, unsigned int y, char c){ char* videoMem = (char*)VIDEO_ADDRESS; unsigned int offset = ((y*MAX_COLS + x)*2)+1; videoMem[offset] = c; videoMem[offset+1] = WHITE_ON_BLACK; } </code>
#define VIDEO_ADDRESS 0xB8000
#define MAX_ROWS 25
#define MAX_COLS 80
#define WHITE_ON_BLACK 0x0F

#include "screen.h"

void printChar(unsigned int x, unsigned int y, char c){
    char* videoMem = (char*)VIDEO_ADDRESS;

    unsigned int offset = ((y*MAX_COLS + x)*2)+1;
    videoMem[offset] = c;
    videoMem[offset+1] = WHITE_ON_BLACK;
}

And here is my Makefile

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>SOURCE_DIR=source
BOOTLOADER_DIR=$(SOURCE_DIR)/bootloader
KERNEL_DIR=$(SOURCE_DIR)/kernel
BUILD_DIR=build
SRCs := $(shell find $(SOURCE_DIR) -name '*.cpp') #List of all .cpp files
OBJS := $(patsubst $(SOURCE_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCs)) #List of all c++ object files
all: folder run clean #Build from zero and wipe
run: os.iso #Start VM
qemu-system-x86_64 -drive file=$(BUILD_DIR)/$<,format=raw,index=0,media=disk
os.iso: bootloader.bin kernel.bin #Concatenate bootloader and kernel into single file
cat $(BUILD_DIR)/bootloader.bin $(BUILD_DIR)/kernel.bin > $(BUILD_DIR)/$@
bootloader.bin: $(BOOTLOADER_DIR)/bootloader.asm #Compile bootloader
nasm $< -f bin -o $(BUILD_DIR)/$@
kernel.bin: entry.o $(OBJS) #Link all object files
x86_64-elf-ld -o $(BUILD_DIR)/$@ -Ttext 0x512 $(BUILD_DIR)/$< $(OBJS) --oformat binary
entry.o: $(KERNEL_DIR)/kernelentry.asm #Compile kernel entry point
nasm $< -f elf64 -o $(BUILD_DIR)/$@
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.cpp #Generic for compiling .cpp files
g++ -c $< -o $@ -fpermissive
folder: #Create build folder
mkdir -p $(BUILD_DIR)/kernel/drivers
clean: #Wipe build folder
rm -rf $(BUILD_DIR)/*
</code>
<code>SOURCE_DIR=source BOOTLOADER_DIR=$(SOURCE_DIR)/bootloader KERNEL_DIR=$(SOURCE_DIR)/kernel BUILD_DIR=build SRCs := $(shell find $(SOURCE_DIR) -name '*.cpp') #List of all .cpp files OBJS := $(patsubst $(SOURCE_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCs)) #List of all c++ object files all: folder run clean #Build from zero and wipe run: os.iso #Start VM qemu-system-x86_64 -drive file=$(BUILD_DIR)/$<,format=raw,index=0,media=disk os.iso: bootloader.bin kernel.bin #Concatenate bootloader and kernel into single file cat $(BUILD_DIR)/bootloader.bin $(BUILD_DIR)/kernel.bin > $(BUILD_DIR)/$@ bootloader.bin: $(BOOTLOADER_DIR)/bootloader.asm #Compile bootloader nasm $< -f bin -o $(BUILD_DIR)/$@ kernel.bin: entry.o $(OBJS) #Link all object files x86_64-elf-ld -o $(BUILD_DIR)/$@ -Ttext 0x512 $(BUILD_DIR)/$< $(OBJS) --oformat binary entry.o: $(KERNEL_DIR)/kernelentry.asm #Compile kernel entry point nasm $< -f elf64 -o $(BUILD_DIR)/$@ $(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.cpp #Generic for compiling .cpp files g++ -c $< -o $@ -fpermissive folder: #Create build folder mkdir -p $(BUILD_DIR)/kernel/drivers clean: #Wipe build folder rm -rf $(BUILD_DIR)/* </code>
SOURCE_DIR=source
BOOTLOADER_DIR=$(SOURCE_DIR)/bootloader
KERNEL_DIR=$(SOURCE_DIR)/kernel
BUILD_DIR=build

SRCs := $(shell find $(SOURCE_DIR) -name '*.cpp')   #List of all .cpp files
OBJS := $(patsubst $(SOURCE_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCs)) #List of all c++ object files

all: folder run clean #Build from zero and wipe

run: os.iso #Start VM
    qemu-system-x86_64 -drive file=$(BUILD_DIR)/$<,format=raw,index=0,media=disk

os.iso: bootloader.bin kernel.bin #Concatenate bootloader and kernel into single file
    cat $(BUILD_DIR)/bootloader.bin $(BUILD_DIR)/kernel.bin > $(BUILD_DIR)/$@

bootloader.bin: $(BOOTLOADER_DIR)/bootloader.asm #Compile bootloader
    nasm $< -f bin -o $(BUILD_DIR)/$@

kernel.bin: entry.o $(OBJS) #Link all object files
    x86_64-elf-ld -o $(BUILD_DIR)/$@ -Ttext 0x512 $(BUILD_DIR)/$< $(OBJS) --oformat binary 

entry.o: $(KERNEL_DIR)/kernelentry.asm #Compile kernel entry point
    nasm $< -f elf64 -o $(BUILD_DIR)/$@

$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.cpp #Generic for compiling .cpp files
    g++ -c $< -o $@ -fpermissive

folder: #Create build folder
    mkdir -p $(BUILD_DIR)/kernel/drivers

clean: #Wipe build folder
    rm -rf $(BUILD_DIR)/*

I would expect for these two to do the same, since they are both being casted into a char when passed into the printChar function, and data size in memory shouldn’t matter since they are being passed into it by index.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật