Good night, what's the simpliest way to receive a simple char as parameter in Assembly 16-BITS, and compares to test if is the right one? I'm for 2 days searching for examples of how to do it, but no one had worked for me... I tried that code from StackOverflow and it doesn't work, the dx has 81h no the hex of the char that I need. I'm very newbie in Assembly, so I need little examples of code to understand... I want the simpliest way possible, I don't want to waste your time... Thanks. In MS-DOS shell I'll call my program with a char in front, like "MOVE A". The example in that code cited above works like an Echo, but I can't compares the char inserted on command line. I'm on Windows 98 with TASM 4.1 I tried the example of the book Art of Assembly cited on the link, of chapter 13.3.12, the one talking about PSP, and, doesn't work for what I need. I think people are not understanding what I wanna learn. Thanks guys
Asked
Active
Viewed 347 times
-3
-
We understand what you want, you don't understand us. You **do** need it from the PSP, offset 81h. That sample code loaded the address because you need that for that function. Otherwise you can just `mov al, [81h]` or `cmp [81h], 'a'` or similar. PS: use less bold font, thank you. – Jester Jan 03 '17 at 23:43
-
That's exactly what I'm talking about! I tried it in a lot of ways, but doesn't work. Seems that char don't goes to register.... – user3587527 Jan 03 '17 at 23:45
-
Yeah, of course. And I don't know how to debug and program that needs to parameters to work. I'm almost giving up of it... – user3587527 Jan 03 '17 at 23:48
-
Also doesn't work [photo](http://i.imgur.com/rsIP7i9.jpg) In this Test the program only would print if A was send. But it doesn't – user3587527 Jan 04 '17 at 00:10
-
http://thestarman.pcministry.com/asm/debug/debug.htm – Ped7g Jan 04 '17 at 00:32
1 Answers
2
Yes, the command line is at 81h
as you have already been told. In those examples however the address had to be passed to a print string function. If you want to access the character itself, you will need a memory load, not just its address. At least with the dosbox version I have available, the command name is not included, but the separating space is. So the actual argument character if you invoke your program as move a
will be at offset 82h
. This sample code will thus load and print the letter:
org 100h
mov dl, ds:[82h]
mov ah, 06h
int 21h
mov ax, 4c00h
int 21h
Apparently tasm
needs the ds:
prefix otherwise it emits a [Constant] assumed to mean immediate constant
warning and proceeds to use it as an immediate not an address.
PS: learn to use a debugger.

Jester
- 56,577
- 4
- 81
- 125
-
I used `82h` and told you the reason for it. So why do you have `81h`? Also you created an exe file, while you have been asking for a com file all along. This will only work as a com file. – Jester Jan 04 '17 at 00:08
-
Also doesn't works with [82h] [PRINTSCREEN](http://i.imgur.com/9azpvge.jpg) @Jester – user3587527 Jan 04 '17 at 00:14
-
Now you have `mov ah, 02h` instead of `mov ah, 06h` ... wrong function code. – Jester Jan 04 '17 at 00:16
-
-
Now you load `dl` but compare `al`. Works [here](http://imgur.com/fG73psP) – Jester Jan 04 '17 at 00:48
-
Can you send me your sourcecode please? What's your compiler? Here stil doesn't working.... – user3587527 Jan 04 '17 at 00:54
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/132244/discussion-between-user3587527-and-jester). – user3587527 Jan 04 '17 at 01:00