> I don't know what mnemonic to use to count the number of bits
> or bytes in a memory location. Is someone willing to give mesome
> practice examples ?
Well, usually you use subtract, like this:
; move number of bytes in string into ecx
mov ecx, string.end
sub ecx, string
string db "This is a string..."
string.end
To get the number of bits, you just multiply the number of bytes by 8.
I don't know A86, so I don't know if that code will work for you or not.
> I am a self-taught student in Assembly language. I am using the
> A86 and D86 I am stuck in some practice exercices. I don't know
> what mnemonic to use to count the number of bits or bytes in a
> memory location. Is someone willing to give me some practice
> examples ? Thanks _____
((( `\
Ummm...as asked, your question _ _`\ )
doesn't appear to make a lot of (^ ) )
sense. ~-( )
_'((,,,)))
Each byte contains 8 bits...so ,-' \_/ `\
to count the bits in a number ( , |
of bytes, just multiply the `-.-'`-.-'/|_|
number of bytes by 8. \ / | |
=()=: / ,' aa
As for memory location, are you
referring to system RAM, or to allocated space within
a program you're writing, or what?
Post the exercise question...or some code...here in
the newsgroup, d00d, so we can see what you're talking
about.
In the meantime, here...assemble this little demo
with A86:
;
; BETH.ASM
; From code posted to Usenet by Beth Stone
;
; Adapted to the A86 assembler by Annie
;
; To assemble: A86 BETH.ASM
;
code segment ;start of code segment
org 100h ;DOS .COM file
;
; Check for VGA video. Error out if not found.
;
mov ah,01Ah ;function 1Ah - display combination code
mov al,0 ;sub-function 0 - read the combination code
int 10h ;call ROM BIOS video services
cmp al,1Ah ;'1Ah' returned in AL?
je okay ;yes, so we have VGA -- continue
;
; Print the 'no VGA' message, and exit.
;
mov dx,offset err ;no, so point DX to 'no VGA' message
mov ah,9 ;function 9 - print string
int 21h ;call DOS services
int 20h ;exit to DOS
;
; set video mode 13h...
;
okay:
mov ax,0013h ;function 0 - set video mode 13h
int 10h ;call ROM BIOS video services
;
; set up some pretty colours...
;
xor cx,cx
xor bx,bx
NextColour:
mov dx,968
mov al,cl
out dx,al
mov dx,969
mov al,cl
out dx,al
mov al,bh
out dx,al
mov al,bl
out dx,al
add bx,2
inc cx
cmp cx,256
jne NextColour
push ds
mov ax,0A000h
mov ds,ax
xor cx, cx
NextFrame2:
mov ax,cx
xor si,si
NextPixel:
mov [si],al
inc al
inc si
cmp si,63999
jne NextPixel
inc cx
;
; terminate the animation by pressing a key
;
mov ah,01h
int 16h
jz NextFrame2
mov ah,0
int 16h
pop ds
;
; restore "normal" text mode 3
;
mov ax,0003h
int 10h
;
; Back to DOS
;
int 20h
;
err db 13,10,205,16,' This program requires VGA video.'
db 13,10,07,'$'
;
end
Count number of bits in double word starting at memory location DS:5678h
that are 1. Move count to AL.