Bona Fide OS Development http://forums.osdever.net/ |
|
ASM will not assemble http://forums.osdever.net/viewtopic.php?f=6&t=57 |
Page 1 of 2 |
Author: | smeezekitty [ Fri Oct 23, 2009 2:36 am ] |
Post subject: | ASM will not assemble |
the error is Invalid effective address on this line: Code: mov di,42 data: mov ah,0x0E mov al,[bp-di] ;Error mov bl,0x0F int 0x10 dec di cmp di,0 jle stoploop cmp 0,[bp-di] jne data stoploop: |
Author: | Love4Boobies [ Fri Oct 23, 2009 4:40 am ] |
Post subject: | Re: ASM will not assemble |
There's nothing wrong with your syntax but that's not an effective address. Code: mov al, [bp+di] ; good example of an effective address Stop asking the same questions on every forum you know, you're making the Internet a much more difficult place. Cheers, Bogdan |
Author: | ctimko [ Fri Oct 23, 2009 11:51 am ] |
Post subject: | Re: ASM will not assemble |
+rep |
Author: | smeezekitty [ Fri Oct 23, 2009 12:15 pm ] |
Post subject: | Re: ASM will not assemble |
i am still getting an invalid effective address Code: mov di,42 data: mov ah,0x0E neg di mov dh,[bp+di] neg di mov al,byte [bp+dh] mov bl,0x0F int 0x10 dec di cmp di,0 jle stoploop neg di mov dh,[bp+di] neg di cmp 0,dh jne data stoploop: |
Author: | smeezekitty [ Fri Oct 23, 2009 12:36 pm ] |
Post subject: | Re: ASM will not assemble |
now i have new problems with near / far calls here is the semi working code: Code: mov di,42 data: dec di mov ah,0x0E neg di mov dh,[bp+di] neg di mov al,dh mov bl,0x0F int 0x10 cmp di,0 jle stoploop neg di mov dh,[bp+di] neg di cmp dh,0 jne data stoploop: |
Author: | ctimko [ Fri Oct 23, 2009 6:19 pm ] |
Post subject: | Re: ASM will not assemble |
So are you doing your whole OS in ASM? |
Author: | smeezekitty [ Fri Oct 23, 2009 7:48 pm ] |
Post subject: | Re: ASM will not assemble |
Quote: So are you doing your whole OS in ASM? no, this is the child test program |
Author: | Love4Boobies [ Sat Oct 24, 2009 12:58 am ] |
Post subject: | Re: ASM will not assemble |
Your code looks very... random to me. [BP+DH] is again, not an effective address. I think you should take a look at what an effective address is in the Intel manuals. While you're at it, look up the "LEA" instruction (and friends). If you want to do mathematical operations there's the normal way to do it: "ADD, INC, ADC, SUB, SBB, DEC, MUL, IMUL, DIV, IDIV". |
Author: | smeezekitty [ Sat Oct 24, 2009 1:47 am ] |
Post subject: | Re: ASM will not assemble |
this time i used a C compiler output Code: [BITS 16] GO: push bp mov bp,sp sub sp,552 push si ; ; unsigned char name[32],mode[4],buffer[512]; ; name[0]=':'; ; mov byte [bp-40],58 ; ; name[1]='p'; ; mov byte [bp-39],112 ; ; name[2]='a'; ; mov byte [bp-38],97 ; ; name[3]='s'; ; mov byte [bp-37],115 ; ; name[4]='s'; ; mov byte [bp-36],115 ; ; name[5]='w'; ; mov byte [bp-35],119 ; ; name[6]='o'; ; mov byte [bp-34],111 ; ; name[7]='r'; ; mov byte [bp-33],114 ; ; name[8]='d'; ; mov byte [bp-32],100 ; ; name[9]= 0 ; ; mov byte [bp-31],0 ; ; mode[0]='r'; ; mov byte [bp-4],114 ; ; mode[1]= 0 ; ; mov byte [bp-3],0 ; ; FILE far *jar=fopen(name, mode); ; push ss mov ax,bp sub ax,4 push ax push ss mov ax,bp sub ax,40 push ax call 0x4000:0x0C4A add sp,16 mov word [bp-6],dx mov word [bp-8],ax ; ; fread(buffer, 1, 512, jar); ; push word [bp-6] push word [bp-8] xor ax,ax mov dx,512 push ax push dx xor ax,ax mov dx,1 push ax push dx push ss mov ax,bp sub ax,552 push ax call 0x4000:0x0DFF add sp,16 ; ; fclose(jar); ; push word [bp-6] push word [bp-8] call 0x4000:0x0D39 pop cx pop cx ; ; int i = 0; ; xor si,si jmp short @1@114 @1@58: ; ; while(i < 512 && buffer[i]){ ; _AL = buffer[i]; ; mov al,byte [bp+si-552] ; ; _AH = 0xE; ; mov ah,14 ; ; _BL = 0xF; ; mov bl,15 ; ; asm {int 10h} ; int 10h @1@114: cmp si,512 jge short @1@170 cmp byte [bp+si-552],0 jne short @1@58 @1@170: ; ; } ; } ; pop si mov sp,bp pop bp retf end almost there |
Author: | Love4Boobies [ Sun Oct 25, 2009 3:01 am ] |
Post subject: | Re: ASM will not assemble |
I know a C compiler output when I see it. I also know a bad assembly programmer when I see his/her code. Even if we'd all be using 8-bit CPUs that would still be the crappiest way to set up a string. There are several better solutions:
You will never be able to write an OS is you skip the learning stage. And you certainly don't learn how to write an OS along the way, as is commonly believed. Take a thorough look at the Intel manuals. Try coding some simple assembly applications first, perhaps even read a book on the subject. That will get you up and going in no time. Cheers, Bogdan |
Page 1 of 2 | All times are UTC - 6 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |