this is a little bit confusing, but can I know what does each part of this codes means..
especially those ptr, something.
i understand those mov.. but the others aren't.

i have googled a lot, but still can't understand..

what i know:
the basic structure of tasm(.stack, .data, .code, and the start thingy, end thingy)

what i don't know, ptr, ja, byte et. all.

can you atleast explain me what these things does...

thank you very much..

.model small
.stack 100h
.data

            string db '123 test TEsting$'

.code 

start:          
            mov ax, @data
            mov ds, ax          

upper_case: 
            cmp byte ptr [BX], '$'
            
            je done
            
            ; check if it's a lower case letter:
            cmp byte ptr [bx], 'A'
            jb ok
            cmp byte ptr [bx], 'Z'
            ja ok

            ;and byte ptr [bx], 11011111b
			or byte ptr [bx], 32

ok:
            inc bx ; next char.
            jmp upper_case   


done:

            lea dx, string
            mov ah, 09h
            int 21h
         
            ; wait for any key press....
            mov ah, 0
            int 16h   
        
            mov ax, 4C00h
        
            int 21h


end start

This code builds a Small Model .EXE program, whick allocates several
segments to the program, .stack 100h allocates a 256-byte stack segment and
will initialize SS : SP when the .EXE header is read by the loader,
the code:

mov ax, @data
mov ds, ax

is necessary to load DS with the segment address of the data segment
because it will only be known at run-time, this portion of code
will be touched up with the actual address of the segment using
the relocation table after the programs memory has been allocated.
the ptr operator is requisite when using indirect addressing mode,
the line:

cmp byte ptr [BX], 'A'

simply means compare byte-sized memory operand 'pointed' to by BX
to the immediate value 65 or 'A'.

DS==ES right when the .EXE (MZ) gains control, they are initialized
with the segment address of the PSP, useful for locating your
program segment prefix.

For a intro look up TASM or Turbo-Assembler Syntax, and
check out the NGASM 8086 Tutorial.

that code actually checks if the letter is uppercase, and if it is, it will change it to lowercase, or the other way around, i don't know how exactly that program does that, can you explain it to me,..

and what if I want to code it, to check if it is lower then change it to upper, and check if upper then change it to lower... how am i suppose to do that..

thank you very much

Sorry about that, I was explaining much of the red-tape that
accompanied the 8086 DOS based assembly language source code.

the check:

cmp byte [bx], 'A' 
jb is_not ; check if byte at [bx] is lower than upper case 'A' value
cmp byte [bx], 'Z'
ja is_not ; check if byte at [bx] is above upper case 'Z' value
or byte [bx], 32 ; convert to lowercase
is_not:
...

Your code is converting a string to all lowercase, but:
BX is uninitialized and
there is not check to ensure the toggled character is in fact a letter.
Other characters lie before, between and after the contiguous
set of letters.

Hope this helps...

if char is (jb) < 'A' or char is (ja) > 'Z' then it is not uppercase
and jumps to OK, otherwise it toggles bit five [ OR BYTE, 32 ]
XOR works to toggle this bit.

i wish i could figure this things out before tomorrow..
let's see what else should I ask

oops..what should i do with that if char is jb < 'a',
what i understand from that is it is a pseudocode
saying

if char(present character) is lower than 'A' jump below, or if character is above 'Z' jump above...

waah..can't figure this things out...

what can i do to change my code to something like
changing lowercase to uppercase and uppercase to lowercase
and do not continue to run the program if there is a single none letter character..

i've been trying to figure things out myself, but i thnk i need a one on one help on thia

let me have a look at the code i provide.
tell me if my explanation is right

upper_case: 
            cmp byte ptr [BX], '$'
            
            je done

-> compare the current byte, in bx, to dollar sign($), which is the string terminator
but wth is ptr? what is byte?

-> je, if the current byte ptr content of bx is EQUAL to dollar sign(string terminator), jump to 'done'


the 'ja' and 'jb' is a bit confusing still,, the above and the below thingy confuses me,
sorry if i need a little bit of spoon feeding in here, i really need this one...

i need to understand wth is byte ptr [bx], what is the initial value or content of that [bx] for it to be compared on the string in .data


waaah...assembly is waaaah..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.