flat assembler
Message board for the users of flat assembler.

Index > Main > Method to mov [dw] to higher and lower bit of regs?

Author
Thread Post new topic Reply to topic
geekbasic@gmx.com



Joined: 25 Oct 2022
Posts: 71
Location: Arizona
geekbasic@gmx.com 12 Nov 2022, 00:01
I am trying to find a way to move the value of a word to the higher and lower bits of registers. Assuming that the word contains a small enough value.

This code gives an error. What is the correct way to do this? Is there an instruction for this? I am unable to find it.

Code:

mov dh,[x]
mov dl,[y]

x dw 0
y dw 0

    
Post 12 Nov 2022, 00:01
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20176
Location: In your JS exploiting you and your system
revolution 12 Nov 2022, 00:07
You either need a byte override to force a byte load, or change the dw definitions to db.
Code:
mov dh,byte [x]
mov dl,byte [y]

x dw 0
y dw 0    
Or
Code:
mov dh,[x]
mov dl,[y]

x db 0
y db 0    
Post 12 Nov 2022, 00:07
View user's profile Send private message Visit poster's website Reply with quote
geekbasic@gmx.com



Joined: 25 Oct 2022
Posts: 71
Location: Arizona
geekbasic@gmx.com 12 Nov 2022, 00:17
That probably would have taken me several more hours to figure out.
I was considering using db, but that would make my program more complex than using the first option you suggested. I'll give it a try..

Thank you!
Post 12 Nov 2022, 00:17
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3959
Location: vpcmipstrm
bitRAKE 12 Nov 2022, 02:23
Another option is to not give the label a size specification:
Code:
mov dh,[x]
mov dl,[y]

x: dw 0
y: dw 0    
... but then the size protection is unused.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 12 Nov 2022, 02:23
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20176
Location: In your JS exploiting you and your system
revolution 12 Nov 2022, 03:50
If you want to keep the size information and also avoid any overrides then you can use label to create an alias.
Code:
mov dh,[x_bytes]
mov dl,[y_bytes]
mov ax,[x]
mov bx,[y]

label x_bytes byte
x dw 0
label y_bytes byte
y dw 0    
Post 12 Nov 2022, 03:50
View user's profile Send private message Visit poster's website Reply with quote
geekbasic@gmx.com



Joined: 25 Oct 2022
Posts: 71
Location: Arizona
geekbasic@gmx.com 12 Nov 2022, 05:35
The size protection is to prevent overflowing from the data?
I'm trying to make sure I understand.
Post 12 Nov 2022, 05:35
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20176
Location: In your JS exploiting you and your system
revolution 12 Nov 2022, 06:05
geekbasic@gmx.com wrote:
The size protection is to prevent overflowing from the data?
Avoiding mistakes mostly.
Post 12 Nov 2022, 06:05
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.