Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Other Discussion / Re: Forum is problematic with UNICODE?
« Last post by Winifred58 on February 01, 2023, 06:57:19 AM »
Why it is problematic? explain. Family Mobile Login
12
Other Discussion / Forum is problematic with UNICODE?
« Last post by fredericopissarra on January 31, 2023, 11:02:18 AM »
I've noticed that if I try to post something using some UNICODE encoded chars an error occurs (it now allow me to post and when I'm back to edit the message I'm now allowed to post again (the Post buton don't work until I refersh the page)...

Just saying...
13
Programming with NASM / Re: keyboard input and assembler
« Last post by fredericopissarra on January 31, 2023, 10:59:29 AM »
Your english is very good! And, hey, I'm not from an english speaking country as well (Brazil).

Your OS is one of those where you jump to graphics mode? Is so it can be "easy" to implement UNICODE. In theory, you could have 2M characters in a "font". But I suggest you don't try to implement surrogates and composition just yet. This can give you almost 64K chars (a little bit less due to surrogates codepoints range -- you'll see).

If you want to implement your own single byte charset, you could create an array mapping a byte to a group of them, like this:
Code: [Select]
unsigned char font[256][16] = {
...
 { /* ASCII: 54 */
    0x00, /* ········ */
    0x00, /* ········ */
    0x38, /* ··***··· */
    0x60, /* ·**····· */
    0xc0, /* **······ */
    0xc0, /* **······ */
    0xfc, /* ******·· */
    0xc6, /* **···**· */
    0xc6, /* **···**· */
    0xc6, /* **···**· */
    0xc6, /* **···**· */
    0x7c, /* ·*****·· */
    0x00, /* ········ */
    0x00, /* ········ */
    0x00, /* ········ */
    0x00  /* ········ */
  },
...
}
The all you need to do is draw this small "box" on screen in the appropriate video memory location.

In VGA hardware you can reconstruct the default "font" setup by the ROM-BIOS. To do this I recommend this article from OSdev. Just know that this is limited to 256 chars and their width and height depends on the text mode you are using. See Ralf Brown's Interrupt List abour service 0, interrupt 0x10, there's a list of modes and char "sizes" there.

But I would stick with graphics mode (emulating a text mode) because you can create a bigger array with bigger and better well drawn glyphs. I think the important thing is to obey some charset like UNICODE. And, of course, you'll have to make some code to decode a "fonts" file, if you want flexibility. This is another venue of research: There are (I believe) 3 types of fonts: bitmaped, vectorial and those which uses Bèzier curves (truetype, opentype etc...). The last one is a little bit complicated (but you can find the specification for those as well). For now, bitmaped fonts should be enough.

[]s
Fred
14
Programming with NASM / keyboard input and assembler
« Last post by Daniellebishop on January 31, 2023, 06:36:26 AM »
Hi, I am Daniellebishop and i have one question. I am no from English speaking country and I am making my own OS in C and assembler but when I came to printing text on screen and I want to use my characters ( that I use in my country ) I don't know how to use them because C compiler doesn't compiled it very well for my OS so it didn't work. Later i change text encoding ( to ISO 8859-2 ) it worked better but not enough - some characters it did compiled correctly and some not, and I don't know know how to fix it, I decide best way will be make own charset but I don't know how to do it. Also I need help with keyboard in C - i know that I can read input from it using port 0x60 and 0x64 but i need also recognize characters and here is my problem - using scan odes i don't know if some key on keyboard has special scan code or if special letter has own and unique scan code if first it will be easy to make function to read for example Slovak, English, American or any keyboard because special key has own scan code and doesn't depends on letters written on it but if second it will be harder because i can'f find Slovak keyboard scan codes so please help me, it is confusing me ( very very confusing )  - sorry for mistakes, because ( as I mentioned before  ) I am not from English speaking country. My Insite Employee Login
15
To build an MBR switching to i386 protected mode you don't need sections or a linker script. Here's an example (attached)...

Just make to build and make run to test (requires qemu-system-i386).
16
Greetings everyone

I was trying to convert the code of a simple VESA VBE program into the elf standard. Bin files  change my settings so here I was making a simple version to try and review. I use ld when I have to use a elf .o object and I can make the elf file run for boot.asm elf object however in my makefile I realize I can only run the bin form stage1a.bin (including the org setting). When I try to make the stage1.o elf object I keep getting the error from above. Here is my code so far


boot.asm
Code: [Select]
[BITS 16]
;[ORG 0x7c00]

_prep_module:
    xor ax,ax   
    mov ds,ax
    mov es,ax 
    mov ss,ax
    mov sp,0x7c00

DriveIdProp:
    mov [DriveId],dl
    mov ah,0x41
    mov bx,0x55aa
    int 0x13
    jc CheckProp
    cmp bx,0xaa55
    jne CheckProp

LoadProp:

mov bx,0x0000_7E00
mov cl,2
mov ah,0x02
mov al,1
mov ch,0
mov dh,0
    int 0x13
    jc  ReadCheck

    mov dl,[DriveId]
    jmp 0x7e00

ReadCheck:
CheckProp:

lea si,[Message]

Print:
lodsb
test al,al
jz .loop
mov ah,0x0E
mov bx,7
int 0x10
jmp Print


.loop:
    hlt   
    jmp .loop
   
DriveId:    db 0
Message:    db "We have an error in boot process"
MessageLen: equ $-Message
ReadPacket: times 16 db 0

;times (0x1be-($-$$)) db 0

;    db 80h
;    db 0,2,0
;    db 0f0h
;    db 0ffh,0ffh,0ffh
;    dd 1
;    dd (20*16*63-1)

;    times (16*3) db 0

;    db 0x55
;    db 0xaa

printstr.asm
[code]
bits 16


global printstr

printstr:

lodsb
test al,al
jz .done
mov ah,0x0E
mov bx,7
int 0x10
jmp printstr

.done:
ret



[/code]

stage1.asm
Code: [Select]
[BITS 16]
;[ORG 0x7E00]

modeblock: times 256 db 0

jmp LoadProp

;section .text

;modeblock: times 256 db 0

DriveIdProp:
    mov [DriveId],dl
    mov ah,0x41
    mov bx,0x55aa
    int 0x13
    jc CheckProp
    cmp bx,0xaa55
    jne CheckProp


LoadProp:

mov bx,0x0000_7E00

;check address arithmetic base
add bx,0x0200
mov cl,3

LoadLoop:
mov ah,0x02
mov al,3
mov ch,0
mov dh,0
int 0x13

;    jc  ReadCheck
cmp cl,5
inc cl

jmp VideoModule

;address zone check


Gdt32:
dq 0

Code32:
dw 0xffff
dw 0
db 0
db 0x9a
db 0xcf
db 0

Data32:
dw 0xffff
dw 0
db 0
db 0x92
db 0xcf
db 0

Gdt32Len: equ $-Gdt32

Gdt32Ptr: dw Gdt32Len-1
dd Gdt32

Idt32Ptr:
dw 0
dd 0

;jmp 0x8400

stack: times 256 dd 0
stackplacer:



VideoModule:
mov ax,0x4f01
mov cx,0x4117

VideoBuff:
mov di,modeblock
int 0x10
mov esi,[modeblock+0x28]

mov ax,0x4f02
mov bx,0x4117
int 0x10

mov ax,0x2401
int 0x15

;check address base
xor edx,edx
mov dx,cs
shl edx,4
add edx,stackplacer


SetVideoMode:

; in al,0x92
; or al,2
; out 0x92,al

cli
lgdt[Gdt32Ptr]
lidt[Idt32Ptr]
mov eax,cr0
or eax,1
mov cr0,eax
jmp 0x8:protectedMode

[bits 32]

protectedMode:
mov ax,0x10
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov esp,edx

; mov byte[0xb8000],'D'
; mov byte[0xb8001],0xa

l1:
xor eax,eax
mov edi,esi
mov ecx,1024*768*2/4
cld
rep stosd

mov eax,0x07FF07FF
mov ecx,32
mov edi,esi

l2:
push ecx
mov ecx,768*16

lines:
cld
rep stosd

mov ecx,0xFFFFFFFF
loop $

pop ecx
sub eax,0x00410041
loop 12

mov ecx,0xFFFFFFFF
loop $
jmp l1




.loop1:
    hlt   
    jmp .loop1

ReadCheck:
CheckProp:

lea si,[Message]

Print:
lodsb
test al,al
jz .loop
mov ah,0x0E
mov bx,7
int 0x10
jmp Print


.loop:
    hlt   
    jmp .loop
   
;section .data

DriveId:    db 0
LoopProp: db 0
AddressProp: dw 0x0000_8000
Message:    db "We have an error in boot process"
MessageLen: equ $-Message
ReadPacket: times 16 db 0


link.ld
Code: [Select]
* boot.ld */

/* linker script for 16 bits - mbr */
OUTPUT_FORMAT(binary)
OUTPUT_ARCH(i386)
ENTRY(_prep_module)

SECTIONS
{
  . = 0x7c00;
  _premier = .;
  _prep_module= .;

  .text : { *(.text16) *(.text) }
  .rodata : { *(.rodata) }
  .data : { *(.data) }

  . = _premier + 512-2;
  .dummy : { BYTE(0x55); BYTE(0xAA); }

  _bss_begin = .;
    .bss : { *(.bss) }
  _bss_end = .;

  _heap = .;

  /DISCARD/ : { *(.comment) *(.eh_frame) *(.note.GNU-stack) }
}

Makefile
Code: [Select]
FILES=boot.o printstr.o

all:
dd if =boot.bin of=boot.img bs=512 count=1 conv=notrunc
dd if =stage1.bin of=stage1a.img bs=512 count=3 seek=1 conv=notrunc

boot.o: boot.asm
nasm -f elf32 -o boot.o boot.asm

printstr.o:printstr.asm
nasm -f elf32 -o printstr.o printstr.asm

stage1.o: stage1.asm
nasm -f elf32 -o stage1.o stage1.asm

stage1a.bin:stage1.asm
nasm -f bin -o stage1a.bin stage1.asm

boot.bin: $(FILES)
ld -T link.ld $(FILES) -o boot.bin

stage1.bin: stage1.o
ld -g -m i386 -tText 0x7E00 -o stage1.bin  stage1.o


clean:
rm -rf boot.img
rm -rf boot.bin
rm -rf stage1.bin
rm -rf stage1.o
rm -rf stage1a.bin
rm -rf printstr.o


I'm really hoping this post can show where I do not understand and would be happy to continue the subject further. Also thank you to fredericopisarra's post from here https://forum.nasm.us/index.php?topic=2850.0 that taught me about using ld.
17
Programming with NASM / Re: why this load fails to instructions valid appear
« Last post by Frank Kotler on January 30, 2023, 08:35:22 AM »
Show the code?

Best,
Frank

18
Programming with NASM / why this load fails to instructions valid appear
« Last post by Elawig57 on January 30, 2023, 06:55:29 AM »
I recently moved to 64-bit NASM from 32-bit MASM, and I have a simple addressing problem. I am writing a DLL in NASM.  The following two lines assemble and link with the NASM assembler / GoLink, but when I try to load the DLL, I get an OS error "invalid access to memory location."  RCX contains a pointer that is passed into the DLL: mov rax,254 mov [rcx+8],rax When I try it this way, it also doesn't work. What to do? Subarunet
19
Programming with NASM / Re: Issue with Function.
« Last post by debs3759 on January 28, 2023, 06:09:17 AM »
It'll be easiest if you show us your code and tell us what OS you are targeting.
20
Programming with NASM / Issue with Function.
« Last post by Franciswalser on January 28, 2023, 05:50:07 AM »
Hello, I'm new on assembly and am having problems with a program I am trying to create. The program is supposed to accept 3 inputs from the user which include an arithmetic operation and 2 numbers. The program should then pass the three values and display the answer with a message. I am having trouble getting the program to jump properly as it would display the 2 numbers being used for all the operations and then abruptly end the program instead of just showing the operation the user picked and asking the user if they would like to do another one. Does anyone know how I can solve this problem? Thanks! TellCulvers Customer Satisfaction Survey
Pages: 1 [2] 3 4 ... 10