flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
axlucas 14 Aug 2015, 21:40
Ha, ha! Found it! I thought "dp" was the size of a pointer, that is, either 32 or 64 bit depending on the architecture, but it's 48 bit (16 bit for a segment and 32 bit for a 32 bit offset). I replaced it with dq and it works fine, except that there's a one pixel offset I still don't know why, but I guess I'm about to figure out. Anyway, comments are appreciated!
|
|||
![]() |
|
SeproMan 15 Aug 2015, 19:30
Glad you found the solution for the dp directive yourself.
You wrote the following: Code: add rdx, rbx mov rbp, [rdx] sub rdx, rbx Might I suggest this simplification: Code: mov ebp, [rdx + rbx] If you want you can shave off the pushing and popping of the RBP register through using: Code: mov ebx, [rdx + rbx] Please note that I changed the destination register to 32 bits because that's where the error in your program lies! You need only 32 bits to store in the video RAM. Code: mov [rdi], ebx add rdi, 4 I don't know if you are interested in code optimizations but here are a couple of them:
Instead of left shifting BL 2 times why not do this with a scaled index address form? Doing so would produce the following code: Code: mov bl, al and rbx, 3 mov ebx, [edx + rbx * 4] mov [rdi], ebx add rdi, 4 If code size matters you can use STOSD provided you exchange the uses of the A and B registers in this part of your code: Code: .anotherline: mov bx, [rsi] mov cl, 8 .anotherpixel: mov al, bl and rax, 3 <--- Oops! mov eax, [rdx + rax * 4] <--- Oops! stosd ;Be sure DirectionFlag is cleared beforehand shr bx, 2 dec cl jnz .anotherpixel _________________ Real Address Mode. Last edited by SeproMan on 16 Aug 2015, 13:57; edited 1 time in total |
|||
![]() |
|
axlucas 15 Aug 2015, 21:06
SeproMan. If I just say "thank you", you won't get the idea of how much I appreciate your comments.
Before I came back here, I did figure out that I was moving a whole quad instead of the 32 bits of colour data, which caused the last pixel to show up as a vertical line to the right of my characters. I had made this error because, as I said before, I translated this routine from one I had made for 32 bits before, so I instinctively changed all 32bit regs to 64bit regs. I do see how significant it is that you have noticed this error quickly too, considering that you're not seeing my program running and that this is the very first time you read my code! About optimisations, while it's true that today's computers are really fast and have tons of memory and disk space and small changes are probably come unnoticed on these systems, I will be glad to implement these. Having to rely on a high level language most of the time is not something I enjoy and I long for the times when we had to be careful about our use of resources, because that made us better programmers. I want to continue to practise that, whether it will be noticed or not. By the way, I'd like to program for some more low-level platform than the PC.... I'll write another post on that. Cheers, mate! ![]() |
|||
![]() |
|
SeproMan 16 Aug 2015, 14:03
axlucas, I just saw I made an error in my last code snippet!
I fogot to exchange RBX for RAX 2 times. I edited the post. Here's the correct version: Code: .anotherline: mov bx, [rsi] mov cl, 8 .anotherpixel: mov al, bl and rax, 3 mov eax, [rdx + rax * 4] stosd ;Be sure DirectionFlag is cleared beforehand shr bx, 2 dec cl jnz .anotherpixel |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.