flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Comand Line Start Goto page 1, 2, 3, 4 Next |
Author |
|
sylwek32 07 Oct 2006, 01:33
what isnt working?
|
|||
07 Oct 2006, 01:33 |
|
smiddy 07 Oct 2006, 02:13
I can only surmize from your code that selector/segment 10h is a linear address, otherwise you may be pointing to somewhere off of your base address, assuming you used and MZ executeable from DOS, you could be writting to somewhere outside of the video text frame buffer. I am curious why you are incrementing AX prior to the jmp cmdloop, why is that?
Give me more information... |
|||
07 Oct 2006, 02:13 |
|
Niels 07 Oct 2006, 15:20
Hello rhyno_dagreat,
Did you remap the PIC and start the timer interrupt on 20? The first 32 (0-31) interrupts are 'reserved' for processor 'things' (faults/exceptions). When pressing the keyboard, the particular ISR will be started. Don't forget the iret with the ISR and the EOI(EndOfInterrupt) for PIC-ints. Niels. ps. I did not speak about the particular function above...You say int21 puts scancode in al and on the next line you count keyboard+scancode... |
|||
07 Oct 2006, 15:20 |
|
Dex4u 07 Oct 2006, 15:24
Having a second look shows that the int 21h is your own function, ( as in does not need a function number to go with it, as there is none, as AX is distroyed ).
First thing is you need to do is uneyelight the " ;mov [ScanCode], al" part, for it to work. I would agree with smiddy as in why do you inc AX ?. But we need to know what it does when you test it. |
|||
07 Oct 2006, 15:24 |
|
Niels 07 Oct 2006, 16:30
@Dex4u, It seems to me, the goal of the function is catch keyboard-int information and print the incoming characters to screen.
|
|||
07 Oct 2006, 16:30 |
|
Dex4u 07 Oct 2006, 17:08
Niels wrote: @Dex4u, It seems to me, the goal of the function is catch keyboard-int information and print the incoming characters to screen. I was meaning more in what error does he get, eg: crashs, wrong ASCII etc |
|||
07 Oct 2006, 17:08 |
|
Niels 07 Oct 2006, 17:53
@Dex4u, I guess no errors, I sense the function CmdPrintFunc is not hailed anywhere.
|
|||
07 Oct 2006, 17:53 |
|
rhyno_dagreat 07 Oct 2006, 22:21
Geeze, I'm sorry I didn't elaborate on it sooner. I was half asleep when I posted. Neils is right about what it's supposed to do, basically get a scancode from the keyboard, and the value of the scancode is added to the starting byte of the KeyBoard array to put on the key needed (I.E., the scancode 2 is grasped, so 2 is added to the starting memory address of KeyBoard to get "1".) It's not giving any errors with the code I have so far. Basically it does nothing though, and I did call it. Also, the inc AX was from the previous function that I copied that function from which I forgot to delete that line .
Sorry for not getting back at you all sooner, and I hope you all can help and thanks for your input so far! |
|||
07 Oct 2006, 22:21 |
|
rugxulo 08 Oct 2006, 02:21
This:
Code: KeyBoard db 0, 0, "1", "2", "3", "4" ... would look much nicer (IMO) as ... Code: KeyBoard db 0,0,'1234' Plus, that line in your source code wouldn't be as long. |
|||
08 Oct 2006, 02:21 |
|
rhyno_dagreat 08 Oct 2006, 20:40
Thanks, I was wondering to myself if I could do that. But nonetheless, that still doesn't fix the problem.
|
|||
08 Oct 2006, 20:40 |
|
Dex4u 08 Oct 2006, 22:37
Here a fix ver of your code, that work fine on my OS (Dex4u)
Code: ;=========================================================;; Test CmdPrintFunc 09/08/06 ;;---------------------------------------------------------;; By Dex4u. ;; ;; c:\fasm test.asm test.dex ;;=========================================================;use32 ORG 0x400000 ; where our program is loaded to jmp start ; jump to the start of program. db 'DEX1' ; We check for this, to make shore it a valid Dex4u file. ;----------------------------------------------------; ; Start of program. ; ;----------------------------------------------------;start: mov ax,18h ; set ax to nonlinear base mov ds,ax ; add them to ds mov es,ax ; and es. ;----------------------------------------------------; ; Get calltable address. ; ;----------------------------------------------------; mov edi,Functions ; this is the interrupt mov al,0 ; we use to load the DexFunction.inc mov ah,0x0a ; with the address to dex4u functions. int 40h ;----------------------------------------------------; ; Test code. ; ;----------------------------------------------------; call CmdPrintFunc ;----------------------------------------------------; ; Exit. ; ;----------------------------------------------------; ret ; This returns to the CLI/GUI ;----------------------------------------------------; ; CmdPrintFunc. ; ;----------------------------------------------------;CmdPrintFunc: push es mov ax,8h ; You should use 10h here mov es,ax mov edi, 0xB8000 ; screen pointer add edi, 0x280 ; Move 4 row down the screen xor ebx, ebx ; Make sure ebx is 0 cmdloop: call [WaitForKeyPress] ; This gets scan code in AH mov bl,ah ; Move scan code into BL cmp bl, 1Ch ; Has enter bean pressed ? je done ; Yes then jump exit mov esi,ebx mov cl, [esi+KeyBoard] mov byte [es:edi],cl inc edi mov byte [es:edi], 1Bh inc edi jmp cmdloop done: pop es ret ;----------------------------------------------------; ; Data. ; ;----------------------------------------------------;KeyBoard db 0, 0, "1", "2", "3", "4", "5", "6", "7", "8", "9"db "0", "-", "=", 0, 0, "Q", "W", "E", "R", "T", "Y", "U"db "I", "O", "P", "[", "]", 0, 0, "A", "S", "D", "F", "G"db "H", "J", "K", "L", ";", "'", "`", 0, "\", "Z", "X", "C"db "V", "B", "N", "M", ",", ".", "/", 0, "*", 0ScanCode db 0 include 'DexFunctions.inc' ; Here is where we includ our "DexFunctions.inc" file Full code for above NOTE: Needs Dex4u OS. http://www.dex4u.com/Redragon/test.zip screenshot: http://www.dex4u.com/Redragon/test.jpg |
|||
08 Oct 2006, 22:37 |
|
rhyno_dagreat 09 Oct 2006, 00:38
Thanks for the code, I'm gonna try it ASAP. But one question that I have is in your code, you have:
Code: mov cl, [esi+KeyBoard] And it (apparently, still haven't tested it) works, whereas I had Code: mov byte [ds:ebx], [Keyboard + al] and it didn't work? |
|||
09 Oct 2006, 00:38 |
|
Dex4u 09 Oct 2006, 01:14
You can not move from memory to memory
|
|||
09 Oct 2006, 01:14 |
|
rhyno_dagreat 09 Oct 2006, 03:51
Oh... Yeah... makes sense. It's like trying to take a warehouse that contains hardware and moving it to another warehouse. It's impossible for one human, and doesn't make much sense logically. So instead take the stuff inside the warehouse, load 'em up in trucks(registers) and ship 'em.
Thanks for your help! |
|||
09 Oct 2006, 03:51 |
|
Niels 09 Oct 2006, 10:42
It is possible to move memory to memory with DMA, although not advisable, too slow. It depends on the warehouse(s) size, if it could be done, even by one human.
|
|||
09 Oct 2006, 10:42 |
|
Niels 09 Oct 2006, 10:54
But fundamentally you're right; You can't put a register in a register other than passing its inner-information. You could say that mov al,5 mov ah,al uses only one 1 register ax.
|
|||
09 Oct 2006, 10:54 |
|
rhyno_dagreat 09 Oct 2006, 21:03
Hey, I tried it, and how my OS works is that it boots up and says "Press 1 to Continue", and then after that happens, it clears the screen and the command line should come up, but what happens is after I press 1 to continue, it fills the screen with 1s and then I can't accept any more input.
|
|||
09 Oct 2006, 21:03 |
|
Dex4u 10 Oct 2006, 00:19
We need to see the full code of your OS.
|
|||
10 Oct 2006, 00:19 |
|
rhyno_dagreat 10 Oct 2006, 00:28
Okay, here it goes:
rhynload.asm Code: ;BOOTSTART org 7C00h jmp start message db 'Loading RhynOS...',13,10,0 start: xor ax, ax mov ds, ax mov si, message call bios_print load_os: mov ax, 0060h mov es, ax mov bx, 0000h mov ah, 02h mov al, 5 mov ch, 0 mov cl, 2 mov dh, 0 ;mov dl, 0 ; Not sure if needed, been told that dl already contains the drive that was booted on int 13h jmp 0060h:0000h bios_print: lodsb or al, al jz done mov ah, 0x0E int 0x10 jmp bios_print done: call load_os ;BOOTEND times 510-($-$$) db 0 dw 0xAA55 rhynos.asm Code: org 0000h use16 cli mov ax, 0060h mov ds, ax add dword [gdt_descriptor+2], 600h lgdt [gdt_descriptor] mov eax, cr0 or eax, 1 mov cr0, eax jmp 08h:clear_pipe gdt: dd 0, 0 gdt_code: db 0FFh, 0FFh, 0, 0, 0, 10011010b, 11001111b, 0 gdt_data: db 0FFh, 0FFh, 0, 0, 0, 10010010b, 11001111b, 0 gdt_end: gdt_descriptor: dw gdt_end - gdt - 1 dd gdt org 0600h+$ use32 clear_pipe: mov ax, 10h mov ds, ax mov ss, ax mov esp, 090000h ;ACTUAL KERNEL CODE STARTS HERE mov si, WelMsg call PrintFunc call Reroute_PICs lidt [idtp] sti GetInput: int 0x21 cmp al, 02 je DoClrScrn jmp GetInput DoClrScrn: call ClrScrn call CmdPrintFunc ;KERNEL CODE ENDS HERE infinite_loop: jmp infinite_loop times 571-($-$$) db 0 include 'interrupts.inc' WelMsg db "Welcome to RhynOS! Press 1 To Continue.", 0 interrupts.inc Code: ;INTERRUPTS!!! YAY PrintFunc: mov ax, 10h mov ds, ax mov ebx, 0B8000h strloop: lodsb mov byte [ds:ebx], al inc ebx mov byte [ds:ebx], 1Bh cmp ax, 0 je done inc ebx inc ax jmp strloop done: ret ClrScrn: mov ax, 10h mov ds, ax mov ebx, 0B8000h mov ax, 0 clrloop: cmp ax, 2000 je done mov byte [ds:ebx], ' ' inc ebx mov byte [ds:ebx], 1Bh inc ebx inc ax jmp clrloop CmdPrintFunc: mov ax, 10h mov es, ax mov edi, 0B8000h xor ebx, ebx cmdloop: int 0x21 mov bl, al cmp bl, 1Ch je done mov esi, ebx mov cl, [esi+KeyBoard] mov byte [ds:edi],cl inc edi mov byte [ds:edi], 1Bh inc edi jmp cmdloop Reroute_PICs: ;send ICW1(Interrupt Control Word1) mov al, 11h ;out PIC1, ICW1 out 20h, al ;out PIC2 ICW1 out 0A0h, al ;send ICW2 mov al, 20h ;out PIC1 + 1, IRQ0 start point out 21h, al mov al, 28h ;out PIC2 + 1, IRQ8 start point out 0A1h, al ;send ICW3 ;IRQ2 to Connection to Slave PIC mov al, 04h out 21h, al mov al, 02h out 0A1h, al ;send ICW4 mov al, 01h out 21h, al out 0A1h, al ;disable IRQs mov al, 0FFh out 021h, al ret isr0: pusha push gs push fs push ds push es mov si, Err00 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr1: pusha push gs push fs push ds push es mov si, Err01 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr2: pusha push gs push fs push ds push es mov si, Err02 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr3: pusha push gs push fs push ds push es mov si, Err03 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr4: pusha push gs push fs push ds push es mov si, Err04 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr5: pusha push gs push fs push ds push es mov si, Err05 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr6: pusha push gs push fs push ds push es mov si, Err06 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr7: pusha push gs push fs push ds push es mov si, Err07 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr8: pusha push gs push fs push ds push es mov si, Err08 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr9: pusha push gs push fs push ds push es mov si, Err09 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr10: pusha push gs push fs push ds push es mov si, Err10 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr11: pusha push gs push fs push ds push es mov si, Err11 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr12: pusha push gs push fs push ds push es mov si, Err12 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr13: pusha push gs push fs push ds push es mov si, Err13 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr14: pusha push gs push fs push ds push es mov si, Err14 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr15: pusha push gs push fs push ds push es mov si, Err15 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr16: pusha push gs push fs push ds push es mov si, Err16 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr17: pusha push gs push fs push ds push es mov si, Err17 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr18: pusha push gs push fs push ds push es mov si, Err18 call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr19: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr20: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr21: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr22: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr23: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr24: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr25: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr26: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr27: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr28: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr29: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr30: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret isr31: pusha push gs push fs push ds push es mov si, ErrRes call PrintFunc cli hlt pop es pop ds pop fs pop gs popa iret irq0: mov si, TimerEnabled call PrintFunc iret irq1: in al, 60h iret idt_start: ;Interrupt Example ; dw start_address ; dw code_selector where ISR is being held ; dw type_settings for ISRs ; dw start_address2(bits 31-16) ; start_address2 should be 0 because the ; start address should be no more than 1 ; word value. ;FOR HISTORIC REFERENCE PURPOSES ONLY ;Original ISRS looked like the following ; ;dw 0x0000 ;dw 0x08 ;dw 0x8E00 ;dw 0x08 ; ;END OF HISTORIC REFERENCE ;SERVICE REQUEST INTS ;int0 dw isr0 dw 0x08 dw 0x8E00 dw 0x0 ;int1 dw isr1 dw 0x08 dw 0x8E00 dw 0x0 ;int2 dw isr2 dw 0x08 dw 0xE00 dw 0x0 ;int3 dw isr3 dw 0x08 dw 0x8E00 dw 0x0 ;int4 dw isr4 dw 0x08 dw 0x8E00 dw 0x0 ;int5 dw isr5 dw 0x08 dw 0x8E00 dw 0x0 ;int6 dw isr6 dw 0x08 dw 0x8E00 dw 0x0 ;int7 dw isr7 dw 0x08 dw 0x8E00 dw 0x0 ;int8 dw isr8 dw 0x08 dw 0x8E00 dw 0x0 ;int9 dw isr9 dw 0x08 dw 0x8E00 dw 0x0 ;int10 dw isr10 dw 0x08 dw 0x8E00 dw 0x0 ;int11 dw isr11 dw 0x08 dw 0x8E00 dw 0x0 ;int12 dw isr12 dw 0x08 dw 0x8E00 dw 0x0 ;int13 dw isr13 dw 0x08 dw 0x8E00 dw 0x0 ;int14 dw isr14 dw 0x08 dw 0x8E00 dw 0x0 ;int15 dw isr15 dw 0x08 dw 0xE00 dw 0x0 ;int16 dw isr16 dw 0x08 dw 0xE00 dw 0x0 ;int17 dw isr17 dw 0x08 dw 0xE00 dw 0x0 ;int18 dw isr18 dw 0x08 dw 0xE00 dw 0x0 ;int19 dw isr19 dw 0x08 dw 0xE00 dw 0x0 ;int20 dw isr20 dw 0x08 dw 0xE00 dw 0x0 ;int21 dw isr21 dw 0x08 dw 0xE00 dw 0x0 ;int22 dw isr22 dw 0x08 dw 0xE00 dw 0x0 ;int23 dw isr23 dw 0x08 dw 0xE00 dw 0x0 ;int24 dw isr24 dw 0x08 dw 0xE00 dw 0x0 ;int25 dw isr25 dw 0x08 dw 0xE00 dw 0x0 ;int26 dw isr26 dw 0x08 dw 0xE00 dw 0x0 ;int27 dw isr27 dw 0x08 dw 0xE00 dw 0x0 ;int28 dw isr28 dw 0x08 dw 0xE00 dw 0x0 ;int29 dw isr29 dw 0x08 dw 0xE00 dw 0x0 ;int30 dw isr30 dw 0x08 dw 0xE00 dw 0x0 ;int31 dw isr31 dw 0x08 dw 0xE00 dw 0x0 ;HARDWARE INTERRUPT REQUESTS ;int32 dw irq0 dw 0x08 dw 0x8E00 dw 0x0 ;int33 dw irq1 dw 0x08 dw 0x8E00 dw 0x0 idt_end: idtp: dw idt_end - idt_start - 1 dd idt_start TimerEnabled db "Timer Interrupt Enabled!", 0 Err00 db "Error 00 - Division By Zero",0 Err01 db "Error 01 - Debug",0 Err02 db "Error 02 - Non Maskable Interrupt",0 Err03 db "Error 03 - Breakpoint Exception",0 Err04 db "Error 04 - Into Detected Overflow",0 Err05 db "Error 05 - Out of Bounds",0 Err06 db "Error 06 - Invalid Opcode",0 Err07 db "Error 07 - No Coprocessor",0 Err08 db "Error 08 - Double Fault",0 Err09 db "Error 09 - Coprocessor Segment Overrun",0 Err10 db "Error 10 - Bad TSS",0 Err11 db "Error 11 - Segment Not Present",0 Err12 db "Error 12 - Stack Fault",0 Err13 db "Error 13 - General Protection Fault",0 Err14 db "Error 14 - Page Fault",0 Err15 db "Error 15 - Unknown Interrupt",0 Err16 db "Error 16 - Coprocessor Fault",0 Err17 db "Error 17 - Alignment Check",0 Err18 db "Error 18 - Machine Check",0 ErrRes db "Error - Reserved",0 KeyBoard db 0, 0, "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", 0, 0, "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", 0, 0, "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "`", 0, "\", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", 0, "*", 0 ScanCode db 0 |
|||
10 Oct 2006, 00:28 |
|
Goto page 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.