UASM Features You Might Not Have Known About

x86 / x64 programming
Post Reply
puppydrum64
Posts: 32
Joined: Thu Apr 22, 2021 9:30 pm

UASM Features You Might Not Have Known About

Post by puppydrum64 » Sun Oct 03, 2021 6:12 pm

Here's a neat little trick I learned the other day. I didn't think that the version of UASM in Keith's development kit would support this, since all the examples in the documentation are for 32-bit x86, but I was surprised to see that this actually works. Before using this I would recommend that you learn and understand how conditional jumping works on the 8086, so that you have an understanding of what these codes actually mean. It turns out there is a macro system that lets you use "C-like" constructs for branches.

Code: Select all

PrintString:
lodsb
cmp al,0
jz PrintString_Done
jmp PrintString
PrintString_Done:
ret
You can actually write it this way also, and the assembler will create the necessary assembly code automatically:

Code: Select all

PrintString:
lodsb
.if (EQUAL?)
ret
.endif
jmp PrintString
This lets you avoid having to create a bunch of contrived, repetitive label names. I still haven't figured out how to use local labels in UASM except when creating macros. I should point out that EQUAL isn't the only condition you can use. Here's a list of what can go in parentheses after the .if:


LESS?
GREATER?
ABOVE?
BELOW?
CARRY?
EQUAL?
ZERO?
OVERFLOW?
SIGN?

(You can add a ! in front to reverse the condition of each.)


The chart came from here:
http://www.terraspace.co.uk/uasm248_ext.pdf

There's a few other features that are mentioned in there but I couldn't get them all to work with 8086 programming.

Bonus: If you were wondering how to create local labels in UASM for macros, the \@ method doesn't work. This is what you have to do:

Code: Select all

	YesNoInput macro choiceYes,choiceNo
local Here
Here:
			call waitKey
			DosReadKey
			and al,11011111b
			cmp al,"Y"
			je choiceYes
			cmp al,"N"
			jne Here
			jmp choiceNo
		endm

Post Reply

Return to “8086 Assembly Programming”