Re: delete bytes



almas wrote:
Hi,
I use A86, but may be, i have to use nasm, we will speak same langage.

I think you'd *like* Nasm, if you got used to it, but you shouldn't "have" to switch assemblers. It's easy to "translate" a86<->Nasm. I thought I had dosemu installed, but it needs some reconfiguring, so I can't "test" my results (and I'm too lazy to boot to real dos). But let me take a guess at what would have to change for a86 to eat this...

assemble it with "nasm convert.asm -o convert.com".

This is one difference - a86 makes a file named ".com" by default - Nasm has to be told the output name we want with the "-o" switch...

org $100

a86 does this by default, too, so could be left out. Won't hurt to include it... a86 may not accept "$" to indicate a hex number - change it to "100h" if a86 complains...


xor bp,bp ; clear flag

loop1: call getc ; get char from stdin
cmp ax,-1 ; EOF
jnz .10 ; branch if not

Labels starting with a "." are (fake) "local labels" in Nasmese. Neither Nasm nor a86 will accept a label name starting with a decimal digit. Change 'em to underscores or something. Wouldn't hurt to give these labels "full talking names"... This instance of ".10" could be named "good_character:" or something...

jmp exit ; exit program

.10: cmp al,$21
jc .20
cmp al,$2f
ja .20

Again, labels and hex numbers may need to be changed.

test bp,bp
jnz loop1 ; not the first character $21-$2f
or bp,byte 1 ; set flag

You probably don't want to say "byte" here. Nasm will generate a longer form of the instruction if you don't use it, but it'll work. a86 will try to do "contents of memory at 1" with "byte" (read chapter 4!!!).

jmp short .30

Probably don't need "short" (shouldn't hurt). Label name will need to be changed.

.20: xor bp,bp ; clear flag
.30: call putc ; write char to stdout
jmp short loop1

....


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

putc: pusha
mov ah,$40
mov dx,sp
add dx,byte 14
mov cx,1
mov bx,1
int $21
popa
ret

Eliminate "byte" - change "$" (a86 *may* accept this - I forget)

getc: xor ax,ax
pusha
mov ah,$3f
mov dx,sp
add dx,byte 14
mov cx,1
xor bx,bx
int $21
jc .10
cmp cx,ax
jnz .10
popa
ret
.10: popa
or ax,byte -1
ret

exit: mov ah,$4c
int $21

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

And so on... as you can see, the actual "code" is the same in most cases.

If you try to "translate" Herbert's code, and it doesn't work - a86 won't assemble it or it doesn't work as intended - post what you've got, and maybe we can spot what a86 doesn't like...

If you *do* want to try Nasm...

<http://sourceforge.net/project/showfiles.php?group_id=6208>

You probably want the "32bit dos binaries" - "nasm-2.02-dos.zip". Unzip it, and either put that directory on your PATH or copy "nasm.exe" and "ndisasm.exe" (if you want it) to some directory that's already on your path...

We - you and I - have our "preferences". Other people have "biases" or even "prejudices". :) I happen to like Nasm a lot. It's a "more powerful" assembler... but for what you're doing, a86 is "just as good", and maybe "simpler" to use. Programmer's choice!

Best,
Frank
.



Relevant Pages

  • Re: Input/Output
    ... You can *use* 32-bit stuff even in dos. ... Register A86, if you like it, and get A386... ... Santosh suggested int 21h/0Ah. ... mov ah, 3Fh ...
    (alt.lang.asm)
  • Re: Assembly beginner
    ... I am using the A86 and D86 ... > .I am stuck in some practice exercices. ... mov cx, tail_of_mytext - mytext ...
    (alt.lang.asm)
  • Re: 2 files in One
    ... XCHG justy use 1 byte... ... int 21h ... mov ax,offset bytes ... YES, i use A86. ...
    (alt.lang.asm)
  • Re: delete bytes
    ... I use A86, but may be, i have to use nasm, we will speak same langage. ... cmp ax,-1; EOF ... mov ah,$40 ...
    (alt.lang.asm)
  • Re: newbie: segments in a .com file
    ... the A86 I knew and used to love. ... use the word "crap" for the old when switching from A86 to NASM, ... it would be interesting which word you would use for NASM when switching ... with the graphics card. ...
    (alt.lang.asm)