Here is my awful attempt at converting this:

int a=0;

to assembly (NASM):

push cx
mov cx, 80
je short endloop
mov al,0xDB
call kputchar
add word [d],1
cmp cx,[d]
pop cx


d dw 0

I am not very good at ASM, so any help would be much appreciated. TIA

Your original "if" statement mutated into a loop there... let's look at the "if" by itself first.

A basic assembly "if" block might look like this:

cmp a, 80
  jne notequal
  ; a == 80, do something here
  jmp done
  ; a != 80, do something else here
  ; program continues...

In your case, it can be a little simpler:

cmp a, 80
  je equal
  inc a  ; only increment when a != 80
  ; program continues...

You could write your loop using similar code, but the 8086 instruction set includes a LOOP instruction.

A basic assembly "for" loop block might look like this, using CX as your loop counter:

push cx
  mov cx, 80
  ; do something here
  loop label
  pop cx

Note that LOOP counts down to zero.